~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The server outgrows its memory bound writing a repository of 100000 records

Open
Open chadtmiller.com opened this issue 1 comment

spec/STORE.md, "Scale", says the server's resident memory is at every moment at most its base, plus PDS_CACHE_BYTES, plus 4 KiB an account, and that "holding, reading or writing a repository of any size stays within the bound". Writing one repository of many small records does not.

Seen

node compare.mjs --scale with the getBlocks check of branch harness/getblocks, which writes 100000 records of about 40 bytes to one account by applyWrites of 200 (harness/checks/scale.mjs, writeWide), sampling the server's RSS every 20 ms, with PDS_CACHE_BYTES 16 MiB and 2000 accounts:

RunPeakBound
183.3 MiB75.4 MiB
294.1 MiB75.7 MiB
3 (the planted-bug run)93.9 MiBabout 75.7 MiB

The same run's 64 MiB repository of 560 records of 120 KB stays within the bound (60 to 62 MiB); so do the getRepo of it and the firehose replay.

Where to look

Not measured: what the server holds of an account between folds of its log grows with the writes since the last one (crates/pds-server/src/checkpoint.rs, the mem blocks, paths and events), and 100000 small records are some 130000 blocks.

Done when

node compare.mjs --scale on harness/getblocks passes, with the memory bound held while the 100000 records are written; then that branch's check of getBlocks lands, and LIMITS.md "getBlocks" leaves harness/spec-coverage.mjs's UNCHECKED. A change to how the server stores runs just nightly here too (AGENTS.md).

The same cause as at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/spec-pds/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3n2446s6uvtsq found for space repos: on main an account's log is compacted only past its checkpoint's size (store.rs policy, cap: None), and the account being written is never evicted, so its memtable grows with the repository. That pull's compaction for what the memtable counts (cache.rs, disk.mem.cost() > ctx.cache.memtable()) counts a repository's blocks and paths too, so it should fix this. Once it lands: node compare.mjs --scale on harness/getblocks merged with main, alone; if it holds the bound while the 100000 records are written, that branch's getBlocks check lands and LIMITS.md "getBlocks" leaves UNCHECKED.