Hasty Briefsbeta

Bilingual

FFS Optimizations with Dirhash

a year ago
  • #OpenBSD
  • #Filesystem
  • #Optimization
  • OpenBSD's filesystem subsystem is divided into VFS (Virtual File System), UFS (Unix File System), and FFS (Fast File System).
  • VFS provides a unified interface to file systems, UFS organizes files in a Unix-like manner, and FFS handles disk storage with OpenBSD-specific optimizations.
  • Optimizations in OpenBSD's filesystem are limited, with softdep no longer available since g2k23.
  • dirhash is an in-memory hash table for large directories, improving file lookup performance from O(n) to O(1).
  • The default dirhash cache size is 5MB, adjustable via sysctl (vfs.ffs.dirhash_maxmem).
  • Increasing dirhash_maxmem can optimize performance, especially for systems with many files or large directories.
  • A practical approach is to set a high value (e.g., 50MB), run 'find /' to populate the cache, and then adjust based on actual usage.
  • Systems with ample RAM can benefit from larger dirhash cache sizes without significant overhead.