Closed Bug 478732 Opened 17 years ago Closed 17 years ago

nsLocalFileWin::InitWithPath is inefficient

Categories

(Core :: XPCOM, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: neil, Assigned: neil)

Details

(Keywords: perf)

Attachments

(1 file, 2 obsolete files)

It clones and adopts the input path, which also means that if anyone wants the path (e.g. Clone, GetPath) it gets copied each time. I did an unscientific test (startup and shutdown with sessionstore enabled) without and with the following patch and obtained the following statistics: 5.1% fewer allocations/frees 2.6% fewer reallocations (no idea why) 4.7% extra shares (these would have been copies) 50% fewer adoptions/frees 95% fewer copies of adopted buffers (wow!) 16% extra copies of auto buffers (presumably callers to InitWithPath)
Attached patch Proposed patch (obsolete) — — Splinter Review
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #362573 - Flags: review?(mozilla)
Attachment #362573 - Flags: review?(benjamin)
Attachment #362573 - Flags: review?(mozilla) → review-
Comment on attachment 362573 [details] [diff] [review] Proposed patch In the OS/2 version you removed the definition of the path variable but not all usages. Did you mean to change those to filePath somehow?
Attached patch Hopefully fixed OS/2 (obsolete) — — Splinter Review
Thanks for spotting that. Here's an updated patch.
Attachment #362573 - Attachment is obsolete: true
Attachment #363097 - Flags: review?(mozilla)
Attachment #363097 - Flags: review?(benjamin)
Attachment #362573 - Flags: review?(benjamin)
Comment on attachment 363097 [details] [diff] [review] Hopefully fixed OS/2 There's still pathLen... I think one could make the OS/2 code even more Windows-like with this: PRInt32 len = filePath.Length() - 1; mWorkingPath = filePath; if (filePath[len] == '\\' && !::isleadbyte(filePath[len-1])) mWorkingPath.Truncate(len);
I tried to make it even slightly more like the Windows code.
Attachment #363097 - Attachment is obsolete: true
Attachment #363220 - Flags: review?(mozilla)
Attachment #363220 - Flags: review?(benjamin)
Attachment #363097 - Flags: review?(mozilla)
Attachment #363097 - Flags: review?(benjamin)
Comment on attachment 363220 [details] [diff] [review] Third time lucky? Yes, this time it not only looks correct, I also tested and it works. Thanks, Neil!
Attachment #363220 - Flags: review?(mozilla) → review+
Attachment #363220 - Flags: review?(benjamin) → review+
Pushed changeset 1288e7384c7f to mozilla-central. Actually I pushed this yesterday but I spent so long gazing at tinderboxpushlog that I forgot to update the bug ;-)
It would help if I marked this fixed too... obviously I haven't woken up yet.
Status: ASSIGNED → RESOLVED
Closed: 17 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: