Plasma turns on in-memory compression only when memory usage is close to quota. In-memory compression can slow down scan throughput due to decompression cost during scan. In cases where scan working set is within quota but the overall memory use is close to quota, scan pages can still get compressed.
One way to fix this issue is to track memory stats used by working set. In plasma, the working set are the pages with InUse bit being set. When a page is being used by mutation or scan, the page is marked as InUse. The swapper (eviction) is responsible for resetting the InUse bit as it sweeps through the pages.
As the swapper resets the bit, it will compress the page (if uncompressed). As the page is compressed, the swapper can calculate the memory (pre-compressed) consumed by this page. We can then adjust the working set memory stats by subtracting the memory of this page.
As the swapper resets the bit and the page is already compressed, we need to get the memory consumed by the page from compressDelta.
When a compressed page being marked in-use, we will need to add the memory back to working set stats.
Currently, for burst eviction, we do not compress a page when inUse bit is reset. We will either have to compress unused page during burst eviction or find another mean to track page memory.