I noticed that the performance test indicated that insert was 10x slower than append. Then I figured out why. Unnecessary churn in the NodeList code. I have a patch that fixes it, but it could possibly slow down other things so it's not quite ready for review. I didn't make a regression test yet.
Created attachment 15985 [details] first cut at a fix
Created attachment 15986 [details] first cut at a fix (uploaded wrong the first time)
Comment on attachment 15986 [details] first cut at a fix (uploaded wrong the first time) +private: + virtual bool nodeMatches(Node*) const; private virtual? Nothing else leaps out at me as being odd, but i don't feel qualified to comment on risk or correctness :( My ad hoc benchmarking of this show Insertion time (from hixies DOM Core test) go from ~1100ms (avg. of 3 runs) to ~110ms (3 runs)
Comment on attachment 15986 [details] first cut at a fix (uploaded wrong the first time) Okay, after repeated runs (mostly cleaning my tree) i don't think this is safe, it's a huge regression for the Indexd portion of Hixies DOM Core tests
http://nontroppo.org/timer/Hixie_DOM.html The index test goes from 26ms to >1000ms
Created attachment 17443 [details] proposed fix This doesn't cause regressions in other tests. I couldn't fully understand the original patch, so I started from scratch. It's possible that I missed some additional optimization opportunities that were present there.
> Unnecessary churn in the NodeList code. In other words, the problem had nothing to do with insertion performance - it's the previous test (index) that was making us register too many NodeLists, and thus slowed down subsequent DOM mutations.
Comment on attachment 17443 [details] proposed fix r=me
Committed revision 27983.