Skip to content

flush: Replace sort with sweep through the hash table - #996

Merged
robertbaldyga merged 3 commits into
Open-CAS:masterfrom
robertbaldyga:flush-rework
Nov 10, 2026
Merged

robertbaldyga merged 3 commits into
Open-CAS:masterfrom
robertbaldyga:flush-rework

Conversation

@robertbaldyga

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Robert Baldyga <robert.baldyga@unvertical.com>
@robertbaldyga
robertbaldyga force-pushed the flush-rework branch 2 times, most recently from 7b8c2bd to fb6ea66 Compare November 10, 2026 22:23
The flush collected all dirty cache lines of a core into one array up
front and sorted it whole, so its memory grew with the amount of dirty
data - about 16 bytes per dirty line, ~12 GB for a dirty 3 TB cache with
4 KiB lines - and the flush failed with -OCF_ERR_NO_MEM when that could
not be allocated.

Sweep the hash table instead: collect the dirty lines of the flushed core
(or of all cores) in the collision lists of consecutive hash buckets, up
to a portion, sort the portion by core address and clean it, then go on
from the next bucket. The portion size is adapted as before, between
4 MiB and 100 MiB of cache lines, which also bounds the buffer.

The hash function assigns consecutive core lines consecutive buckets,
so a portion containing lines from consecutive buckets is likely to
contain several consecutive core line ranges, interleaved by a collision
list length (typically a few lines at most), thus the portion needs to
be sorted before being passed to the cleaner.

To keep more than one portion in flight, the hash table is split into
slices swept concurrently, one per core with dirty data, at most 16. A
line is in the list of exactly one bucket, so slices never collect the
same line.

Signed-off-by: Robert Baldyga <robert.baldyga@unvertical.com>
Signed-off-by: Robert Baldyga <robert.baldyga@unvertical.com>
@robertbaldyga
robertbaldyga merged commit f020262 into Open-CAS:master Nov 10, 2026
5 checks passed
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