Files
disktree/crates/disktree-core
Joshua Gosse 48fc31af48 tree: a node is 88 bytes instead of 120
A home directory of 2.6 million directories and 17 million files is
19.7 million nodes, so every field of Node is paid that many times: its
120 bytes were 2.36 GB of the scan's 3.27 GB peak.

- own_bytes and own_files are no longer stored. After aggregate a leaf's
  own figures always equal its totals, and only the selection line reads
  a directory's, so Node::own_bytes() and own_files() sum the direct
  children when asked. A leaf's bytes is now the measured size and the
  only input; de-duplication zeroes it for a second name, as it zeroed
  own_bytes before.
- dirs is a u32, which packs beside the one-byte fields.
- inode is Option<(u64, NonZeroU64)>: no file has inode or file record
  zero, so None fits in the niche and the pair costs 16 bytes, not 24.
  Node::identity() gives the plain pair.

On the same home directory, peak memory for a scan falls from 3,267 MB
to 2,588 MB and node storage from 2,359 MB to 1,731 MB. Trees are
identical to upstream's with de-duplication off (1.25 million nodes
across ~/src, /Applications and /System/Applications, both size modes),
and the totals are identical with it on. a_node_stays_small holds the
size on 64-bit targets.
2026-09-28 09:38:59 -04:00
..