Created attachment 131989[details]
Performance test
In Mac, HTMLElement.innerText in Chromium/V8 is 3~ times slower than HTMLElement.innerText in AppleWebKit/JavaScriptCore. We should optimize it.
The results of the attached performance test in my local Mac environemnt are as follows:
- Chromium/V8: 10250.8 ms
- AppleWebKit/JavaScriptCore: 3075.4 ms

Comment on attachment 132038[details]
Patch
View in context: https://bugs.webkit.org/attachment.cgi?id=132038&action=review
Whoa, this is an awesome patch. For a second there, I was excited that you were speeding up the setters. But even speeding up the getters so much is kick-ass!
> Source/WebCore/editing/TextIterator.cpp:2515
> +#if PLATFORM(CHROMIUM)
Why CHROMIUM? That is way too wide and completely mysterious. Can we narrow down the specific bit that's required?

(In reply to comment #7)
> > Source/WebCore/editing/TextIterator.cpp:2515
> > +#if PLATFORM(CHROMIUM)
>
> Why CHROMIUM? That is way too wide and completely mysterious. Can we narrow down the specific bit that's required?
(In reply to comment #8)
> (In reply to comment #7)
> This issue may depend on the fact that Chromium/Mac doesn't use tcmalloc. So I think we can narrow it down to Mac.
Fixed it.
Another thing I tried is to remove plainTextToMallocAllocatedBuffer() and replace the logic with StringBuilder. While it cleaned up the code, it degraded performance by 10%.
Consequently, I just changed the initial buffer size if "PLATFORM(CHROMIUM) && PLATFORM(MAC)".

(In reply to comment #14)
> Why was this even made a platform ifdef at all? Is there any platform where 1 << 15 is worse than 1 << 16?
- As far as I experimented locally, 1<<15 is better than 1<<16 in Chromium/Mac. 1<<15 and 1<<16 are the same in AppleWebKit/Mac and Chromium/Linux (their performance "gap" exists at between 1<<17 and 1<<18).
- According to anttik (who wrote 1<<16 a long time ago), there was no strong reason for 1<<16.
- The reason why I changed 1<<16 to 1<<15 on Chromium/Mac only is that it seems the value highly depends on malloc systems and I was afraid that changing to 1<<15 _might_ cause performance regression in some platform.
But as you pointed, I think 1<<15 would not be worse than 1<<16 in all platforms. I'll change it to 1<<15 in a following patch.