CacheStorageService::PurgeOverMemoryLimit() doesn't work correctly under specific circumstances
Categories
(Core :: Networking: Cache, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox79 | --- | fixed |
People
(Reporter: mconley, Assigned: mayhemer)
References
Details
(Whiteboard: [MemShrink:P2][gfx-noted][necko-triaged])
Attachments
(5 files, 1 obsolete file)
| Reporter | ||
Comment 1•7 years ago
|
||
| STR | ||
| Reporter | ||
Comment 2•7 years ago
|
||
Updated•7 years ago
|
Comment 3•7 years ago
|
||
| Reporter | ||
Comment 4•7 years ago
|
||
Comment 5•7 years ago
|
||
Comment 6•7 years ago
|
||
Comment 7•7 years ago
|
||
| Reporter | ||
Comment 8•7 years ago
|
||
Comment 9•7 years ago
|
||
| Reporter | ||
Comment 10•7 years ago
|
||
Comment 11•7 years ago
|
||
Comment 12•7 years ago
|
||
Comment 13•7 years ago
|
||
Updated•7 years ago
|
| Reporter | ||
Comment 14•7 years ago
|
||
Comment 15•7 years ago
|
||
Comment 16•7 years ago
|
||
Comment 17•7 years ago
|
||
Comment 18•7 years ago
|
||
Updated•7 years ago
|
Comment 19•7 years ago
|
||
Comment 20•7 years ago
|
||
| Assignee | ||
Comment 21•7 years ago
|
||
Updated•7 years ago
|
| Assignee | ||
Comment 22•5 years ago
|
||
| Assignee | ||
Comment 23•5 years ago
|
||
Comment 24•5 years ago
|
||
Stupid question of an outsider, why not combining both ideas and do presumably costly sort only every now and then.
- I.e. sort only every other time but make sure, that new entries are added to safer places.
- Make sure that a minimum number of purges happen, regardless of high prio interruptions.
This avoids the strange sorting which might cause problems in other situations.
I do not know about memoryLimit thing, might or might not be good.
Go! I am afraid, this particular bug bugs me since 2010.
Updated•5 years ago
|
| Assignee | ||
Comment 25•5 years ago
|
||
Let's see how this works with the second (purge > 20) patch. Occasional sorting turned out to happen still too often. And looking at the array shows it's scattered too much. If we manager to keep the array relatively short, sorting may be kept fast. I also put a 10% reserve on the memory limit, so we purge a little bit more - to specifically save sorting time.
Comment 26•5 years ago
|
||
(In reply to Honza Bambas (:mayhemer) from comment #25)
Let's see how this works with the second (purge > 20) patch. Occasional sorting turned out to happen still too often. And looking at the array shows it's scattered too much. If we manager to keep the array relatively short, sorting may be kept fast. I also put a 10% reserve on the memory limit, so we purge a little bit more - to specifically save sorting time.
Why exactly 20? Is it enough? The minimum delay between purging is 4 seconds and I can imagine that a way more entries could be added in 4 seconds.
(In reply to Frank Nestel from comment #24)
Go! I am afraid, this particular bug bugs me since 2010.
That's unlikely because this code landed in 2015 :)
| Assignee | ||
Comment 27•5 years ago
|
||
(In reply to Michal Novotny [:michal] from comment #26)
(In reply to Honza Bambas (:mayhemer) from comment #25)
Let's see how this works with the second (purge > 20) patch. Occasional sorting turned out to happen still too often. And looking at the array shows it's scattered too much. If we manager to keep the array relatively short, sorting may be kept fast. I also put a 10% reserve on the memory limit, so we purge a little bit more - to specifically save sorting time.
Why exactly 20? Is it enough? The minimum delay between purging is 4 seconds and I can imagine that a way more entries could be added in 4 seconds.
Good point with the 4 seconds, I forgot about it. Then it should be more, yes. What about to try to reduce the array to some specific length only? Aka, do kind of a limit on the array length?
Comment 28•5 years ago
|
||
That's unlikely because this code landed in 2015 :)
OK. How was previous code? Not serious question of course. Thanks for correcting me.
I am a poor bug reporter as I am reporting memory leaks for about 7+ years, and never ever convinced someone to solve at least one, I am not back to Firefox yet, but I would love to :(
- You can still go for even rarer sorting (you had that 0.1 tuning factor up there).
- That 0.9 thing is of course also a way to reduce frequency.
- I feel in a loaded environment (ok, my Browser) there will be many fresh objects and the balance between trashing old and new is critical. It is unfortunate, that there is not at least some LRU policy fallback. But I understand, this might be beyond this fix.
Comment 29•5 years ago
|
||
(In reply to Honza Bambas (:mayhemer) from comment #27)
Good point with the 4 seconds, I forgot about it. Then it should be more, yes. What about to try to reduce the array to some specific length only? Aka, do kind of a limit on the array length?
Sounds like a good approach. This would avoid infinite growth of the array.
Updated•5 years ago
|
Comment 30•5 years ago
|
||
Opening a Firefox instance, opening quite a few tabs (70 maybe), seeing 1323 cache entries in about:cache (and 16487 on disk). Somewhat irritating, nearly all the in memory cached things are actually "expired immediately". Can this be used to tune sorting? I.e. is it expired? Looks like this isn't my leak either. Sigh. Anyway, leaks must be fixed.
Comment 31•5 years ago
|
||
Question/Comments.
- Where do the 2000 come from? I have a one day old Firefox with exact 80 tabs and 1422 cache entries. Cache limit is 32768 LiB, Cache use is 17295 KiB. Limit expected to trigger way beyond 2000 only.
- The code does not really warrant the cache is shrunk to 2000, since it could contain many small bits and the loop can exit earlier.
- Sorting the zero access to the end protects both, the new entries in cache and old entries that get never used. This will fill the cache with useless entries as used entries will killed before unused ones.
Comment 32•5 years ago
|
||
- I have missed, this is about disk cache. Here my Firefox looks like
Number of entries: 15222
Maximum storage size: 1048576 KiB
Storage in use: 587576 KiB
2000 sounds brutally low, cleanup will kill many heavily used entries and keep all the unused ones.
Comment 33•5 years ago
|
||
- On disk cache there is also an expiry date, use this as (sub) criterion for sorting to clear at least unused expired stuff.
Comment 34•5 years ago
|
||
Comment 35•5 years ago
|
||
| bugherder | ||
Comment 36•5 years ago
|
||
OK, thanks, I'll disable disk cache.
Comment 37•5 years ago
|
||
This is nothing personal. But what does this patch do? Why not getting a user benefit of the time and ideas investigated?
The patch is obviously fixing worst case, but has big potential of damaging the whole purpose of a cache.
No vision about user your users, this is why Firefox is on the decline.
| Assignee | ||
Comment 38•5 years ago
|
||
(In reply to Frank Nestel from comment #31)
Question/Comments.
- Where do the 2000 come from? I have a one day old Firefox with exact 80 tabs and 1422 cache entries. Cache limit is 32768 LiB, Cache use is 17295 KiB. Limit expected to trigger way beyond 2000 only.
We have a so called "pool" of entries we keep in memory (only headers) while they are in direct use or expected to be reused again (on follow on navigation, for instance). The bug was cleaning this pool was not working when it grew beyond some limit.
Hence, I added a limit that keeps cleaning this pool until we have only 2000 entries. It's totally arbitrary number, but seems reasonable according experience and testing.
- The code does not really warrant the cache is shrunk to 2000, since it could contain many small bits and the loop can exit earlier.
You misunderstand what the patch does.
- Sorting the zero access to the end protects both, the new entries in cache and old entries that get never used. This will fill the cache with useless entries as used entries will killed before unused ones.
Again, you don't understand the code.
(In reply to Frank Nestel from comment #32)
- I have missed, this is about disk cache. Here my Firefox looks like
Number of entries: 15222
Maximum storage size: 1048576 KiB
Storage in use: 587576 KiB
2000 sounds brutally low, cleanup will kill many heavily used entries and keep all the unused ones.
What you are looking at is how many entries is on your disk, not in the memory pool.
(In reply to Frank Nestel from comment #33)
- On disk cache there is also an expiry date, use this as (sub) criterion for sorting to clear at least unused expired stuff.
It's not that simple, because there are situations we want to use expired (stall) content and it's totally valid. I will not go to details about it, because it's beyond the scope of this bug.
(In reply to Frank Nestel from comment #36)
OK, thanks, I'll disable disk cache.
I don't follow this offensive reaction at all.
(In reply to Frank Nestel from comment #37)
This is nothing personal. But what does this patch do? Why not getting a user benefit of the time and ideas investigated?
We always do, if it has the technical quality.
The patch is obviously fixing worst case, but has big potential of damaging the whole purpose of a cache.
Again, you misunderstand the patch.
No vision about user your users, this is why Firefox is on the decline.
Again, offensive reaction I don't follow.
Comment 39•5 years ago
|
||
Thank you for your answer, though it fails to convince me. Yes, I might not have missed some presumed magic going on, but you didn't attempt to change that.
Simple question: From observed cache of 13000 entries, under 2000 well used and over 11000 with no access recorded according to about:cache, what would your patch remove?
| Assignee | ||
Comment 40•5 years ago
|
||
(In reply to Frank Nestel from comment #39)
Thank you for your answer, though it fails to convince me. Yes, I might not have missed some presumed magic going on, but you didn't attempt to change that.
Simple question: From observed cache of 13000 entries, under 2000 well used and over 11000 with no access recorded according to about:cache, what would your patch remove?
Nothing. It doesn't do anything with on disk entries. And I believe it's now clear from my comment trying to explain what the patch does.
Please let's stop polluting this bug now. Let's see how the patch works in the field and if leaks in this code persist, let's look at it again.
Thanks.
Updated•5 years ago
|
Description
•