Closed Bug 15810 Opened 26 years ago Closed 26 years ago

[Perf] PR_Sync is called when you close a read-only file

Categories

(Core :: XPCOM, defect, P3)

PowerPC
Mac System 8.5
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: sfraser_bugs, Assigned: sfraser_bugs)

Details

FileImpl doesn't seem to be optimized for read-only files; it allocates an mOutputbuffer, even if the file is opened in PR_RDONLY mode. But a larger problem is that it calls Flush(), which calls PR_Sync, even if the file is read-only. This will cause a lot more disk-rattling than is necessary.
Summary: PR_Sync is called when you close a read-only file → [Perf] PR_Sync is called when you close a read-only file
Here's a diff for the flush fix: Index: nsIFileStream.cpp =================================================================== RCS file: /cvsroot/mozilla/xpcom/io/nsIFileStream.cpp,v retrieving revision 3.26 diff -r3.26 nsIFileStream.cpp 388c388,389 < Flush(); --- > if (mNSPRMode & PR_RDONLY) > Flush();
Since we can't tell in the ctor whether the FileImp will be used in read or write mode, I suggest we allocate the buffers lazily when we know we're writing.
Sorry that diff was wrong. Try this: Index: nsIFileStream.cpp =================================================================== RCS file: /cvsroot/mozilla/xpcom/io/nsIFileStream.cpp,v retrieving revision 3.26 diff -r3.26 nsIFileStream.cpp 388c388,389 < Flush(); --- > if ((mNSPRMode & PR_RDONLY) == 0) > Flush();
finders keeper. can you check this diff in?
Assignee: dougt → sfraser
Status: NEW → ASSIGNED
Fix in hand.
Target Milestone: M11
since Simon has fix in hand, setting to M11
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Fixed was checked in way back when.
*** Bug 209650 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.