Cache FileInfo when replaying WAL #3137
Merged
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.
The WAL replayer is currently opening the destination file every time it updates or inserts a page, which is unnecessary and slows down bulk modifications.
In the benchmarks for #2938 it reduced the cost of replaying the WAL (in tmpfs) from 4.5 seconds to 3.2 seconds (where I'm still copying the hash index through the WAL file on the first try, but on additional copies in future significant amounts of data will still need to go through the WAL file).
I don't particularly like this solution, and I feel like it would be better to group them by file (removing the need for hashing and repeatedly looking up the same file), but I don't know of any way reasonable way of doing that without messing up the order that the records are replayed.
I briefly tried using a std::find with a vector of pairs, which gave more or less the same performance. If we allowed c++23 I'd use std::flat_map, but I'm not convinced that the vector of pairs by itself simplifies anything (no hashing, but messier access).