Do we need to increase the doc cache size default value?

In a clean XS we have about 1560 documents. Our default cache size is 500.

We used to have a lot less documents when we set 500 as the default. Should we increase it to have a good production-level value?

If we increase it, how does it make the minimal memory requirement evolve from https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/#HMemory

We say Small and medium installs: A minimum of 1024MB (-Xmx1024m).

Note that the Admin Tools apps says: Your cache configuration is too low for a production usage. Your cache is set to 500 documents, it should be 1000 or more.

Thx

1 Like

How do you arrive at that number? Does that include translations? I see 720 pages in a default installation. I suspect (but I’m not sure) that many of them don’t need to be in the document cache to have good performance. For example, there is no reason to have the syntax guide in cache. Same for all color themes. What would be interesting to understand is how the admin tools app arrived at that value of 1000.

I ran the following in a recent XS:

{{velocity}}
$services.query.xwql('').count()
{{/velocity}}

This includes translations and many documents that we don’t need to have in the cache all the time, as @MichaelHamann mentioned. I really doubt we need to increase the default document cache size.

I guess we could check the cache hit ratio on xwiki.org, maybe you’ve done that already @tmortagne ? To have some comparison between the # of docs and the doc cache size we’ve used on xwiki.org. That could give some ratio idea.

xwiki.org is a use case with a lot of pages which are mainly archive nobody ever access (old release notes, release plans, etc.).

It’s hard to deduce a number from a single use case.

FWIW is what I get when starting XS and just loading the home page:

Screenshot 2024-01-16 at 16.30.08

I’m surprised to see that 500 pages are already in the cache (and 1480 evictions). For hit ratio, I guess I’d need more navigation to see how it evolves.

The very first time, the solr search core is empty, so it’s loading all documents to index them.

It would be better to try after a restart on a fully indexed instance.

Actually that wiki was already indexed. I’ve check the index size and restarted to be sure and I get the same data.

I doubt we need that many documents to access the home page, I guess there are other inits that load a lot of documents. Clearing the document cache and loading the home page (without restarting) would probably get a more accurate result for what you are checking.

Good idea, it still is quite impressive, with 189 docs in the cache after call $xwiki.flushCache() on the home page and not extra navigation.

Screenshot 2024-01-16 at 17.23.56

hmm we do have timed-based evictions or any eviction strategy not based on the cache being full? After navigating a bit in the wiki and coming back to it after 15 minutes, the cache size is now at 164 entries which I find weird (evictions = 1511). I thought it was always supposed to increase until it’s full, no?

Not in the document cache. The only evictions we have are:

  • getting rid of the oldest entry when it’s full
  • remove a document when it’s modified

A time to live of less than 15 minutes would not really make any sense anyway.

Maybe something triggered your flushcache.

The reason is that evictions number is not reset when calling flushcache and there were evictions when the cache got to 500 in prior restarts of my instance (and thus there were evictions). I’ve now reset statistics (through JMX) and I can clearly see that evictions stay to 0, and when calling my page with the flushcache call using http://localhost:8080/xwiki/bin/view/Main/?xpage=xml the doc cache is at 132 entries (still a lot). It moves to 164 when calling http://localhost:8080/xwiki/bin/view/Main/ (which contains the flushcache), and to 188 when calling http://localhost:8080/xwiki/bin/view/Sandbox/.

It moves to 295 entries when I click all the App Panel entries.

So indeed for a standard XS wiki without anything in it, it seems that 500 is enough.

OK, but the eviction number was not really the weird thing for me: from what you described you went from a cache containing 189 entries to one containing “only” 164 without doing anything.