Closed Bug 750989 Opened 13 years ago Closed 13 years ago

Pause Profiler during saving

Categories

(Core :: Gecko Profiler, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: BenWa, Assigned: BenWa)

References

Details

Attachments

(1 file, 3 obsolete files)

Currently we don't pause the profiler while saving. Pausing the profiler eliminates some race condition when the profile is being saved and written to at the same time and prevent profile saving samples from being recorded in the profile.
Attached patch patch (obsolete) — Splinter Review
Increased sampling frequency to 1 microsecond on mac. The empty profile bug occured very frequently. With this patch applied it no longer appears as well as profile saving samples were no longer recorded.
Assignee: nobody → bgirard
Status: NEW → ASSIGNED
Attachment #620165 - Flags: review?
The description you posted sounds like it belongs to a different patch. I think a better solution for this bug would be remember the current write position before reading the samples, and then only read up to this position. Then you could still profile GetProfile with the built-in profiler (by getting another profile afterwards) without disabling this patch.
The description was meant to explain how I tested the patch. There's current a race condition that can cause profile saving to fail if you grab a sample while saving. I feel like this might be a regression with some of the jank changes done to the circular buffer code but I'm not sure. In any case I feel like sampling profile saving could go either way. Either we record it or we don't. I would rather not record it since it makes the code simpler. If we care about profile saving we can use an external profiler to catch that.
Comment on attachment 620165 [details] [diff] [review] patch Also asking review from mstange since you seem to disagree with this patch.
Attachment #620165 - Flags: review?(mstange)
Attachment #620165 - Flags: review?(jmuizelaar)
Attachment #620165 - Flags: review?
Try run for 62fdf76fe945 is complete. Detailed breakdown of the results available here: https://tbpl.mozilla.org/?tree=Try&rev=62fdf76fe945 Results (out of 107 total builds): success: 79 warnings: 28 Builds (or logs if builds failed) available at: http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/b56girard@gmail.com-62fdf76fe945
Try run for 6b0d8d1b3629 is complete. Detailed breakdown of the results available here: https://tbpl.mozilla.org/?tree=Try&rev=6b0d8d1b3629 Results (out of 113 total builds): success: 85 warnings: 26 other: 2 Builds (or logs if builds failed) available at: http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/b56girard@gmail.com-6b0d8d1b3629
Comment on attachment 620165 [details] [diff] [review] patch (In reply to Benoit Girard (:BenWa) from comment #3) > The description was meant to explain how I tested the patch. Ah, I see. I didn't understand how the empty profile bug relates to pausing the profiler, but now I do. > There's current a race condition that can cause profile saving to fail if > you grab a sample while saving. I see how that can happen as soon as we sample faster than we read. Or rather, there's no way it doesn't happen if that's the case. Say w and f are 3 and we have already wrapped at least once. Then r is 4. Now we start reading at 4, but while we're stringifying the first sample, two entries are added and flushed, so w and f are now 5. After the stringification of the first entry, our local readPos is incremented to 5, compared to f, and we stop. Then our resulting profile has only one entry. Even if we cached f locally before starting to read, we'd be reading data that's already overwritten with newer data from the next round, and we don't want that. I now agree with the approach this patch takes. The only clean way of doing what I proposed is to copy the whole buffer before reading from it, but even then we'd have to pause the profiler during the copy if we want it to be consistent. But that would be too much effort.
Attachment #620165 - Flags: review?(mstange) → review+
Comment on attachment 620165 [details] [diff] [review] patch Review of attachment 620165 [details] [diff] [review]: ----------------------------------------------------------------- This seems to only fix OS X, and should include an explanation of why it's needed.
Attachment #620165 - Flags: review?(jmuizelaar) → review-
Attached patch patch v2 (obsolete) — Splinter Review
Fixed
Attachment #620165 - Attachment is obsolete: true
Attachment #624995 - Flags: review?(jmuizelaar)
Attachment #624995 - Flags: review?(jmuizelaar) → review+
Attached patch patch v3 (obsolete) — Splinter Review
fixed a few typos
Attachment #624995 - Attachment is obsolete: true
Attachment #625252 - Flags: review+
Attached patch patch v4Splinter Review
Attachment #625252 - Attachment is obsolete: true
Attachment #625749 - Flags: review+
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Depends on: 764616
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: