mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-22 01:20:39 +00:00
When reclaiming segments to the seastar the code tries to free the segments sequentially. For this it walks the segments from left to right and frees them, but every time a non-empty segment is met it gets migrated to another segment, that's allocated from the right end of the list. This is waste of cycles sometimes. The destination segment inherits the holes from the source one, and thus it will be compacted some time in the future. Why not compact it right at the reclamation time? It will take the same time or less, but will result in better compaction. To acheive this, the segment to be reclaimed is compacted with the existing compact_segment_locked() code with some special care around it. 1. The allocation of new segments from seastar is locked 2. The reclaiming of segments with evict-and-compact is locked as well 3. The emergency pool is opened (the compaction is called with non-empty reserve to avoid bad_alloc exception throw in the middle of compaction) 4. The segment is forcibly removed from the histogram and the closed_occupancy is updated just like it is with general compaction The segments-migration auxiliary code can be removed after this. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
78 KiB
78 KiB