Session Restore generates sustained large disk traffic [meta]
Categories
(Firefox :: Session Restore, defect)
Tracking
()
| Performance Impact | medium |
People
(Reporter: gcp, Unassigned)
References
(Depends on 2 open bugs, Blocks 1 open bug)
Details
(5 keywords)
Attachments
(1 file, 3 obsolete files)
|
3.56 KB,
patch
|
mak
:
feedback+
|
Details | Diff | Splinter Review |
Comment 2•9 years ago
|
||
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
Comment 6•9 years ago
|
||
| mozreview-review | ||
Comment 7•9 years ago
|
||
| mozreview-review | ||
Comment 8•9 years ago
|
||
| mozreview-review | ||
Comment 9•9 years ago
|
||
| mozreview-review | ||
Comment 10•9 years ago
|
||
Updated•9 years ago
|
Updated•9 years ago
|
Comment 11•9 years ago
|
||
Comment 13•9 years ago
|
||
Comment 14•9 years ago
|
||
Comment 15•9 years ago
|
||
Comment 17•9 years ago
|
||
Comment 20•9 years ago
|
||
Comment 22•9 years ago
|
||
Comment 23•9 years ago
|
||
Comment 25•9 years ago
|
||
Comment 27•9 years ago
|
||
Comment 28•9 years ago
|
||
Comment 29•9 years ago
|
||
Comment 30•9 years ago
|
||
Comment 32•9 years ago
|
||
Comment 33•9 years ago
|
||
Comment 34•9 years ago
|
||
Comment 35•9 years ago
|
||
Comment 36•9 years ago
|
||
Comment 37•9 years ago
|
||
Comment 38•9 years ago
|
||
Comment 39•9 years ago
|
||
Comment 40•9 years ago
|
||
Comment 41•9 years ago
|
||
Comment 42•9 years ago
|
||
Comment 43•9 years ago
|
||
Comment 44•9 years ago
|
||
Comment 45•9 years ago
|
||
Comment 47•8 years ago
|
||
Comment 48•8 years ago
|
||
Comment 49•8 years ago
|
||
| Comment hidden (offtopic) |
| Comment hidden (offtopic) |
Comment 52•8 years ago
|
||
Comment 53•8 years ago
|
||
Comment 54•8 years ago
|
||
Comment 55•8 years ago
|
||
Updated•7 years ago
|
Updated•7 years ago
|
Comment 56•7 years ago
|
||
Comment 57•7 years ago
•
|
||
| workaround | ||
I have browser.sessionstore.interval set to 60, which is working quite well
Comment 58•6 years ago
|
||
I believe we can stop saving the session all the time: save it only when quitting Firefox. In case Firefox crash we can use an exception to save the information.
The only problem is in the rare case of a system crash. For those rare cases, we can only save the URL of all open tab when tab is open/closed. Saving URL in sqlite will be very few IO. In case of a crash, you will have to reload all the tab, and perhaps you lose some information. But is that really a problem? I will be perhaps affected once a year. On top of that, I don't think peoples are waiting for a full restore in case of a system crash.
Today, Firefox is using so much IO that I have to change browser.sessionstore.interval to have normal performance for other programs. The current situation is not viable.
Comment 59•6 years ago
•
|
||
(In reply to perdrisat from comment #58)
I believe we can stop saving the session all the time: save it only when quitting Firefox. In case Firefox crash we can use an exception to save the information.
Bad idea. But maybe it should be an option in about:config allowing to change time between savings, and to turn off this savings between Firefox restarts.
Comment 60•6 years ago
|
||
(In reply to Robert Ab from comment #59)
Bad idea.
For what it's worth, I strongly disagree. Firefox is constantly wasting battery power (via wakeups) and SSD longevity (by frequent and sizeable filesystem writes). This behavior is completely unnecessary, not at all typical for a program that is primarily a document reader, and hidden from the vast majority of users with no obvious way to disable it even if they do eventually discover it. This, the current behavior, is an ill-conceived, bloody awful idea.
Please don't be so dismissive of legitimate suggestions for fixing the problem. Let's instead try to make Firefox better.
Comment 61•6 years ago
•
|
||
(In reply to Forest from comment #60)
(In reply to Robert Ab from comment #59)
Bad idea.
For what it's worth, I strongly disagree. Firefox is constantly wasting battery power (via wakeups) and SSD longevity (by frequent and sizeable filesystem writes). This behavior is completely unnecessary, not at all typical for a program that is primarily a document reader, and hidden from the vast majority of users with no obvious way to disable it even if they do eventually discover it. This, the current behavior, is an ill-conceived, bloody awful idea.
Please don't be so dismissive of legitimate suggestions for fixing the problem. Let's instead try to make Firefox better.
But maybe it should be an option in about:config allowing to change time between savings, and to turn off this savings between Firefox restarts. So everybody can decide what it is better for him/her.
Another possible solution. Session managers (like Tab Session Manager) can be installed in Firefox. TSM is using IndexedDB now as extension storage, which make much easier on HDD/SSD.
Comment 62•6 years ago
|
||
In case Firefox crash we can use an exception to save the information.
Bad idea.
I think it's a fine idea, but not that this is not acceptable in general.
There are multiple situations beyond the "system crash" (which I take as meaning "the whole computer crashes") in which Firefox will not be given the chance to run exception handlers. For example, when a user force-kills Firefox because it hung irrecoverably, or on Linux when the out-of-memory killer kicks in (which triggers a SIGKILL signal where the process is terminated without any chance to run code at shutdown).
This means there must be some form of saving in between to guard against that.
However, it is totally sensible to reduce any form of "periodic" saving as much as possible.
For example, there's no point in saving the current state if it hasn't changed, and it might also make sense to save only the changes instead of the full state every time.
Also, giving about:config settings to tune the tradeoff between safety and resource usage sounds great. However, we should still make the general situation as good as possible.
On top of that, I don't think peoples are waiting for a full restore in case of a system crash.
This one I strongly oppose. I expect Firefox to recover in this situation.
I have some tabs open in Firefox for over 10 years, and it has never permanently lost them, across thousands of restarts and hundreds of hard crashes. This is one of the features where Firefox does a lot better than Chromiu. This is how good programs behave, and it is feasible (many modern programs have this property of being extremely reliable in not losing user data; Sublime Text is another example).
And it's critical for a good user experience to not have users lose data.
Comment 63•6 years ago
|
||
(In reply to Niklas Hambüchen from comment #62)
This means there must be some form of saving in between to guard against that.
I hope we can rephrase that to, "it makes sense to offer the option of saving in between, to guard against such crashes." After all, to think of it as a "must" would be to presume to know users' needs better than they do themselves, to waste their resources without their permission, and to assume that a browser cannot exist without this behavior. :)
For example, there's no point in saving the current state if it hasn't changed
Indeed. For example, none of the web pages/apps/sites that I use need their state saved when I haven't been typing or clicking in them. Save frequency can therefore be reduced to zero for such cases.
Optimizing all three of these would be great:
- what to save
- how to represent it
- when to save it
Making the last one easily configurable, perhaps with options like "regularly", "infrequently and only after user input", and "never", would be flexible enough to work for most people?
Comment 64•6 years ago
|
||
(In reply to Forest from comment #63)
(In reply to Niklas Hambüchen from comment #62)
...For example, there's no point in saving the current state if it hasn't changed
Indeed. For example, none of the web pages/apps/sites that I use need their state saved when I haven't been typing or clicking in them. Save frequency can therefore be reduced to zero for such cases.
Do you understand how this already works?
The time interval doesn't mean data is always resaved every X seconds. Interval is when state change is checked, and ONLY if the state has changed is anything written. If you are seeing writes when there was no state change then that is a bug you can file.
Comment 65•6 years ago
|
||
I expect Firefox to recover in this situation.
Perhaps I was not clear enough in my comment #58. I'm not saying we should not save tabs or take the risk to lose them.
There are two aspects:
Opened tabs/windows
We should constantly save which tab are open (this is not the case now, it's only append every 15secondes). With this information we can restore all the opened tabs in any case. But this is very light information (basically just URL and windows).
Sessions
Sessions hold a lot more information, this is the "page state". Session can sometimes change without interaction from the user. I believe we can store session when Firefox close instead of a regular interval. I believe session information are not critical as opened tab are.
I'm sure we can do something smarter, but this bug is 3 years old and nothings appended yet.
But maybe it should be an option in about:config
No. Option are not there to fix bugs. Having constantly ~1-2mb/s of IO is a bug, not a feature. This have dramatic implication when you run on a networked disk for example.
Comment 66•6 years ago
|
||
I'm going to restrict comments to users with editbugs because at this point, comments are going in circles and not adding new information.
A significant amount of work happened since this bug was first filed that has reduced the severity of the problem.
There's still more that can be done, that's why this bug is marked up as a metabug and there are still open related bugs.
We're not going to compromise on the ability of users to restore after a crash (of either the machine or Firefox). There is still plenty of scope to improve the situation without doing so.
If you're seeing dramatic performance issues unless you alter internal session store prefs, please file a new dependent bug as comment #64 suggested, with detailed steps about how to reproduce the issue starting with a clean Firefox profile (ie what add-ons to install, which sites show problems), and ideally after some checks with the Firefox profiler ( https://developer.mozilla.org/en-US/docs/Mozilla/Performance/Reporting_a_Performance_Problem ) and/or disk monitoring tools like those from sysinternals that show that the problem is actually sessionstore-related.
Updated•6 years ago
|
Updated•3 years ago
|
Updated•2 years ago
|
Updated•1 year ago
|
| Reporter | ||
Comment 67•1 year ago
|
||
This came up recently, so I had a check: my current session restore file is 2.4M (double that of the initial report), and last year the 75th Percentile of sizes was 950k, so 25% of our users have a file >1M.
So despite adding compression, this got worse compared to https://bugzilla.mozilla.org/show_bug.cgi?id=1304389#c22.
The current file that I have is actually 7.5MB in size.
| Reporter | ||
Comment 69•1 year ago
•
|
||
I believe it's possible to incrementally update the recovery.jsonlz4/sessionstore.jsonlz4 while avoiding the issues with atomicity and garbage collection of stale files, by appending to the existing file with diffs and rewriting it entirely when (for example) the diff part is equal or larger than the original part. Restoring then consists of reading the normal file, decompressing the diffs and applying them. This would only work if the rest of the session restore machinery doesn't rely on being able to move the file away every single time - I'm not 100% sure that's not the case, but I think that only happens on a normal shutdown, not during the 15 second updates.
For generating the diffs, I can see several options:
- There's several libraries that can do JSON diff and patch that could be used for this. Not sure any of them are production solid enough to use in session restore though.
- Something ad hock is possible: Instead of writing out the raw JSON, split it on entries (e.g. windows->tabs->entries, _closedTabs->state->entries, etc, probably want to do the same for the cookie list) and compute and store a hash per entry (with modern hashes like BLAKE3 or AHash this is negligible overhead). Then write out the compressed data (in 1 block). Keep the hashes around. For the next session dump, do the same operation, but check whether the hash matches for each entry. If it does, delete the entry. If it does not, store the old hash and the new hash in a list. At the end, store all compressed data including new entries, and a list of hashes (entries) that were deleted and append this to the file. Basically we're patching by hashing each "entry" and recording the adds/removes/replaces by hash.
- Probably the easiest: Decode (or have stored in RAM) the previous JSON, call
ZSTD_createCDict()with it, and then compress the new one. This should work very well as long as the zstd window is equal at least to the previous session size, and I think we can guarantee that, as a huge session size is less likely to happen on a low RAM machine.
The advantage of these approaches is that they're entirely on the data serialization level. You don't need to know anything or depend on Firefox internals to get this working, and can even shove it in an external Rust library or whatever.
My first thought was to just hash the per-tab data, and re-transmit changed tabs, but look at this:
Data size per second-level domain (in bytes), from the recovery.jsonlz4 from my personal profile:
google.com: 169965
slack.com: 462642
discord.com: 19308696
mozilla.org: 70929
chatgpt.com: 266999
openai.com: 11871
github.com: 198099
pytorch.org: 9431
nvidia.com: 7445
openreview.net: 11008
arxiv.org: 19187
github.io: 20058
reddit.com: 104768
searchfox.org: 15451
<rest mostly negligible>
...
Given that discord.com is the majority of data, and also the one that keeps changing, you do really need to diff/patch the data itself. But the zstd approach should be fast, easy and efficient for this. So quite doable, I hope.
Also, FWIW, just switching to zstd @ level 1 instead of LZ4 gives a factor 2x-3x improvement. These kind of fast high ratio compressors weren't available 8 years ago.
Updated•1 year ago
|
Comment 70•1 year ago
|
||
The Performance Impact Calculator has determined this bug's performance impact to be medium. If you'd like to request re-triage, you can reset the Performance Impact flag to "?" or needinfo the triage sheriff.
Platforms: [x] Windows [x] macOS [x] Linux
Impact on browser: Causes noticeable jank
Configuration: Specific but common
Websites affected: Rare
Resource impact: Some
[x] Affects animation smoothness
[x] Able to reproduce locally
[x] Multiple reporters
Updated•1 year ago
|
Description
•