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

RESOLVED FIXED in mozilla13

Status

()

Core
XPCOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: bbondy, Assigned: bbondy)

Tracking

unspecified
mozilla13
x86_64
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

5 years ago
Created attachment 594394 [details] [diff] [review]
Patch v1.

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 1

5 years ago
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.
(Assignee)

Comment 2

5 years ago
> 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
(Assignee)

Comment 3

5 years ago
Created attachment 595018 [details] [diff] [review]
Patch v2.

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)
(Assignee)

Comment 4

5 years ago
Created attachment 595019 [details] [diff] [review]
Patch v2.
Attachment #595018 - Attachment is obsolete: true
Attachment #595018 - Flags: review?(neil)
Attachment #595019 - Flags: review?(neil)

Updated

5 years ago
Attachment #595019 - Flags: review?(neil) → review+
(Assignee)

Comment 5

5 years ago
http://hg.mozilla.org/integration/mozilla-inbound/rev/f4a4146c5683
Target Milestone: --- → mozilla13

Comment 6

5 years ago
https://hg.mozilla.org/mozilla-central/rev/f4a4146c5683

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