Closed Bug 592001 Opened 16 years ago Closed 16 years ago

Fix v8-regexp regression in wake of patch for bug 558451

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla2.0b7

People

(Reporter: brendan, Assigned: brendan)

References

()

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(2 files, 2 obsolete files)

Attached patch proposed fix (obsolete) — — Splinter Review
We maybeHash too soon (HASH_THRESHOLD = 6), and worse, we maybeHash when adding shapes that may never be subject to property lookups. The HASH_THRESHOLD value of 6 is ancient, and I don't propose to change it for this bug. It's always more space-efficient to avoid creating a PropertyTable for a shape-path, but if script actually does lookup properties by name, one could argue it's worth the space overhead for O(1) time complexity. But as David Bacon likes to point out, O(k) where k != 1 can differ measurably from O(1), asymptote aside. Obviously if there's only one property mapped by the shape path, you don't need a double hashtable to speed up the linear search done under Shape::search. When there's time, it would be informative to measure benchmark performance with different HASH_THRESHOLD values and see where the O(n^2) compounding complexity of linear search starts to be noticeable. For now, this patch does the trick: TEST COMPARISON FROM TO DETAILS ============================================================================= ** TOTAL **: 1.067x as fast 610.9ms +/- 2.3% 572.4ms +/- 2.1% significant ============================================================================= v8: 1.067x as fast 610.9ms +/- 2.3% 572.4ms +/- 2.1% significant regexp: 1.067x as fast 610.9ms +/- 2.3% 572.4ms +/- 2.1% significant /be
Attachment #470514 - Flags: review?(jorendorff)
Blocks: 558451
Attachment #470514 - Flags: review?(jorendorff) → review?(gal)
Comment on attachment 470514 [details] [diff] [review] proposed fix The malloc counting accounting here is really lame. Time to revive the memory pressure accounting bug.
Attachment #470514 - Flags: review?(gal) → review+
http://hg.mozilla.org/tracemonkey/rev/34a07da93976 If this doesn't win back all the lost perf, I'll take a new bug. /be
Whiteboard: fixed-in-tracemonkey
Backed out: http://hg.mozilla.org/tracemonkey/rev/801ea8bd0d06 Didn't win and broke a jsreftest :-(. Taking the longer path. /be
Whiteboard: fixed-in-tracemonkey
I did some analyzing with Callgrind. The only things that really struck me were: - PropertyTable::init() is called a lot; it and its children account for almost 12% of instructions executed (many of them in malloc). - PropertyTree:sweepShapes() is called a lot; it and its children account for almost 8% of instructions executed (many of them in free). This matches cdleary's Shark result in bug 558451 comment 153. The Shape::Shape() with 7 args is called 1,727,129 times. The Shape::Shape() with 3 args is called 110,080 times. That's a lot of shapes.
(In reply to comment #4) > - PropertyTable::init() is called a lot; it and its children account for > almost 12% of instructions executed (many of them in malloc). > > - PropertyTree:sweepShapes() is called a lot; We should really change the shape allocation to the GC and make the GC to sweep them in the background. That should help.
Attached patch fix (obsolete) — — Splinter Review
The new-instance vs. proto-emptyShape class mismatch misfeature got me again. Jorendorff and I have discussed it before (it's in InitScopeForObject, which now needs a new name, post-scope-ectomy). I'll file a followup bug. This patch more than settles the score: TEST COMPARISON FROM TO DETAILS ============================================================================= ** TOTAL **: 1.83x as fast 638.6ms +/- 2.0% 349.1ms +/- 2.0% significant ============================================================================= v8: 1.83x as fast 638.6ms +/- 2.0% 349.1ms +/- 2.0% significant regexp: 1.83x as fast 638.6ms +/- 2.0% 349.1ms +/- 2.0% significant Sayrer was right, it was an "easy" fix (or a small fix, anyway -- took me too long to find, sorry). /be
Attachment #470514 - Attachment is obsolete: true
Attachment #470780 - Flags: review?(gal)
Attached patch fix — — Splinter Review
Igor kindly agreed to review. /be
Attachment #470780 - Attachment is obsolete: true
Attachment #470784 - Flags: review?(igor)
Attachment #470780 - Flags: review?(gal)
(In reply to comment #5) > (In reply to comment #4) > > - PropertyTable::init() is called a lot; it and its children account for > > almost 12% of instructions executed (many of them in malloc). > > > > - PropertyTree:sweepShapes() is called a lot; > > We should really change the shape allocation to the GC and make the GC to sweep > them in the background. That should help. That is bug 569422, on my list now. /be
igor: brendan: what about passing SlowArrayClass to js_InitClass ? brendan: igor: gal tried that, it results in missing length property, believe it or not brendan: igor: this is a minimal patch -- 7 chars if you ignore comments and asserts brendan: igor: we may retry using slow array class but that is for later igor: brendan: ok, but the patch should assert in js_InitClass something like JS_ASSERT_IF(proto->clasp != clasp, clasp == js_ArrayClass && proto->clasp == js_SlowArrayClass) with fixme pointing to the new bug. [08:41am] igor: brendan: r+ with that. /be
http://hg.mozilla.org/tracemonkey/rev/e80892986b11 Filed bug 592296 on initializing so Array.prototype is slow from the start. /be
Whiteboard: fixed-in-tracemonkey
Attachment #470784 - Flags: review?(igor) → review+
Comment on attachment 470780 [details] [diff] [review] fix Thanks for the follow-up bug.
Attachment #470780 - Flags: review+
Attached image woohoo! —
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Target Milestone: mozilla2.0b5 → mozilla2.0b6
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: