Closed Bug 724207 Opened 12 years ago Closed 12 years ago

Save 15-20ms on startup from unused file attributes fetch when opening files

Categories

(Core :: XPCOM, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: bbondy, Assigned: bbondy)

References

Details

Attachments

(1 file, 2 obsolete files)

Attached patch Patch v1. (obsolete) — Splinter Review
nsLocalFile::OpenNSPRFileDesc is called 311 times during startup, this takes 20-30ms of startup time.

We currently call ResolveaAndStat before opening the file, the purpose is just to get the resolved path though.
There are 311 extra unused GetFileAttributeEx calls because of this.
We should instead use the newer Resolve() method which takes almost no time to run.

These results were obtained by a small profiler I'm using which is based on QueryPerformanceCounter and QueryPerformanceFrequency.
Attachment #594394 - Flags: review?(benjamin)
Comment on attachment 594394 [details] [diff] [review]
Patch v1.

>-    nsresult rv = ResolveAndStat();
>+    nsresult rv = Resolve();
Aha, well there's one of them ;-)

>     if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND)
I don't think Resolve() ever returns this, because it doesn't stat.

Alternatively, test mResolveDirty and if it's true then Resolve() failed.
> I don't think Resolve() ever returns this, because it doesn't stat.
> Alternatively, test mResolveDirty and if it's true then Resolve() failed.

I think the check is only really needed to save time on failure conditions, but I think you're right that it should be adjusted. I'll go with testing mResolveDirty
Attached patch Patch v2. (obsolete) — Splinter Review
bsmedberg, I'm just going to r? Neil on this since he's already looked at it.  Let me know if you need to sr it though.

> I don't think Resolve() ever returns this, because it doesn't stat.
> Alternatively, test mResolveDirty and if it's true then Resolve() failed.

On second thought, to keep the code path the same we should just remove the 
`&& rv != NS_ERROR_FILE_NOT_FOUND)`.
Attachment #594394 - Attachment is obsolete: true
Attachment #594394 - Flags: review?(benjamin)
Attachment #595018 - Flags: review?(neil)
Attached patch Patch v2.Splinter Review
Attachment #595018 - Attachment is obsolete: true
Attachment #595018 - Flags: review?(neil)
Attachment #595019 - Flags: review?(neil)
Attachment #595019 - Flags: review?(neil) → review+
https://hg.mozilla.org/mozilla-central/rev/f4a4146c5683

\o/
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: