Rate This Document
Findability
Accuracy
Completeness
Readability

Prefetch Optimization

Application scenario: random Get, Seek, range-query starting-point lookups, and MemTable lookups that miss the cache

Technical principle: This feature issues cache prefetch instructions before the data is actually used, overlapping memory accesses with computation phases such as key comparison and restart-point binary search, thereby reducing stalls caused by cache misses.

  • Skip list pointer chasing optimization

    After accessing the current node, the optimization prefetches both x->Next(level - 1) and next->Next(level). The former prepares the first candidate node at the lower level for descending after a failed comparison, while the latter prepares the next-next node for continued traversal at the same level. During the current key comparison, the memory subsystem can fetch the data at these addresses in parallel.

  • Block lookup prefetch optimization

    At the start of the binary search within a block, the optimization prefetches the initial midpoint. During a sequential scan, it prefetches the next key. On each comparison, it computes and prefetches the midpoints of the left and right subintervals at the same time. Regardless of whether the next iteration goes left or right, the candidate restart offset has a chance to be brought into the cache ahead of time, reducing additional misses caused by the branch direction.

Performance metric: The performance on YCSB workloads A to F is improved by 1% to 2% on average.

Figure 1 Performance comparison

How to use:

For details, see RocksDB 6.26.1 Prefetch Optimization Feature Guide.