Skip to content

Audit and benchmark non-file hot paths - #3

Open
siraben wants to merge 6 commits into
codex/io-memory-benchmarksfrom
codex/non-file-hotpath-benchmarks
Open

Audit and benchmark non-file hot paths#3
siraben wants to merge 6 commits into
codex/io-memory-benchmarksfrom
codex/non-file-hotpath-benchmarks

Conversation

@siraben

@siraben siraben commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds focused C benchmarks for non-file hot paths: syscall identity, time syscalls, futex EAGAIN, eventfd, epoll readiness, mmap faults, fd control, fork/wait, signal masks, and sched_yield.
  • Defers poll notify-pipe setup until a poll actually blocks, avoiding pipe/fcntl/kevent setup for immediate-ready epoll/poll paths.
  • Avoids host timezone work for gettimeofday when the guest passes a null tz pointer.
  • Tightens fcntl(F_GETFD/F_SETFD) to update/read cloexec under the fd table lock and avoids bit-setting an invalid F_DUPFD_CLOEXEC result.

Benchmark Notes

Final focused run:

CLANG=/opt/homebrew/opt/llvm/bin/clang RUNS=5 WARMUPS=1 PREPARE_APK_INDEXES=0 \
  BENCH_FILTER='^(syscall_identity|identity_extended|time_syscalls|futex_eagain|eventfd_loop|epoll_eventfd|mmap_faults|fd_control|process_wait|signal_mask|yield_loop|pipe_throughput|dev_urandom_stream)$' \
  OUT=/tmp/ish-nonfile-final \
  I386_BASE_FS=e2e_out/bench-base/i386 \
  RV64_BASE_FS=e2e_out/bench-base/riscv64 \
  ./benchmarks/hot_paths/compare.sh
Benchmark i386 best RV64 best RV64 vs i386
dev_urandom_stream 0.007796s / 2052.33 MiB/s 0.007492s / 2135.61 MiB/s 1.041x
epoll_eventfd 0.226719s 0.150893s 1.503x
eventfd_loop 0.200460s 0.202724s 0.989x
fd_control 0.787822s 0.866376s 0.909x
futex_eagain 0.241512s 0.268871s 0.898x
identity_extended 1.055663s 1.086358s 0.972x
mmap_faults 0.012561s / 20380.54 MiB/s 0.012897s / 19849.58 MiB/s 0.974x
pipe_throughput 0.010779s / 2968.74 MiB/s 0.010400s / 3076.92 MiB/s 1.036x
process_wait 0.014454s 0.014640s 0.987x
signal_mask 0.398589s 0.405305s 0.983x
syscall_identity 1.921237s 2.194061s 0.876x
time_syscalls 0.501590s 0.556313s 0.902x
yield_loop 0.052319s 0.052326s 1.000x

Earlier focused before/after for the poll change showed RV64 epoll_eventfd moving from 0.207266s to 0.136769s, a 1.515x speedup on that immediate-ready workload. The final broader run still shows epoll_eventfd at 1.503x vs i386.

Validation

  • ninja -C build-bench-rv64 ish
  • python3 -m py_compile benchmarks/hot_paths/compare.py benchmarks/hot_paths/run.py
  • git diff --check
  • Focused cross-arch benchmark run above

siraben commented Apr 28, 2026

Copy link
Copy Markdown
Owner Author

Follow-up hot-path pass pushed through ecc7ec12.

Implemented and kept:

Area Benchmark Before best After best Speedup Notes
fakefs negative metadata cache stat_misses 1.470629s 0.813193s 1.81x 5 runs, RV64 old build vs current branch
poll grouping / callback fanout poll_many_ready 0.136954s 0.034819s 3.93x 5 runs, RV64 old build vs current branch

Current focused RV64/i386 comparison after the changes:

Benchmark i386 best RV64 best RV64 speedup
recursive_ls_deep 0.160000s 0.080000s 2.00x
find_stat_deep 3.800000s 5.060000s 0.75x
fstat_loop 0.058137s 0.023193s 2.51x
stat_misses 3.130487s 0.813193s 3.85x
eventfd_loop 0.177551s 0.195855s 0.91x
epoll_eventfd 0.223901s 0.144718s 1.55x
poll_many_ready 0.144021s 0.034819s 4.14x
fd_high_churn 0.728030s 0.278294s 2.62x

Discarded after measurement:

Experiment Result
fakefs inode-stat cache No measurable gain beyond the negative path cache; removed before commit.
fdtable next_free allocation hint Slowed fd_high_churn on RV64 (0.263854s baseline vs 0.275629s with the hint in the earlier run); removed before commit.
fakefs stat cache size matrix 2048 remains the best tradeoff. 8192 did not improve the realistic metadata workloads.

Validation run before pushing:

  • ninja -C build-bench-rv64 ish
  • python3 -m py_compile benchmarks/hot_paths/compare.py benchmarks/hot_paths/run.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant