Skip to content

Making the cluster cache global can result in highly increased memory usage for mono-ZIM-file use cases #1037

@veloman-yunkan

Description

@veloman-yunkan

This ticket grows from kiwix/libkiwix#1265

Making the cluster cache global (#960) had a fallout in the form of increased memory usage in mono-ZIM-file scenarios (when a single ZIM file is open at any given time). Global cache was considered mainly in the context of kiwix-serve where multiple ZIM files are simultaneously active, and each having its own independent cache could lead to indefinite growth of memory usage. Once the cache was made global (shared across all ZIM archives) it was natural to set a high default max limit so that kiwix-serve's performance didn't suffer. However, for mono-ZIM-file use cases this effectively translated to a significantly increased limit for the cluster cache - going from 16 to about half a thousand in terms of cluster count (assuming 2MiB clusters).

Though affected client applications can explicitly lower the cluster cache limit to the previous level, @kelson42 considers the change of the default behavior a regression. An easy way to fix that regression is to lower the default limit of the (global) cluster cache. But that will mean a regression for kiwix-serve and other multi-ZIM applications!

One (more complex) solution that will satisfy both sides, is to bind the current cache size limit to the number of open ZIM files while capping it at the hard limit, i.e.

cache_memory_limit = min(512MiB, 16MiB * (number of open ZIM files))

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions