Closed
Bug 524178
Opened 16 years ago
Closed 16 years ago
sessionrestore.js is read in 1kb chunks
Categories
(Firefox :: Session Restore, defect)
Firefox
Session Restore
Tracking
()
VERIFIED
FIXED
Firefox 3.7a1
People
(Reporter: taras.mozilla, Assigned: zpao)
Details
(Keywords: perf, Whiteboard: [ts][affects mobile])
Attachments
(1 file, 1 obsolete file)
|
2.46 KB,
patch
|
dietrich
:
review+
|
Details | Diff | Splinter Review |
Given that this file can get quite large, it would be best if the code would call ->available and then read the whole length of the file. Individual read() syscalls can be quite slow on wince/osx
| Reporter | ||
Updated•16 years ago
|
Whiteboard: [ts]
Updated•16 years ago
|
| Assignee | ||
Comment 1•16 years ago
|
||
For easy linkage: http://hg.mozilla.org/mozilla-central/file/be5eeaf56443/browser/components/sessionstore/src/nsSessionStartup.js#l280
So since I'm not familiar with all the file APIs, what's actually happening?
I see cvstream.init with a 1kb buffer, and then cvstream.readString reading 4096 characters. Does init read the file into memory in 1kb chunks and then readString pulls it from memory into other memory?
| Reporter | ||
Comment 2•16 years ago
|
||
First one is a conversionstream. It seems to act as a buffering input stream. I am not sure why stuff is being converted here.
So the buffering stream reads in 1k chunks, but the consumer stream is reading in 4k chunks, so every consumer read call, ends up in 4 read syscalls. Easy fix is to just boost the buffers to a high enough number, but i'd rather have the code figureout number of bytes avail and read in exact amount(ie going from 260 reads() in the case of 260K file, to 1).
| Assignee | ||
Comment 3•16 years ago
|
||
I can take this. Looks like it should be easy.
Should I just make the change in the buffer stream or should both streams read the full length. Are there potential issues if that happens? I've heard of very large (>50MB) sessionstore.js files in extreme atypical cases. Will that cause problems?
Assignee: nobody → paul
Comment 4•16 years ago
|
||
50mb sessionstore.js will cause all kinds of problems outside of just reading the file. i think you should read the whole thing for this bug, and file a followup to cap how much we'll read in.
| Assignee | ||
Comment 5•16 years ago
|
||
Per discussion with Taras, we should be fine getting rid of the while loop since stream.available() will max out at PR_UINT_32_MAX, but that would mean we'd be trying to read a 4gb+ file. I don't think we need to guard against that case because... well, a 4gb sessionstore.js file?!
Attachment #415488 -
Flags: review?(dietrich)
Comment 6•16 years ago
|
||
Comment on attachment 415488 [details] [diff] [review]
Patch v0.1
cancelling, reviewed on irc
Attachment #415488 -
Flags: review?(dietrich)
| Assignee | ||
Comment 7•16 years ago
|
||
Added a max file size (100MB) and an error message if we go over it.
Attachment #415488 -
Attachment is obsolete: true
Attachment #415685 -
Flags: review?(dietrich)
Comment 8•16 years ago
|
||
Comment on attachment 415685 [details] [diff] [review]
Patch v0.2
r=me assuming you've tested the cap code, and verified that a new session is started and the error makes it to the console.
Attachment #415685 -
Flags: review?(dietrich) → review+
| Assignee | ||
Comment 9•16 years ago
|
||
(In reply to comment #8)
> r=me assuming you've tested the cap code, and verified that a new session is
> started and the error makes it to the console.
I did. Of course it requires that javascript.options.showInConsole is true, but that's consistent with most errors (and in particular, other sessionstore errors).
Target Milestone: --- → Firefox 3.7a1
| Assignee | ||
Comment 10•16 years ago
|
||
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Comment 11•16 years ago
|
||
Comment on attachment 415685 [details] [diff] [review]
Patch v0.2
>+ if (fileSize > MAX_FILE_SIZE)
>+ throw "SessionStartup: sessionstore.js was not processed because it was too large.";
Shouldn't you be throwing a Components.Exception object here and pass Cr.NS_ERROR_FILE_TOO_BIG for it?
| Assignee | ||
Comment 12•16 years ago
|
||
(In reply to comment #11)
> (From update of attachment 415685 [details] [diff] [review])
> >+ if (fileSize > MAX_FILE_SIZE)
> >+ throw "SessionStartup: sessionstore.js was not processed because it was too large.";
> Shouldn't you be throwing a Components.Exception object here and pass
> Cr.NS_ERROR_FILE_TOO_BIG for it?
I was looking for an existing Cr to throw, but none seemed appropriate.
From https://developer.mozilla.org/en/Table_Of_Errors - NS_ERROR_FILE_TOO_BIG "This error occurs when the createUnique method cannot create a file with a unique filename. This indicates that too many files have been created already."
Regardless, all we do is report the error to the console, and treat it as if the file didn't exist. The error doesn't get thrown out of this method.
Comment 13•16 years ago
|
||
(In reply to comment #12)
> From https://developer.mozilla.org/en/Table_Of_Errors - NS_ERROR_FILE_TOO_BIG
> "This error occurs when the createUnique method cannot create a file with a
> unique filename. This indicates that too many files have been created already."
Haha, I bet that description is wrong (I didn't even know we had that page).
Comment 14•15 years ago
|
||
Is there anything QA can do to verify this bug?
| Assignee | ||
Comment 15•15 years ago
|
||
(In reply to comment #14)
> Is there anything QA can do to verify this bug?
Not unless you want to get dtrace set up & run a script that looks at system read calls.
Comment 16•15 years ago
|
||
(In reply to comment #15)
> (In reply to comment #14)
> > Is there anything QA can do to verify this bug?
>
> Not unless you want to get dtrace set up & run a script that looks at system
> read calls.
Is there any perceptible performance improvement expected that QA can check for?
| Reporter | ||
Comment 17•15 years ago
|
||
(In reply to comment #16)
> Is there any perceptible performance improvement expected that QA can check
> for?
No. The overhead can only be meaningfully measured either with good instrumentation or with crappy instrumentation on slow operating systems such as windows mobile.
Comment 18•15 years ago
|
||
(In reply to comment #17)
> (In reply to comment #16)
>
> > Is there any perceptible performance improvement expected that QA can check
> > for?
>
> No. The overhead can only be meaningfully measured either with good
> instrumentation or with crappy instrumentation on slow operating systems such
> as windows mobile.
Ok, marking as VERIFIED based on faith and the confidence of the developers :)
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•