Summary: | Web Inspector: Avoid slice-ing listeners array in WI.Object.prototype.dispatchEventToListeners | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Alexander Pavlov (apavlov) <apavlov> | ||||
Component: | Web Inspector | Assignee: | Nobody <webkit-unassigned> | ||||
Status: | RESOLVED WONTFIX | ||||||
Severity: | Normal | CC: | apavlov, bburg, bweinstein, graouts, joepeck, keishi, loislo, oliver, pfeldman, pmuellr, rik, timothy, vsevik, webkit-bug-importer, yurys | ||||
Priority: | P2 | Keywords: | InRadar | ||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | All | ||||||
OS: | All | ||||||
Attachments: |
|
Description
Alexander Pavlov (apavlov)
2012-09-11 03:44:12 PDT
Created attachment 163325 [details]
Patch
Comment on attachment 163325 [details]
Patch
This will probably regress scenarios when we have more listeners.
(In reply to comment #2) > (From update of attachment 163325 [details]) > This will probably regress scenarios when we have more listeners. We may add a check for a threshold if this optimization has a noticeable effect. If you think performance is critical here - do copy-on-write. I.e. iterate over original and put it into the iterating-over Set. If upon addEventListener your list is in Set - clone it. Finally we put has() method into our Map and make Set implementation possible. (In reply to comment #4) > If you think performance is critical here - do copy-on-write. I.e. iterate over original and put it into the iterating-over Set. If upon addEventListener your list is in Set - clone it. Finally we put has() method into our Map and make Set implementation possible. This was actually all about one element listeners array case. Apparently putting something into the set makes things even slower in this case. Special-casing one element case might help but I don't think that we currently have a scenario where this whole issue is a problem. the linked jsperf shows manual copy about 75% faster than for-loop. Why can't we optimize Array.prototype.slice() instead? I'm not convinced this is a big perf issue right now, since jsperf is probably not representative of how WI code will be optimized. We replaced this code recently. |