48c099ba03
CI / check (pull_request) Successful in 1m40s
FsStore previously CBOR-decoded all .bin nodes into memory at startup, making cold-open O(n) in time and memory. Now it scans only filenames into a Set<Hash> at init and reads/decodes nodes from disk on first get(). has() and listAll() use the filename set; put() write-throughs to cache; delete() clears cache and disk. Index/meta migration still performs a one-time scan when _index/ is missing. Adds 12 new tests (L1-L12) covering startup-no-decode, lazy get, filename-based has/listAll, write-through put, delete cleanup, list operations, and migration/bootstrap regression. All existing tests pass unchanged. Fixes #85
611 B
611 B
@ocas/fs
| @ocas/fs |
|---|
| patch |
FsStore now uses lazy loading: at startup it scans only filenames in the nodes/ subdirectory (no CBOR decoding) and reads each node from disk on first get(). This makes startup O(filenames) instead of O(decoded-bytes), keeps memory usage bounded by what's actually accessed, and avoids paying the full-load cost for stores with many nodes. Behaviour is unchanged: has(), listAll(), listByType(), listMeta(), and listSchemas() return the same results as before. Index/meta migration paths still work — they perform a one-time scan + decode when _index/ is missing.