Closed Bug 411630 Opened 17 years ago Closed 17 years ago

Clean up #ifdef'ed metering & stats code, instrument property lookup

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9beta3

People

(Reporter: brendan, Assigned: brendan)

References

Details

Attachments

(1 file)

Splitting this out as a prerequisite to bug 365851. Patch shortly.

/be
Flags: blocking1.9+
OS: Mac OS X → All
Priority: -- → P1
Status: NEW → ASSIGNED
Attached patch patchSplinter Review
* Menu of -D flags for enabling instrumentation, as a commented-out CFLAGS +=
  setting for convenient testing.
* js_FindProperty and js_LookupPropertyWithFlags return indexes into the scope
  and prototype chains, respectively, to support internal instrumentation, and
  to pave the way for the return of the property cache (bug 365851)..
* jsutil.[ch] JSBasicStats struct and functions for computing mean/sigma/max
  and auto-scaling histogram.
* JS_SCOPE_DEPTH_METER instrumentation for compile- and run-time scope chain
  length instrumentation:
+ At compile time, rt->hostenvScopeDepthStats and rt->lexicalScopeDepthStats
  meter scope chains passed into the compile and evaluate APIs.
+ At runtime, rt->protoLookupDepthStats and rt->scopeSearchDepthStats track
  steps along the prototype and scope chains until the sought-after property
  is found.
* JS_ARENAMETER uses JSBasicStats now.
* Added rt->liveScopePropsPreSweep to fix the property tree stats code that
  rotted when property tree sweeping moved to after the finalization phase.
* Un-bitrotted some DEBUG_brendan code, turned some off for myself via XXX.
* Mac OS X toolchain requires initialized data shared across dynamic library
  member files, outlaws common data, so initialize extern metering vars.
* Old HASHMETER code in jshash.[ch] is now JS_HASHMETER-controlled and based
  on JSBasicStats.
* DEBUG_scopemeters macro renamed JS_DUMP_SCOPE_METERS; uses JSBasicStats now.
* Disentangle DEBUG and DUMP_SCOPE_STATS (now JS_DUMP_PROPTREE_STATS) and fix
  inconsistent thread safety for liveScopeProps (sometimes atomic-incremented,
  sometimes runtime-locked).
* Compiler-modeled maxScopeDepth will propagate via JSScript to runtime for
  capability-based, interpreter-inlined cache hit qualifier bits, to bypass
  scope and prototype chain lookup by optimizing for common monomorphic get,
  set, and call site referencing a prototype property in a well-named object
  (no shadowing or mutation in 99.9% of the cases).
Attachment #296497 - Flags: review?(igor)
The quad of proto-lookup, scope-search, hostenv and lexical scope depths from the end of a gmail + 5 or so bugzilla tabs session:


mean proto-lookup depth 0.502478, std. deviation 1.01867, max 10
        [     0]:  2876157 *******
        [     1]:  1002388 *******
        [     2]:   128915 ******
        [     3]:    53639 *****
        [     4]:    83683 *****
        [     5]:    34179 *****
        [     6]:    19197 *****
        [     7]:     7599 ****
        [     8]:      887 ***
        [     9]:      785 ***
        [    10]+      510 ***

mean scope-search depth 0.928236, std. deviation 0.333209, max 14
        [     0]:    87631 *****************
        [     1]:   900310 ********************
        [     2]:     6314 *************
        [     3]:     4453 *************
        [     4]:       22 *****
        [     5]:      101 *******
        [     6]:        5 ***
        [     7]:        0 
        [     8]:       11 ****
        [     9]:        3 **
        [    10]+       11 ****

mean hostenv scope depth 3.8604, std. deviation 2.72772, max 15
        [     0]:        0 
        [     1]:       69 *******
        [     2]:        0 
        [     3]:      156 ********
        [     4]:       45 ******
        [     5]:       17 *****
        [     6]:       24 *****
        [     7]:        5 ***
        [     8]:        1 
        [     9]:        9 ****
        [    10]+       25 *****

mean lexical scope depth 0.0219369, std. deviation 0.150569, max 3
        [     0]:     9679 **************
        [     1]:      211 ********
        [     2]:        0 
        [     3]:        2 *
        [     4]:        0 
        [     5]:        0 
        [     6]:        0 
        [     7]:        0 
        [     8]:        0 
        [     9]:        0 
        [    10]+        0 


Long scope chains are due to the XUL DOM; long proto-chains can be due to XBL. These are not necessarily doing any programmers any good. Note for Mozilla 2.

/be
(In reply to comment #1)
> * js_FindProperty and js_LookupPropertyWithFlags return indexes into the scope
>   and prototype chains, respectively, to support internal instrumentation, and
>   to pave the way for the return of the property cache (bug 365851)..

Would it be better to wait with changes to the property API signatures until the patch is ready and for internal instrumentation use a debug-only flag in JSContext? 
(In reply to comment #3)
> (In reply to comment #1)
> Would it be better to wait with changes to the property API signatures until
> the patch is ready and for internal instrumentation use a debug-only flag in
> JSContext? 

That's just making more work -- the other patch will be ready on the heels of this one, and I'd rather not redo work at this point. I don't think these changes to the two library-internal APIs will affect performance.

/be
I would like to prove that the internal API changes do not affect perf tests, too. Landing these in a separate step helps on that front too.

/be
Attachment #296497 - Flags: review?(igor) → review+
Attachment #296497 - Flags: approval1.9+
Patch is in:

js/src/Makefile.ref 3.47
js/src/js.c 3.183
js/src/jsapi.c 3.384
js/src/jsarena.c 3.36
js/src/jscntxt.h 3.181
js/src/jsemit.c 3.296
js/src/jsemit.h 3.90
js/src/jsgc.c 3.259
js/src/jshash.c 3.19
js/src/jshash.h 3.11
js/src/jsinterp.c 3.402
js/src/jsobj.c 3.413
js/src/jsobj.h 3.77
js/src/jsparse.c 3.324
js/src/jsparse.h 3.56
js/src/jsscope.c 3.76
js/src/jsscript.c 3.167
js/src/jsstr.c 3.183
js/src/jsutil.c 3.28
js/src/jsutil.h 3.15
js/src/jsxml.c 3.185

/be
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Bug 412133 filed to get this bug's # and r=igor recorded in the commit messages.

/be
Flags: in-testsuite-
Flags: in-litmus-
It is needed to fix Makefile of js3250.dll for DEBUG build.
When building with --enable-debug on cygwin + VC8, 
Creating js3250.dll fails with two unresovlved external symbol.
jsemit.obj : _js_GuardedArenaMark is not resolved
jsstr.obj : _JS_MeanAndStdDev is not resolved
I filed issue of Comment #8 as Bug 415032.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: