Add cache for SHM segments
Add a cache to allow the reuse of SHM segments. Shared memory segments are added to the cache instead of being deallocated, and the cache is searched instead of/before allocating a new segment. Both the SHM segments and their attachment with the X server are cached. The cache currently has a fixed number of 10 entries, this provided a good cache hit rate while keeping memory usage under control. Building with DEBUG_SHM_CACHE defined and running with G_MESSAGES_DEBUG=all will periodically print out the SHM cache hit rate. On my Ubuntu 18.04 system running XFCE4 with a 2560x1440 screen, the cache hit rate starts around 72%. On-screen windows that update often and have consistently-sized damage rectangles are the best case. With several of those (scrolling terminal windows, web browser showing a WebGL demo), the hit rate slowly rises to around 92%. Operations that generate rapid damage reports (like resizing or moving windows) will lower the hit rate. Signed-off-by:Brendan Shanks <bshanks@codeweavers.com> Acked-by:
Jeremy White <jwhite@codeweavers.com>
Please register or sign in to comment