3 ms·
If your dcache is growing to the point that each bucket has many entries in it, you can also increase the number of buckets in the hash table using the dhash_en
by caf 9y ago
If your dcache is growing to the point that each bucket has many entries in it, you can also increase the number of buckets in the hash table using the dhash_entries kernel command-line option.
(The latency in this situation is caused not by the sheer number of entries, but by the fact that the hash table is undersized for the number of entries it gets).
- haikuginger 9y agoOut of curiosity, do you know why the kernel uses a fixed-size hash table as opposed to a dynamically-expanding one?
- caf 9y agoI'm not sure I can give a definitive answer, but there's a few difficulties in making it expand. One is that in the kernel, you can only reliably make large contiguous kmalloc() allocations at init time; another is that the dentry cache is highly optimised for parallel access (most lookups will proceed without taking locks under Read-Copy-Update). In most cases memory pressure will tend to naturally limit the dentry cache size - the "perfect storm" here was almost zero memory pressure combined with a process doing a lot of negative lookups on an essentially endless list of unique filenames. For such an unusual situation, it's probably reasonable to ask the administrator to manually tune things, rather than building a more complex runtime-resizing hashtable that almost everyone won't need - especially since the failure mode is a graceful performance degradation.