mirror of
https://github.com/versity/scoutfs.git
synced 2026-02-07 19:20:44 +00:00
2bc16172808f4fc01607d74976ff31114fc9e1c6
Using kvecs for keys seemed like a good idea because there were a few uses that had keys in fragmented memory: dirent keys made up of an on-stack struct and the file name in the dentry, and keys straddling the pages that make up a cached segment. But it hasn't worked out very well. The code to perform ops on keys by iterating over vectors is pretty fiddly. And the raw kvecs only describe the actively referenced key, they know nothing about the total size of the buffer that the key resides in. Some ops can't check that they're not clobbering things, they're relying on callers not to mess up. And critically, the kvec iteration's become a bottleneck. It turns out that comparing keys is a very hot path in the item cache. All the code to initialize and iterate over two key vectors adds up when each high level fs operation is a few tree descents and each tree descent is a bunch of compares. So let's back off and have a specific struct for tracking keys that are stored in contiguous memory regions. Users ensure that keys are contiguous. The code ends up being a lot clearer, code now can see how big the full key buffer is, and the rbtree node comparison fast path is now just a memcmp. Almost all of the changes in the patch are mechanical semantic changes involving types, function names, args, and occasionaly slightly different return conventions. A slightly more involved change is that now dirent key users have to manage an allocated contiguous key with a copy of the path from the dentry. Item reading is now a little more clever about calculating the greatest range it can cache by initially walking all the segments instead of trying to do it as it runs out of items in each segment. The largest meaningful change is that now keys can't straddle page boundaries in memory which means they can't cross block boundaries in the segment. We align key offsets to the next block as we write keys to segments that would have straddled a block. We then also have to account for that padding when building segments. We add a helper that calculates if a given number of items will fit in a segment which is used by item dirtying, segment writing, and compaction. I left the tracepoint formatting for another patch. Signed-off-by: Zach Brown <zab@versity.com>
Description
No description provided
Languages
C
87%
Shell
9.3%
Roff
2.5%
TeX
0.8%
Makefile
0.4%