report and trees hold every record, including both hex hashes, in memory #14
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
report.go:32-48callsloadFileRows(db.go:207-239), which materializes the entirefilestable as a[]scanRec.trees.go:38-43does the same and then builds the full node graph on top of it.Each record carries two 64-character hex hash strings plus the path plus slice and string headers — call it 210 bytes at minimum, before Go's allocator overhead. At the stated scale of ~10M files that is over 2 GB resident for
reportalone, on a machine that may be the same storage server running the scan.This is the one design constraint the scan phase goes out of its way to honour and the reporting phase ignores. README §Design goal 2 is explicit: "Holding one small record (path, size, mtime) per file in memory during a scan is acceptable; holding every file's hashes is not (they stay in the database)."
Note the two commands have different ceilings.
reportnever needs more than one duplicate group at a time and can stream.treesgenuinely needs the whole hierarchy to compute Merkle digests bottom-up, but it does not need to retain the hex hashes once a leaf's signature has been folded into its parent's digest.Definition of done
reportstreams: group in SQL withORDER BY size DESC, head, tail, pathover rows whereheadis non-empty, add the supporting index, and emit each group as its boundary is crossed. It must never hold more than one group. Output must remain byte-identical to today's for a given database — the existing report tests must pass unchanged.treesstops retaining the record slice and the hex hash strings; leaf signatures are folded into parent digests as rows stream in, so peak memory is proportional to the directory count, not the file count.make checkgreen, andmake teststill finishes in under 20 seconds (build the 10M-row database in a throwaway benchmark, not in the test suite).