Skip to content

Use hexane as the in memory representation of coln-store - #112

Open
incipit0 wants to merge 14 commits into
mainfrom
coln-store/exp
Open

Use hexane as the in memory representation of coln-store#112
incipit0 wants to merge 14 commits into
mainfrom
coln-store/exp

Conversation

@incipit0

@incipit0 incipit0 commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

This is a major rewrite of the in memory representation of data. We now use hexane columns to represent data, which gives us nice compression properties, saving us lots of memory. This also provides us with a nice indexing data structure, like a btree index, but instead here we are using a sorted hexane column as indexes.

This PR also introduces a complete rewrite of the previous rowing data structures, which is used when structurally identical terms come up and we need to identify. I tried to follow egglog's style of canonicalisation. It also introduces memory savings by only adding ids that require canonicalisation to rowing.

Finally this PR introduces rollback functionalities to the store, which means we can rollback changes if a transaction aborts, without copying the entire store, which was a serious scalability issue.

incipit0 and others added 14 commits August 4, 2026 11:24
Coln tables tend to store lots of ids in memory. Storing all of them
as plain (hash,counter) will blow up memory easily because each of them
require 36 bytes. Instead use dictionary encoding for these ids so that
we can represent each id with 8 bytes of memory, a 4x reduction in
memory footprint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
We introduce three optimisations to optimise the in memory consumption
for large tables with lots of ids and hashes:

  1. stream the importing from csv to coln-store in batch. This avoids a
     big increase in peak memory consumption. This does not change the
     stable memory consumption, but avoids the potential of OOM kicking
     in when importing a large file.
  2. cmt.resolved_ops now returns an iterator rather than a Vec. Again
     this is to reduce the peak memory consumption because creating a
     Vec that holds a copy of all the ids with hash in them is wasteful.
  3. Drop Commit.pending field after we apply it, trading compute for
     space. This is because the data would be accessed in tables and it
     is wasteful to keep another copy in each commit, essentially
     doubling the memory usage.

  Hashcons data structure is disabled, and will be optimised next.
Use hexane as the in memory representation for data, and indexes. This
helps reduce the memory footprint, especially for hashcons data
structures. So we manage to go from 12 GB to about 6 GB.

Also make the `id_packer` a store wide construction, which is shared by
the index data structures (`HexaneIndex`) and the `Rowing` hashcons data
structure.
Introduce ColumnMap as well.
A basic rollback support for tables and id_packer. Hashcons is broken
right now and will be rewritten.

Also add PackedOp so that tables no longer need to take id_packer.
It is not txn specific, so move to a more generic location.
Use egglog style canonicalisation: i.e. do fixpoint iteration until we
get no more ids to update.

Also add rollback support for rowing, for now this is doing some cloning.
But we expect most of the data structures in rowing small. So should not
be a big problem.

This is a major rewrite of many of the internals of coln-store, to hopefully
get better memory footprint. But for this commit, get to work first.
During rebuilding, add the option to do a full table scan rather than
using index. Index scan is disabled for now until rebuilding becomes
slow enough we need to do an index scan. But even then maybe we can just
have a hexane index on each column than a HashMap<rowid, Vec<rowid>>.

The full table scan right now reduces memory from 1.5 G to 350 MB.

Also make finalize_handles canonicalise ids.
This saves some cloning around and reduces the peak memory usage by
about 150 MB.

Also reduces runtime by about 200s.
Just like duckdb -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant