carrotdata / carrot-cache

In-Out-Process Java cache (L1/L2 off-heap, scalable, ZeroGC) with full SSD support
Apache License 2.0
3 stars 0 forks source link

[CODE] Improve in-memory cache save and load time #431

Closed VladRodionov closed 2 months ago

VladRodionov commented 2 months ago

For in-memory caches we can write segments to disk asynchronously when segment is sealed. Then on shutdown we will need to save only index and some other meta , this should be much faster. On start up, read data segments in parallel.

VladRodionov commented 2 months ago

We can avoid rehashing index as well before saving. This will give us additional performance boost.

VladRodionov commented 2 months ago

First optimization: increased performance of reading saved memory index by introducing BufferedInputStream with large buffer size (16MB) This gives significant boost in read I/O. Another optimization is parallel saving loading engine data and memory index.

VladRodionov commented 2 months ago

Further optimizations seems won't give any significant reduction in save/load cache operation time. We are now close to 4GB/s on load and 2GB/s on save on Mac Studio M1

VladRodionov commented 2 months ago

Removed finishRehashing() call in MemoryIndex::save() method - it improved save operation performance.