Why close_idle_time defaults to 100000s?

Hi, all.

I find close_idle_time defaults to 30s in wiredtiger(config_def.c),why does mongo 4.4 change it to 100000(~28h) ? (related to https://jira.mongodb.org/browse/SERVER-41492, I know 4.0 also uses 100000.)

If I create many collections and don’t access them for a long period of time, is it a good idea to sweep them from memory quickly and make room for other active collections ?

And can’t we change it at runtime ?

We actually changed the default for this recently:
https://jira.mongodb.org/browse/SERVER-24949

The context for the original setting of 28 hours is here:
https://jira.mongodb.org/browse/SERVER-17907

Note that idle collection pages don’t need to be removed from memory to “make room for other active collections”, as the eviction policy will do that automatically anyway. The real reason to close idle file handles is to remove the overhead of the bookkeeping and resources necessary to keep each file open. The removal of pages in memory associated with a file handle being closed is a necessary (and somewhat undesirable) side-effect.

2 Likes

Thanks for replying.

Eviction does work when there’s cache pressure. But if eviction cannot keep up with the rate of collection being created and inserted (We once saw performance problem of eviction efficiency in mongo 4.0 production, that is, cache_used is hard to decrease even if we increase number of eviction worker), reducing close_idle_time will help sweep inactive pages, right ?

I suppose changing to 10min also applies to mongo 4.0 ? (For some reason we’re still using mongo 4.0.)

I think you are talking about eviction of dirty cache pages. Clean cache pages are simple to evict, and idle file handles only have clean pages in the cache (unless your checkpoints are taking longer than the idle sweep time; in such a case, lowering the idle sweep time will do nothing to improve this).
If you are having cache pressure, that typically means the number of dirty cache pages has hit the dirty cache limit, and no amount of freeing clean cache pages will do anything to alleviate that.