Skip to content

mpt: change to variable-width Key and Val types#80

Open
rsc wants to merge 2 commits into
FiloSottile:mainfrom
rsc:main
Open

mpt: change to variable-width Key and Val types#80
rsc wants to merge 2 commits into
FiloSottile:mainfrom
rsc:main

Conversation

@rsc

@rsc rsc commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Key and Val are now slices instead of fixed-width [32]byte values.
Client code will need updating, especially code that expects key1 := key2 to make a copy of the key.

rsc added 2 commits July 10, 2026 11:04
Until now the client of pmem has not needed to know the size
of the space used on the on-disk leaf file. Variable-sized keys and values
is going to change that. Add tracking of the size of the disk data.

Also be more explicit about the invariants guaranteed in transactions
with respect to ReadDisk/WriteDisk, and test disks thoroughly in the
random testing.
Allow variable-width Key and Val, so that applications are not
locked into 32-byte blobs as the only possible format.

Update disk format to support variable-width keys and values.
The first write of a key reserves space for the number of bytes
in the associated value. Future updates can overwrite that space
as long as the value does not grow in size. If the value does get
larger, then the existing space is abandoned (leaked) and new
space is allocated. That strategy should be fine for now,
since all of our applications have fixed-size values anyway.

Also create and use new testdata/treehash.txt, test vectors
for tree creation and snapshotting.
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