Closed Bug 707308 Opened 13 years ago Closed 12 years ago

Support dynamic stack labels for profile

Categories

(Core :: Gecko Profiler, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jrmuizel, Assigned: BenWa)

References

Details

Attachments

(4 files, 8 obsolete files)

4.34 KB, patch
ehsan.akhgari
: feedback+
Details | Diff | Splinter Review
1.26 KB, patch
johns
: review+
Details | Diff | Splinter Review
1.18 KB, patch
BenWa
: review+
Details | Diff | Splinter Review
16.06 KB, patch
BenWa
: review+
Details | Diff | Splinter Review
We'll want to be able to add some dynamic information like the page that we're painting or the javascript script that we're running.
Depends on: 683229
Blocks: 713227
No longer depends on: 683229
Component: General → Gecko Profiler
QA Contact: general → gecko-profiler
Blocks: 761261
Attached patch WIP (obsolete) — Splinter Review
Attached file WIP (v2) works but needs clean up (obsolete) —
right now we always copy stack entries. The tagged pointers didn't work since pointers don't always have any particular alignment.
Assignee: nobody → bgirard
Status: NEW → ASSIGNED
Attached patch Part 1: Add dynamic labels (obsolete) — Splinter Review
Attachment #634122 - Attachment is obsolete: true
Attachment #634298 - Attachment is obsolete: true
Attachment #634448 - Flags: review?(ehsan)
Attachment #634451 - Flags: feedback?(ehsan)
Example: file:///Users/bgirard/ben/sps/cleopatra/index.html?report=AMIfv97liONaWJ92kkACmY6SAW_PmAYsAy-kifO-4AmTWBXeyRbtrA9OVYzg8ND9r5fOJcN7sjk9tLjUIga3hSLP4TTXYahYBcs9umdN-9M1p9f_-DHw0EduYg6_-sjisyJavzsrN3I2URCBc3A1_W4oGngVApzwLA
avoid gotos, and hard coded array sizes. also avoid incrementing variables on one line,and decrementing them on the next!
please use default arguments.
r+ with comments in the bug and over lunch.
Attachment #634451 - Flags: feedback?(ehsan) → feedback+
Attachment #634448 - Flags: review?(ehsan) → review+
Attached patch Part 1: Add dynamic labels (v2) (obsolete) — Splinter Review
Jeff asked to review this.
Attachment #634448 - Attachment is obsolete: true
Attachment #634539 - Flags: review?(jmuizelaar)
We need to enable JSON format support and this patch should solve the last regression of the JSON format (not supporting responsiveness). I've already pushed the required changes to the Add-on and cleopatra.
Attachment #634557 - Flags: review?(jmuizelaar)
Comment on attachment 634571 [details] [diff] [review] Part 4: Annotate plugin mimetype + url during loading I'd like John Schoenick to do this review.
Attachment #634571 - Flags: review?(joshmoz) → review?(jschoenick)
Comment on attachment 634571 [details] [diff] [review] Part 4: Annotate plugin mimetype + url during loading This looks good to me -- with the caveat that the aURI = baseURI block right above that may be going away in the future (I believe it is unnecessary after bug 745030 lands), so aURI may be null (and will always be null for java, for instance)
Attachment #634571 - Flags: review?(jschoenick) → review+
Attachment #634557 - Flags: review?(jmuizelaar) → review+
Comment on attachment 634539 [details] [diff] [review] Part 1: Add dynamic labels (v2) Review of attachment 634539 [details] [diff] [review]: ----------------------------------------------------------------- ::: tools/profiler/TableTicker.cpp @@ +249,5 @@ > + const char* tagStringData = entry.mTagData; > + int readAheadPos = (readPos + 1) % mEntrySize; > + char tagBuff[SAMPLER_MAX_STRING]; > + tagBuff[0] = '\0'; > + tagBuff[SAMPLER_MAX_STRING-1] = '\0'; Why do we need to '\0' these two particular values? @@ +259,5 @@ > + while (readAheadPos != mLastFlushPos && !seenNullByte) { > + incBy++; > + ProfileEntry readAheadEntry = mEntries[readAheadPos]; > + for (size_t pos = 0; pos < sizeof(void*)/sizeof(char); pos++) { > + tagBuff[tagBuffPos] = ((char*)(&readAheadEntry.mTagData))[pos]; Can you use a union here instead of type punning? @@ +270,5 @@ > + if (!seenNullByte) > + readAheadPos = (readAheadPos + 1) % mEntrySize; > + } > + tagStringData = tagBuff; > + } Can this be a separate function? It adds a lot of bulk to this function. It would also be nice if there were some tests. As I read through it, I can't tell whether it is correct or not. @@ +599,5 @@ > + // First entry has tagName 's' (start) > + // Check for magic pointer bit 1 to indicate copy > + bool isCopyString = aStack->mStack[i].isCopyLabel(); > + const char* sampleLabel = aStack->mStack[i].mLabel; > + if (isCopyString) { You could just check isCopyLabel() directly instead of giving it a name. @@ +610,5 @@ > + for (size_t j = 0; j < strLen;) { > + // Store as many characters in the void* as the platform allows > + void* text = 0; > + for (size_t pos = 0; pos < sizeof(void*)/sizeof(char) && j+pos < strLen; pos++) { > + ((char*)&text)[pos] = sampleLabel[j+pos]; union vs type punning again. @@ +711,5 @@ > snprintf(tagBuff, 1024, "l-%#llx\n", pc); > stream << tagBuff; > + } else if (entry.mTagName == 'd') { > + void* text = 0; > + printf("d tag\n"); You probably don't want this. ::: tools/profiler/sampler.h @@ +71,5 @@ > #define SAMPLER_GET_RESPONSIVENESS() NULL > #define SAMPLER_GET_FEATURES() NULL > #define SAMPLE_LABEL(name_space, info) > +// Provide a default literal string to use if profiling is disabled > +// and a printf argument to be computed if profiling is enabled. Might be worth adding a note about stack usage. ::: tools/profiler/sps_sampler.h @@ +169,5 @@ > + _vsnprintf(buff, SAMPLER_MAX_STRING, aFormat, args); > + _snprintf(mDest, SAMPLER_MAX_STRING, "%s %s", aDefault, buff); > +#else > + vsnprintf(buff, SAMPLER_MAX_STRING, aFormat, args); > + snprintf(mDest, SAMPLER_MAX_STRING, "%s %s", aDefault, buff); The double printing here is sort of crappy, but at least it is safe and easy to read. You may want to add a comment about why you're doing it. @@ +181,5 @@ > + ~SamplerStackFramePrintfRAII() { > + mozilla_sampler_call_exit(mHandle); > + } > +private: > + char mDest[SAMPLER_MAX_STRING]; I don't really like the fact that we pay this this stack size penalty regardless of whether we're profiling or not. I have no suggestions for how to avoid that though. @@ +190,5 @@ > > +class StackEntry > +{ > +public: > + static const void* EncodeStackAddress(const void* aStackAddress, bool aCopy) { This could probably use a description of what you're doing and why it's safe. Though I suppose some of that is by the definition of mStackAddress @@ +191,5 @@ > +class StackEntry > +{ > +public: > + static const void* EncodeStackAddress(const void* aStackAddress, bool aCopy) { > + aStackAddress = (const void*)((uintptr_t)aStackAddress & ~0x1); You should also probably use c++ casts
Attachment #634539 - Flags: review?(jmuizelaar) → review-
Another thing I thought of was that it is probably a good idea to split the formatted string from the the other part of the label in the json'd data so that filtering is easier in the front end.
(In reply to Jeff Muizelaar [:jrmuizel] from comment #14) > @@ +181,5 @@ > > + ~SamplerStackFramePrintfRAII() { > > + mozilla_sampler_call_exit(mHandle); > > + } > > +private: > > + char mDest[SAMPLER_MAX_STRING]; > > I don't really like the fact that we pay this this stack size penalty > regardless of whether we're profiling or not. I have no suggestions for how > to avoid that though. > We could solve this by processing the printf at sample time. This has the benefit of eliminating the stack size penalty and the run time over head. The drawback is that we now have to guarantee that the parameters are constant throughout the scope and we need to either find a signal safe implementation of printf or roll out a custom limited variant.
Attached patch Part 1: Add dynamic labels (v3) (obsolete) — Splinter Review
Attachment #634539 - Attachment is obsolete: true
Attachment #635065 - Flags: review?(jmuizelaar)
Blocks: 766579
Fixed a verbal review comment. (resp->responsiveness) Carrying forward r+
Attachment #634557 - Attachment is obsolete: true
Attachment #635114 - Flags: review+
Attached patch Part 1: Add dynamic labels (v3) (obsolete) — Splinter Review
This was missing a change
Attachment #635065 - Attachment is obsolete: true
Attachment #635065 - Flags: review?(jmuizelaar)
Attachment #635115 - Flags: review?(jmuizelaar)
(In reply to John Schoenick [:johns] from comment #13) > Comment on attachment 634571 [details] [diff] [review] > Part 4: Annotate plugin mimetype + url during loading > > This looks good to me -- with the caveat that the aURI = baseURI block right > above that may be going away in the future (I believe it is unnecessary > after bug 745030 lands), so aURI may be null (and will always be null for > java, for instance) What's the best way to resolve that? To keep that block there, or have a null check and only annotate the plugin URI if it's not null?
(In reply to Benoit Girard (:BenWa) from comment #20) > What's the best way to resolve that? To keep that block there, or have a > null check and only annotate the plugin URI if it's not null? A comment that we intend to be logging the baseURI if aURI is null would probably be sufficient, so whoever ends up fixing up that function can preserve it (we just don't want to be assigning it into aURI as that's passed onwards to pluginHost)
Comment on attachment 635115 [details] [diff] [review] Part 1: Add dynamic labels (v3) Review of attachment 635115 [details] [diff] [review]: ----------------------------------------------------------------- ::: tools/profiler/TableTicker.cpp @@ +616,5 @@ > + size_t strLen = strlen(sampleLabel) + 1; > + for (size_t j = 0; j < strLen;) { > + // Store as many characters in the void* as the platform allows > + char text[sizeof(void*)/sizeof(char)]; > + for (size_t pos = 0; pos < sizeof(void*)/sizeof(char) && j+pos < strLen; pos++) { sizeof(char) is defined as 1 so you can remove all of them.
Attachment #635115 - Flags: review?(jmuizelaar) → review+
Attached patch Part 1: Add dynamic labels (v4) (obsolete) — Splinter Review
Carry forward r=jrmuizel
Attachment #635115 - Attachment is obsolete: true
Attachment #636879 - Flags: review+
Increase the size of dynamic labels to 512 to support big JS strings. Note: I kept the size of the RAII helper to 128.
Attachment #636879 - Attachment is obsolete: true
Attachment #636981 - Flags: review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/0e8522d513c2 Going to land the other parts once we figure how to shutdown JS properly and have Js and non Js dynamic label co-exists.
Whiteboard: [leave open]
Blocks: 785287
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [leave open]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: