Bug 57059

Summary: input field with focus makes appendChild operation ~42x slower
Product: WebKit Reporter: Igor Minar <iiminar>
Component: DOMAssignee: Emil A Eklund <eae>
Status: VERIFIED FIXED    
Severity: Major CC: abarth, commit-queue, dglazkov, eae, eric, webkit.review.bot
Priority: P2 Keywords: HasReduction
Version: 528+ (Nightly build)   
Hardware: Macintosh Intel   
OS: OS X 10.5   
Attachments:
Description Flags
reduced test case
none
Patch none

Description Igor Minar 2011-03-24 15:36:07 PDT
Attached is a reduced test case from a large application that suffers from latency issues in Chrome/WebKit due to slow dom manipulation (specifically adding child nodes via appendChild).

The issue perf issue occurs only if the input field has a focus, if the same set of dom operations are invoked via provided button, the dom manipulation is fast.

I measured the perf difference and constantly see ~42x slowdown if the input field has focus (tested with r81868).

Test instructions:
- open the test case
- note how long it took to add 1000 li elements to the list present on the page (the number is displayed)
- click on the "toggle input" button, to cause 1000 li nodes to be removed from the list
- click on the "toggle input" button again to cause 1000 li nodes to be appended to the list and note how long it took
- now do the same by typing "x" into the input field and removing it and compare the results

You can also try invoking update('x') and update('') from console with and without placing focus on the input field with focus() to see the same results.

When the same test is run in Firefox 4, placing focus on the input field makes no difference in performance of appendChild operation.

I also tried testing the issue with Safari 5.0.4, and while it's not as bad there, the slowdown is ~21x.
Comment 1 Igor Minar 2011-03-24 15:38:02 PDT
Created attachment 86848 [details]
reduced test case
Comment 2 Igor Minar 2011-03-24 15:43:55 PDT
I also filed https://bugs.webkit.org/show_bug.cgi?id=57061 which in combination with this issue kills our app in WebKit/Chrome.
Comment 3 Emil A Eklund 2011-04-15 11:36:01 PDT
Created attachment 89819 [details]
Patch
Comment 4 Dimitri Glazkov (Google) 2011-04-15 11:42:07 PDT
Comment on attachment 89819 [details]
Patch

great! Can you file a bug to put this whole deleteButtonController business behind a compile flag? Most builds of WebKit don't need it.
Comment 5 WebKit Commit Bot 2011-04-15 17:03:21 PDT
Comment on attachment 89819 [details]
Patch

Clearing flags on attachment: 89819

Committed r84056: <http://trac.webkit.org/changeset/84056>
Comment 6 WebKit Commit Bot 2011-04-15 17:03:26 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 WebKit Review Bot 2011-04-15 18:22:24 PDT
http://trac.webkit.org/changeset/84056 might have broken WinCairo Debug (Build)
Comment 8 Igor Minar 2011-04-19 23:48:03 PDT
I was able to manually verify the fix with the r84295 nightly build.

Thanks for the fix, Emil.
Comment 9 Emil A Eklund 2011-04-20 07:48:53 PDT
Cool, thanks for verifying!