Performance: Tiered directory storage
Directory entries are no longer maintained in sorted order. Small directories (< DirMapThreshold entries) use linear scan. Larger directories lazily allocate a hash map for O(1) lookups, similar to ext4's inline-to-htree promotion.
This yields a 13x speedup on directory creation and 9x speedup on mkdir in downstream benchmarks (absfs/absnfs).
Breaking behavior change
ReadDir() no longer returns entries in sorted order. No ordering guarantee is made. Code that relied on sorted iteration should sort explicitly:
entries := node.ReadDir()
sort.Slice(entries, func(i, j int) bool {
return entries[i].Name() < entries[j].Name()
})Directory still implements sort.Interface, so sort.Sort(dir) also works.
New API
DirMapThreshold— exported var controlling when the hash map is allocated (default: 4). Unlikely to need changing; only modify with a measured reason.