Closed
Bug 707308
Opened 13 years ago
Closed 12 years ago
Support dynamic stack labels for profile
Categories
(Core :: Gecko Profiler, defect)
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.
Assignee | ||
Updated•13 years ago
|
Assignee | ||
Updated•13 years ago
|
Component: General → Gecko Profiler
QA Contact: general → gecko-profiler
Assignee | ||
Comment 1•12 years ago
|
||
Assignee | ||
Comment 2•12 years ago
|
||
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
Assignee | ||
Comment 3•12 years ago
|
||
Attachment #634122 -
Attachment is obsolete: true
Attachment #634298 -
Attachment is obsolete: true
Attachment #634448 -
Flags: review?(ehsan)
Assignee | ||
Comment 4•12 years ago
|
||
Attachment #634451 -
Flags: feedback?(ehsan)
Assignee | ||
Comment 5•12 years ago
|
||
Example:
file:///Users/bgirard/ben/sps/cleopatra/index.html?report=AMIfv97liONaWJ92kkACmY6SAW_PmAYsAy-kifO-4AmTWBXeyRbtrA9OVYzg8ND9r5fOJcN7sjk9tLjUIga3hSLP4TTXYahYBcs9umdN-9M1p9f_-DHw0EduYg6_-sjisyJavzsrN3I2URCBc3A1_W4oGngVApzwLA
Comment 6•12 years ago
|
||
avoid gotos, and hard coded array sizes. also avoid incrementing variables on one line,and decrementing them on the next!
Comment 7•12 years ago
|
||
please use default arguments.
Comment 8•12 years ago
|
||
r+ with comments in the bug and over lunch.
Updated•12 years ago
|
Attachment #634451 -
Flags: feedback?(ehsan) → feedback+
Updated•12 years ago
|
Attachment #634448 -
Flags: review?(ehsan) → review+
Assignee | ||
Comment 9•12 years ago
|
||
Jeff asked to review this.
Attachment #634448 -
Attachment is obsolete: true
Attachment #634539 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 10•12 years ago
|
||
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)
Assignee | ||
Comment 11•12 years ago
|
||
Attachment #634571 -
Flags: review?(joshmoz)
Comment 12•12 years ago
|
||
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 13•12 years ago
|
||
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+
Reporter | ||
Updated•12 years ago
|
Attachment #634557 -
Flags: review?(jmuizelaar) → review+
Reporter | ||
Comment 14•12 years ago
|
||
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-
Reporter | ||
Comment 15•12 years ago
|
||
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.
Assignee | ||
Comment 16•12 years ago
|
||
(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.
Assignee | ||
Comment 17•12 years ago
|
||
Attachment #634539 -
Attachment is obsolete: true
Attachment #635065 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 18•12 years ago
|
||
Fixed a verbal review comment. (resp->responsiveness)
Carrying forward r+
Attachment #634557 -
Attachment is obsolete: true
Attachment #635114 -
Flags: review+
Assignee | ||
Comment 19•12 years ago
|
||
This was missing a change
Attachment #635065 -
Attachment is obsolete: true
Attachment #635065 -
Flags: review?(jmuizelaar)
Attachment #635115 -
Flags: review?(jmuizelaar)
Assignee | ||
Comment 20•12 years ago
|
||
(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?
Comment 21•12 years ago
|
||
(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)
Reporter | ||
Comment 22•12 years ago
|
||
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+
Assignee | ||
Comment 23•12 years ago
|
||
Carry forward r=jrmuizel
Attachment #635115 -
Attachment is obsolete: true
Attachment #636879 -
Flags: review+
Assignee | ||
Comment 24•12 years ago
|
||
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+
Assignee | ||
Comment 25•12 years ago
|
||
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]
Comment 26•12 years ago
|
||
Assignee | ||
Comment 27•12 years ago
|
||
Comment 28•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
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.
Description
•