$smwgEntityCacheSizes

From semantic-mediawiki.org


Configuration parameter details:
Name $smwgEntityCacheSizes
Description Sets per-pool entry limits for the in-memory caches used to look up entity IDs during a request
Default setting See below
Software Semantic MediaWiki
Since version
Until version still available
Configuration Cache settings
Keyword cache · performance · entity · sqlstore


$smwgEntityCacheSizes is a configuration parameter that sets per-pool entry limits for the in-memory caches Semantic MediaWiki uses to look up entity IDs during a single request. Each pool maps a string key to an integer capacity. The configuration parameter was introduced in Semantic MediaWiki 7.0.0Released on 4 June 2026 and compatible with MW 1.43.x - 1.46.x., replacing the previously hardcoded EntityIdManager::MAX_CACHE_SIZE constant.1

These caches avoid duplicate database queries for the same titles and IDs while a page renders. On large or unusually rich pages the default sizes can fill up and force Semantic MediaWiki to re-query entities it has already seen. Raising a limit keeps more entries resident at the cost of additional memory. Override individual pools to tune memory use without replacing the full map; pools not listed keep their defaults.

Default setting[edit]

$smwgEntityCacheSizes = [
    'entity.id'              => 1000,
    'entity.sort'            => 1000,
    'entity.lookup'          => 2000,
    'propertytable.hash'     => 1000,
    'warmup.byid'            => 1000,
    'sequence.map'           => 1000,
    'redirect.source.lookup' => 1000,
    'redirect.target.lookup' => 1000,
    'count.map'              => 1000,
];

Available pools[edit]

  • 'entity.id' – title → Semantic MediaWiki internal ID.
  • 'entity.sort' – title → sortkey.
  • 'entity.lookup' – Semantic MediaWiki ID → wiki page data item.
  • 'propertytable.hash' – which property tables hold data for each entity.
  • 'warmup.byid' – IDs already prefetched in the current request.
  • 'sequence.map' – Semantic MediaWiki ID → property sequence map.
  • 'redirect.source.lookup' / 'redirect.target.lookup' – redirect resolution caches.
  • 'count.map' – Semantic MediaWiki ID → auxiliary count map.

Changing the default setting[edit]

To modify the setting to this configuration parameter, add a line to your "LocalSettings.php" file. To tune a single pool without replacing the full map, override only that key:

$smwgEntityCacheSizes['entity.id'] = 5000;
To assess whether tuning is needed, monitor the mediawiki.SemanticMediaWiki.inmemory_cache_hits_total and mediawiki.SemanticMediaWiki.inmemory_cache_misses_total metrics emitted via MediaWiki's StatsFactory service (when $wgStatsTarget and $wgStatsFormat are configured). A consistently low hit ratio on a specific pool indicates it would benefit from a higher limit.

See also[edit]

References

  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:6694