]> git.giacomolli.uk - onechat/commit
Read messages and nodes through indexes
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Fri, 6 Nov 2026 15:39:12 +0000 (12:39 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Fri, 6 Nov 2026 15:39:12 +0000 (12:39 -0300)
commitfeda522eba3e2a27c91741c77d0d01f1840c0004
tree31e48ff26f0d9ce98fb8286b4e871f0eff966fc7
parentecf2974df6ab9222978c259fdbb091fc8f8f4369
Read messages and nodes through indexes

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
journal.go
log.go
log_test.go
memory.go
memory_test.go
records.go [new file with mode: 0644]
replay_test.go
tree.go
tree_test.go
view.go
view_test.go