Bug 111789 - HTMLTreeBuilder::ExternalCharacterTokenBuffer should not need to copy bytes in the CompactHTMLToken case
Summary: HTMLTreeBuilder::ExternalCharacterTokenBuffer should not need to copy bytes i...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 111645
  Show dependency treegraph
 
Reported: 2013-03-07 16:09 PST by Eric Seidel (no email)
Modified: 2023-04-01 00:52 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2013-03-07 16:09:49 PST
HTMLTreeBuilder::ExternalCharacterTokenBuffer should not need to copy bytes in the CompactHTMLToken case

CompactHTMLToken has already allocated a StringImpl of the right size in the common case.  We need to plumb this information through AtomicHTMLToken so that ExternalCharacterTokenBuffer can avoid copying the bytes and instead just ref the StringImpl. :)

e.g.
        m_tree.insertTextNode(buffer.takeRemaining());

profiling Parser/html-parser-threaded.html with bug 107236 applied:

Running Time	Self		Symbol Name
84.2ms    4.8%	84.2	 	WTF::fastMalloc(unsigned long)
19.6ms    1.1%	0.0	 	 WTF::StringImpl::createUninitialized(unsigned int, unsigned char*&)
17.7ms    1.0%	0.0	 	  WTF::String::make8BitFrom16BitSource(unsigned short const*, unsigned long)
8.3ms    0.4%	0.0	 	   WebCore::HTMLTreeBuilder::processCharacterBufferForInBody(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer&)

The .4% spent in HTMLTreeBuilder::processCharacterBufferForInBody are likely all unnecessary.
Comment 1 Anne van Kesteren 2023-04-01 00:52:28 PDT
It looks like we're doing this today.