Skip to content

Instantly share code, notes, and snippets.

View congwang-mk's full-sized avatar

Cong Wang congwang-mk

View GitHub Profile
@congwang-mk
congwang-mk / lmbench-full-daxfs.sh
Created August 17, 2026 03:09
Multikernel vs. KVM lmbench benchmark scripts (multikernel.io: Measuring the Virtualization Tax with lmbench)
#!/bin/bash
# Boot one spawn kernel that runs the full lmbench suite built from the
# autubrew/lmbench image (Ubuntu 20.04 + lmbench source, no prebuilt
# binaries). kerf pulls --image through skopeo from the registry, so a
# locally built image is invisible to it; instead the built container is
# exported once to a rootfs directory and loaded with --rootfs-dir.
#
# One-time setup (already done on this machine):
# docker run --name lmbench-build --entrypoint /bin/bash \
# autubrew/lmbench -c 'cd /root/lmbench/src && make -j8'
@congwang-mk
congwang-mk / fio-shared-daxfs.sh
Created August 4, 2026 21:45
fio-shared-daxfs.sh
#!/bin/bash
# Boot two spawn kernels that share one daxfs rootfs and each run fio.
#
# The first instance is loaded with --image, which extracts the Docker
# image and creates the daxfs image in multikernel memory. The second
# instance is loaded without --image: its command line points at the
# same daxfs physical region, so both kernels mount the same base image
# and the same lock-free write overlay. Both spawn kernels load daxfs
# as a module from the bootstrap initramfs.
#
@congwang-mk
congwang-mk / bench_redis.py
Created March 21, 2026 22:08
Sandlock vs Docker Redis benchmark
#!/usr/bin/env python3
"""Benchmark Redis: bare metal vs sandlock vs Docker.
redis-server runs in each environment.
redis-benchmark runs on host, connecting to the server.
Tests SET/GET with small payloads (256 bytes) — similar to RioDB's pattern.
"""
import json
import subprocess
root@localhost:~# kerf exec --console --verbose web-server
Instance name: web-server (ID: 1)
Checking if kernel image is loaded for instance 'web-server'...
Status file: /sys/fs/multikernel/instances/web-server/status
Instance status: 'loaded'
✓ Kernel image found for instance 'web-server'
Instance ID to boot: 1
Using reboot syscall with command: 0x4d4b4c49
Calling reboot syscall at TSC 126359934520
✓ Boot command executed successfully (result: 0)
@congwang-mk
congwang-mk / tsc_elapsed.py
Created January 22, 2026 02:43
Python tool to convert TSC to ms
#!/usr/bin/env python3
import sys
import re
def get_tsc_freq_mhz():
with open('/proc/cpuinfo', 'r') as f:
for line in f:
if line.startswith('cpu MHz'):
match = re.search(r':\s*([\d.]+)', line)
if match:
@congwang-mk
congwang-mk / dmesg.txt
Created January 10, 2026 02:36
36ms kernel boot
[ 0.000000] Linux version 6.19.0-rc2+ (wangcong@pop-os) (gcc (Ubuntu 12.3.0-1ubuntu1~22.04.2) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #2033 SMP Fri Jan 9 18:33:57 PST 2026
[ 0.000000] Command line: pci=noaer,lastbus=0 lpj=999999 clocksource=tsc tsc=reliable pci=realloc=off random.trust_cpu=on console=ttyS0 pci=nobar quiet rootfstype=daxfs rootflags=phys=0x48000000,size=9834496 init=/init
[ 0.000000] x86 CPU feature dependency check failure: CPU0 has '18*32+31' enabled but '18*32+26' disabled. Kernel might be fine, but no guarantees.
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] MULTIKERNEL: [mem 0x0000000040000000-0x0000000047ffffff] usable
[ 0.000000] random: crng init done
[ 0.000000] setup: detected multikernel KHO data
[ 0.000000] KHO: Multikernel KHO: processing FDT at 0x3bfd000 (size: 4096)
[ 0.000000] KHO: Multikernel KHO: successfully populated FDT data
[ 0.000000] NX (Execute Disable) protection: active
@congwang-mk
congwang-mk / dmesg.txt
Created December 29, 2025 22:17
49ms kernel boot message
[ 0.000000] Linux version 6.19.0-rc2+ (wangcong@pop-os) (gcc (Ubuntu 12.3.0-1ubuntu1~22.04.2) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #1438 SMP PREEMPT_DYNAMIC Mon Dec 29 14:00:12 PST 2025
[ 0.000000] Command line: pci=noaer,lastbus=0 lpj=999999 clocksource=tsc tsc=reliable pci=realloc=off random.trust_cpu=on loglevel=0 quiet 8250.nr_uarts=0 console=ttyprintk pci=nobar rootfstype=daxfs rootflags=phys=0x48000000,size=9838592 init=/init
[ 0.000000] x86 CPU feature dependency check failure: CPU0 has '18*32+31' enabled but '18*32+26' disabled. Kernel might be fine, but no guarantees.
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000001000-0x000000000009fbff] usable
[ 0.000000] BIOS-e820: [mem 0x0000000040000000-0x0000000047ffffff] usable
[ 0.000000] random: crng init done
[ 0.000000] setup: detected multikernel KHO data
[ 0.000000] KHO: Multikernel KHO: processing FDT at 0xb708000 (size: 4096)
[ 0.000000] KHO: Multikernel KHO: successfully po
@congwang-mk
congwang-mk / kernel.config
Last active December 10, 2025 00:40
Multikernel kernel config
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 6.18.0 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 12.3.0-1ubuntu1~22.04.2) 12.3.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=120300
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=23800
@congwang-mk
congwang-mk / mk_vsock_server.c
Created November 12, 2025 17:10
Multikernel Vsock Test (Server)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <linux/vm_sockets.h>
#define VSOCK_TRANSPORT_VM 0
#define VSOCK_TRANSPORT_MULTIKERNEL 1
@congwang-mk
congwang-mk / mk_vsock_client.c
Created November 12, 2025 17:09
Multikernel Vsock Test (Client)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <linux/vm_sockets.h>
#define VSOCK_TRANSPORT_VM 0
#define VSOCK_TRANSPORT_MULTIKERNEL 1