From: Anderson A. Giacomolli Date: Fri, 6 Nov 2026 15:39:12 +0000 (-0300) Subject: Read messages and nodes through indexes X-Git-Url: https://git.giacomolli.uk/onechat/commitdiff_plain/feda522eba3e2a27c91741c77d0d01f1840c0004?ds=inline;hp=feda522eba3e2a27c91741c77d0d01f1840c0004 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 ---