SchOS/kernel/fs/schfs
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz ddf1e41177 schfs: cache the last inode and the last extent
Every read descended the B-tree twice per block -- once for the inode and
once for the extent -- so an 834 KB file cost 418 descents, each a tree
walk plus a 4 KB copy out of the buffer cache per node visited. A
sequential read asks for the same inode every time and usually stays
inside one extent, so both answers were already known and thrown away.

One entry each, not a table: the pattern being optimised is a single file
read straight through, and one entry catches all of it without needing an
eviction policy. A second reader simply misses.

Correctness rests entirely on invalidation, so it is blunt: all five
write entry points in objw.c call schfs_cache_invalidate() before
touching anything. A cache that is merely usually right would hand back
another file's data. The volume pointer is part of the key because the
host tools can hold two images open at once.

Measured in the guest, bracketed inside one command line, TCG:

  read 834 KB   1.73s -> 0.31s   (5.6x, together with the BOUNCE fix)
  ls /bin cold  2.80s -> 1.40s   (2x)
  ls /bin warm  0.70s -> 0.70s   (unchanged)

Warm ls is untouched on purpose-by-consequence: it is 241 separate
inodes, so a one-entry cache never hits. That cost is the per-entry
lookup path -- dirlookup plus iload, each its own descent -- and it is
where the next order of magnitude is, not here.

schfs-check passes, including the round-trip; bootcheck 108 [ok].

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 23:52:11 +02:00
..
btree.c Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
btree.h Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
kmount.c Rename Schunix to SchOS; the kernel becomes SchIFT 2026-08-09 14:09:59 +02:00
obj.c schfs: cache the last inode and the last extent 2026-08-09 23:52:11 +02:00
objw.c schfs: cache the last inode and the last extent 2026-08-09 23:52:11 +02:00
schfs_int.h schfs: cache the last inode and the last extent 2026-08-09 23:52:11 +02:00
space.c Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
vfs.c schfs: read a whole block per tree descent, not half of one 2026-08-09 23:41:11 +02:00
vol.c Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00