Closed Bug 553682 Opened 14 years ago Closed 14 years ago

TM: GC Profiler

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a4

People

(Reporter: gwagner, Assigned: gwagner)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(8 files, 9 obsolete files)

8.52 KB, image/png
Details
10.46 KB, image/png
Details
8.75 KB, image/png
Details
7.00 KB, image/png
Details
935 bytes, patch
Details | Diff | Splinter Review
10.78 KB, patch
Details | Diff | Splinter Review
2.28 KB, patch
Details | Diff | Splinter Review
2.55 KB, patch
gwagner
: review+
Details | Diff | Splinter Review
Attached patch GCTimer (obsolete) — Splinter Review
I used this patch to profile the js_GC function and count how many chunks are allocated and destroyed between GC calls. The results are written to a file and can be visualized with gnuplot.
Attachment #433619 - Attachment is patch: true
Attachment #433619 - Attachment mime type: application/octet-stream → text/plain
Attached file gnuplot file (obsolete) —
and the gnuplot file to generate the graph.
You have to change the input filename in order to use it.
Attached image sample output
Sample output
Assignee: general → anygregor
Gregor,

Can you update the patch to include #ifdef so we can conditionally enabled this on trunk builds?

Mike M
I captured a random surf behavior: Opened a lot of tabs and visited random webpages. 
The graph shows again the two different webpage styles:
1) transition based with long living objects
2) recreation based with lots of short living objects.

Marking time dominates in 1) and sweeping time in 2).
Attached image Facebook
Example for transition based webpage: Facebook.
Marking time kills here.
Attached image 280 slides
example for recreation based webpage: 280 slides.
Sweeping time matters.
Gregor, this work is fantastic.
Huzzah^2, and props for using dear old gnuplot (don't make Andreas program it ;-).

/be
Attached patch new version (obsolete) — Splinter Review
It covers now everything with the GCTIMER option.
Attachment #433619 - Attachment is obsolete: true
Gregor, Can you land the GCTIMER patch on the TIP?
(In reply to comment #10)
> Gregor, Can you land the GCTIMER patch on the TIP?

I still have problems with rdtsc on different platforms. It's defined in avmplus.h but it seems that not all platforms include this header.
Attached patch patch (obsolete) — Splinter Review
added compiler flag
Attachment #433663 - Attachment is obsolete: true
Attachment #434105 - Flags: review?(igor)
Attached patch patch update (obsolete) — Splinter Review
refresh
Attachment #434105 - Attachment is obsolete: true
Attachment #434105 - Flags: review?(igor)
Attached patch patch update (obsolete) — Splinter Review
and now the right version.
Attachment #434636 - Attachment is obsolete: true
Attachment #434637 - Flags: review?(igor)
Attachment #434637 - Flags: review?(igor)
Comment on attachment 434637 [details] [diff] [review]
patch update

>diff -r f909e6aacc87 js/src/jsgc.cpp
>--- a/js/src/jsgc.cpp	Tue Mar 23 21:23:40 2010 -0700
>+++ b/js/src/jsgc.cpp	Wed Mar 24 13:07:46 2010 -0700
>@@ -562,21 +562,28 @@ MakeNewArenaFreeList(JSGCArena *a, size_
> #else
> # define METER(x)               ((void) 0)
> # define METER_IF(condition, x) ((void) 0)
> #endif
> 
> #define METER_UPDATE_MAX(maxLval, rval)                                       \
>     METER_IF((maxLval) < (rval), (maxLval) = (rval))
> 
>+#ifdef MOZ_GCTIMER
>+static int newChunkCount = 0;
>+static int destroyChunkCount = 0;

Use jsrefcount for the type here and JS_ATOMIC_INCREMENT to increase the counter.

>+#ifdef MOZ_GCTIMER
>+typedef struct GCTimer {

Nit: no need for typedef.

>+static uint64 firstEnter = 0;

Nit: use more descriptive name here. Something like firstGCStart. Alternatively move the static into js_GC and pass it into dumpGCTimer.

>+
>+void dumpGCTimer(GCTimer *gcT, bool lastGC)
>+{
>+    static FILE *gcFile;
>+
>+    if (!gcFile) {
>+        gcFile = fopen("gcTimer.dat", "w");
>+        JS_ASSERT(gcFile);

I suggest to always open file in the dump function and append the data using the "a" mode. This way the data file would not be overwritten if one starts browser again. 

>+#define TIMESTAMP(x) x = rdtsc();
>+#else
>+#define TIMESTAMP(x)
>+#endif

Nit: move the define into js_GC to emphasis its locality. Also use ((void) 0) for the empty timestamp and wrap the definition of the first one into parenthesis. 

>@@ -3199,16 +3263,17 @@ js_GC(JSContext *cx, JSGCInvocationKind 

>     FinalizeArenaList<JSString, FinalizeString>
>         (cx, FINALIZE_STRING, &emptyArenas);

It would be nice to add a separated counter for the string finalization timing.

Assume r+ with that fixed.
(In reply to comment #15)
> >+
> >+void dumpGCTimer(GCTimer *gcT, bool lastGC)
> >+{
> >+    static FILE *gcFile;
> >+
> >+    if (!gcFile) {
> >+        gcFile = fopen("gcTimer.dat", "w");
> >+        JS_ASSERT(gcFile);
> 
> I suggest to always open file in the dump function and append the data using
> the "a" mode. This way the data file would not be overwritten if one starts
> browser again. 
> 

I don't like if the file just grows and I have to manually delete it or copy some parts for plotting. I want to leave it like that if there is no other reason.

> 
> >@@ -3199,16 +3263,17 @@ js_GC(JSContext *cx, JSGCInvocationKind 
> 
> >     FinalizeArenaList<JSString, FinalizeString>
> >         (cx, FINALIZE_STRING, &emptyArenas);
> 
> It would be nice to add a separated counter for the string finalization timing.

Added

> 
> Assume r+ with that fixed.

Thx!
Attached patch patch (obsolete) — Splinter Review
Addressed Igors comments.
Attachment #434637 - Attachment is obsolete: true
Attached patch patch (obsolete) — Splinter Review
fix output
Attachment #434973 - Attachment is obsolete: true
Attached patch patch: gnuplot script (obsolete) — Splinter Review
I added another folder for it. utils->gcTimer
Other script files don't have the copyright header so I didn't add one.
Attachment #433620 - Attachment is obsolete: true
Attachment #434999 - Flags: review?(gal)
Comment on attachment 434999 [details] [diff] [review]
patch: gnuplot script

Looks good. Please get consensus from #jsapi on the directory name.
Attachment #434999 - Flags: review?(gal) → review+
moved to js/src/gnuplot
Attachment #434999 - Attachment is obsolete: true
Attachment #434988 - Attachment is obsolete: true
Whiteboard: fixed-in-tracemonkey
To make sure that the timestamping code does not rot the patch enables it (but not the stats printout) in debug builds unconditionally.
Attachment #435289 - Flags: review?(anygregor)
(In reply to comment #25)
> Created an attachment (id=435289) [details]
> enable timestamping in debug builds
> 
> To make sure that the timestamping code does not rot the patch enables it (but
> not the stats printout) in debug builds unconditionally.

I wanted to do the same but I always got a compile error with rdtsc on Maemo on try-server. I asked dmandelin because he uses it for traceviz and he said that rdtsc might not be implemented on Maemo.
(In reply to comment #26)
> try-server. I asked dmandelin because he uses it for traceviz and he said that
> rdtsc might not be implemented on Maemo.

Then we should only enable it if rdtsc is available.
I filed bug 555338 to get a preprocessor define that tells when rdtsc is available.
Here is an updated patch that checks for rdtsc availability using AVMPLUS_HAS_RDTSC from the bug 555338.

On a releated note I have found that it would be very useful to expose the timing stats for shell scripts. This way a performance benchmark can run a test repetitively and process the statistics on its own.
Attachment #435666 - Flags: review?(anygregor)
(In reply to comment #29)
> On a releated note I have found that it would be very useful to expose the
> timing stats for shell scripts. This way a performance benchmark can run a test
> repetitively and process the statistics on its own.

Gregor, what do you think about this?
Comment on attachment 435666 [details] [diff] [review]
enable timestamping in debug builds v2


>+
>+#if !AVMPLUS_HAS_RDTSC
>+#error "MOZ_GCTIMER can only be enabled if the rdtsc() is available."
>+#endif
>+

nit: "if rdtsc() is available" or "if the rdtsc() instruction is available" sounds better to me.
Attachment #435666 - Flags: review?(anygregor) → review+
> On a releated note I have found that it would be very useful to expose the
> timing stats for shell scripts. This way a performance benchmark can run a test
> repetitively and process the statistics on its own.

You mean like the sunspider comparison? 
Yeah the timing output was just the first step and we should really use these numbers.
I also want to use the relative application time that is already in the output file and do some GC frequency graphs.
Target Milestone: --- → mozilla1.9.3a4
http://hg.mozilla.org/mozilla-central/rev/f896af789657
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Attachment #435289 - Flags: review?(anygregor)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: