WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
107371
Pre-allocate our CompatHTMLToken Vector since we know how big it will be the the common case
https://bugs.webkit.org/show_bug.cgi?id=107371
Summary
Pre-allocate our CompatHTMLToken Vector since we know how big it will be the ...
Eric Seidel (no email)
Reported
2013-01-19 03:39:50 PST
Pre-allocate our CompatHTMLToken Vector since we know how big it will be the the common case
Attachments
Patch
(1.68 KB, patch)
2013-01-19 03:41 PST
,
Eric Seidel (no email)
abarth
: review-
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Eric Seidel (no email)
Comment 1
2013-01-19 03:41:16 PST
Created
attachment 183617
[details]
Patch
Eric Seidel (no email)
Comment 2
2013-01-19 03:41:48 PST
The real wins will come from making HTMLCompactToken smaller. Then we'll be allocating much less memory each time.
Adam Barth
Comment 3
2013-01-19 11:12:47 PST
Comment on
attachment 183617
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=183617&action=review
> Source/WebCore/ChangeLog:10 > + We know the maximum size of this buffer, so pre-allocate it to that size > + for a small savings. This shows us spending slightly less time in malloc, > + but doesn't seem noticable on the final runtime (at least not outside the error bars).
I looked at this patch and didn't see much if any change in the benchmark. On other workloads (say those with many scripts), it's not clear to me whether reserving this much space is actually a good thing. If we're only sending off a hundred tokens in a chunk, then reserving space for 4k seems wasteful in terms of memory. Before making this change, I'd like to either see some data showing its a win or be convinced that it's never a loss.
Eric Seidel (no email)
Comment 4
2013-03-05 04:22:36 PST
I guess we could re-explore this change now that we have fancy telemetry to help us.
Eric Seidel (no email)
Comment 5
2013-03-07 16:32:58 PST
Allocs from our current lazy-strategy currently account for about 1% of total time: Running Time Self Symbol Name 51.2ms 5.7% 51.2 WTF::fastMalloc(unsigned long) 8.7ms 0.9% 0.0 WTF::Vector<WebCore::CompactHTMLToken::Attribute, 0ul>::Vector(WTF::Vector<WebCore::CompactHTMLToken::Attribute, 0ul> const&) 5.8ms 0.6% 0.0 WTF::VectorMover<false, WebCore::CompactHTMLToken>::move(WebCore::CompactHTMLToken const*, WebCore::CompactHTMLToken const*, WebCore::CompactHTMLToken*) 5.8ms 0.6% 0.0 WTF::Vector<WebCore::CompactHTMLToken, 0ul>::reserveCapacity(unsigned long) 5.8ms 0.6% 0.0 void WTF::Vector<WebCore::CompactHTMLToken, 0ul>::appendSlowCase<WebCore::CompactHTMLToken>(WebCore::CompactHTMLToken const&) 5.8ms 0.6% 0.0 WebCore::BackgroundHTMLParser::pumpTokenizer()
Eric Seidel (no email)
Comment 6
2013-03-07 16:34:46 PST
Related: abarth suggests that we at least set: static const size_t pendingTokenLimit = 1000; to align with one of the Vector pre-allocation sizes. This is the vector algorithm: reserveCapacity(std::max(newMinCapacity, std::max(static_cast<size_t>(16), capacity() + capacity() / 4 + 1)));
Eric Seidel (no email)
Comment 7
2013-03-07 16:40:52 PST
Actually this is worse than I thought. We have an extra 2.5% of total time spent copying CompactHTMLTokens around these growing vectors: Running Time Self Symbol Name 22.6ms 2.5% 0.0 WTF::Vector<WebCore::CompactHTMLToken, 0ul>::reserveCapacity(unsigned long) 22.6ms 2.5% 0.0 void WTF::Vector<WebCore::CompactHTMLToken, 0ul>::appendSlowCase<WebCore::CompactHTMLToken>(WebCore::CompactHTMLToken const&) 22.6ms 2.5% 0.0 WebCore::BackgroundHTMLParser::pumpTokenizer()
Eric Seidel (no email)
Comment 8
2013-03-09 14:02:35 PST
Assuming I'm understanding the vector growth curve correctly, I'm not sure it's the one we want:
https://docs.google.com/spreadsheet/ccc?key=0AlC4tS7Ao1fIdE1xa1pRc3Y3R2FRMGJoeGw2ZWk0dVE#gid=0
Anne van Kesteren
Comment 9
2023-12-25 10:05:28 PST
Threaded HTML parser was removed.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug