-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Towards stable storage of indexes and the ART #8703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… code, and generalizing index allocation
Mytherin
reviewed
Sep 1, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Looks great - some minor comments below:
test/sql/index/art/storage/test_art_storage_multi_checkpoint.test
Outdated
Show resolved
Hide resolved
…ex memory for DROP INDEX
# Conflicts: # test/sql/storage_version/storage_version.db
|
Thanks! Looks excellent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR reworks our ART serialization implementation. Currently, we (de)serialize on a per-node basis, as described here.
We already moved away from per-node allocations for in-memory allocations (#6951). Instead, we store ART nodes on fixed-size allocators. In this PR, we implement (de)serializing these fixed-size allocators directly.
Previously, any fixed-size allocator would store its buffers as memory pointers in a
vector. Instead, eachFixedSizeAllocatornow holds anunordered_mapof<idx_t, FixedSizeBuffer>elements (buffer ID and buffer). These fixed-size buffers keep track of their state. They can store both a memory pointer and a disk pointer. Additionally, they have three flags: (1)in_memory, (2)on_disk, and (3)dirty. With these flags, it is possible only to serialize buffers that are not yet on disk or dirty. Also, we continue to deserialize lazily, i.e., if a node is on a buffer that is not yet in memory, then we deserialize the respective buffer.Next steps
in_memory && (!on_disk || dirty). However, after that serialization, we do not reset thedirtyflag. So, if any buffer is dirty, it will repeatedly get serialized at each checkpoint until closing/restarting the database connection. For a more in-depth example, seetest/sql/index/art/storage/test_art_storage_multi_checkpoint.test. We cannot yet reset thedirtyflag, which causes overwritten/invalid disk memory issues that we have to look into. For reference, see here: b70af69, c224d2b, and Rework Metadata Storage #8513.Node::GetChildandNode::GetNextChildfunction and two implementations for each (const NodeandNode); seenode.hpp. The same holds forPrefix::Traverseinprefix.hpp. Also, all node-type specific files now inline these functions into their header file. There may be a more elegant way of solving this (Windows could not resolve the types of templates)! 😄FixedSizeAllocator,FixedSizeBuffer, andIndexPointer) concerning pluggable indexes!Towards stable storage and pluggable indexes
Working towards stable storage and pluggable indexes, we made the following changes.
FixedSizeAllocatorclass is now completely decoupled from the ART. Ideally, any future index can use these allocators to store its memory. Therefore, we unify how indexes (de)serialize their memory through these allocators.IndexPointerclass. TheFixedSizeAllocatorprovides these index pointers to be used by arbitrary indexes. Any index requiring memory can allocate multiple buffers of up to approximatelyBUFFER_SIZE = Storage::BLOCK_ALLOC_SIZE;memory segments, with anIndexPointerto each memory section.Nodeclass is now a specialization of theIndexPointer, with additional functionality specific to ART nodes.Serializeon everyFixedSizeAllocatorit utilizes.Benchmarks
I've added a new benchmark,
benchmark/micro/index/checkpoint/checkpoint_art.benchmark, to ensure we do not regress on (de)serialization speed. Also, here are some general timings for some of our ART benchmarks. We increase performance for checkpoints and do not regress for other index operations. We also increase the performance of constraint checking, deletions, and insertions with minor general changes in this PR.INT64INT64, 2.5M distinctINT, approx. 100 distinctVARCHAR, 8GB memory limitVARCHARVARCHARINTINT64INT64INT64, one pointNotes
BlockPointerdirectly instead ofblock_idandoffsetseparately.consts).