]> git.giacomolli.uk - onechat/commitdiff
Read messages and nodes through indexes
authorAnderson A. Giacomolli <redacted>
Fri, 6 Nov 2026 15:39:12 +0000 (12:39 -0300)
committerAnderson A. Giacomolli <redacted>
Fri, 6 Nov 2026 15:39:12 +0000 (12:39 -0300)
The memory core no longer holds the whole log, which grows by about 200
MB a month. The log and the tree read each message and node from its day
file at the position in an index. index/main.idx holds the position of
message i in record i. index/tree.idx lists the node lines in file
order, and index/tree-L.idx holds the position of node (L, i) in record
i, with a zero record for a node that is not built. A read is one read
of the index and one of the day file.

At open the log and the tree index the lines after their last indexed
line, so a missing index is built again from the day files, and the
lines that a crash left out of an index join it. A partial record at the
end of an index is cut. The last node of the tree gets its level record
again, because a crash can stop an add between the two index writes.

The views keep the nodes of their own lines, and a running build keeps
its task. Nothing else stays in memory: after the 100,000-message
synthetic log the heap in use is about 3.4 MB.

Issue: beb9a70


No differences found