Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp

Issue 2078723002: Add HTML parser UMA for rewinds and chunk queue statistics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "core/html/parser/BackgroundHTMLParser.h" 26 #include "core/html/parser/BackgroundHTMLParser.h"
27 27
28 #include "core/HTMLNames.h" 28 #include "core/HTMLNames.h"
29 #include "core/html/parser/HTMLDocumentParser.h" 29 #include "core/html/parser/HTMLDocumentParser.h"
30 #include "core/html/parser/TextResourceDecoder.h" 30 #include "core/html/parser/TextResourceDecoder.h"
31 #include "core/html/parser/XSSAuditor.h" 31 #include "core/html/parser/XSSAuditor.h"
32 #include "platform/Histogram.h"
32 #include "platform/ThreadSafeFunctional.h" 33 #include "platform/ThreadSafeFunctional.h"
33 #include "platform/TraceEvent.h" 34 #include "platform/TraceEvent.h"
34 #include "public/platform/Platform.h" 35 #include "public/platform/Platform.h"
35 #include "public/platform/WebTaskRunner.h" 36 #include "public/platform/WebTaskRunner.h"
37 #include "wtf/CurrentTime.h"
36 #include "wtf/text/TextPosition.h" 38 #include "wtf/text/TextPosition.h"
37 39
38 namespace blink { 40 namespace blink {
39 41
40 // On a network with high latency and high bandwidth, using a device 42 // On a network with high latency and high bandwidth, using a device
41 // with a fast CPU, we could end up speculatively tokenizing 43 // with a fast CPU, we could end up speculatively tokenizing
42 // the whole document, well ahead of when the main-thread actually needs it. 44 // the whole document, well ahead of when the main-thread actually needs it.
43 // This is a waste of memory (and potentially time if the speculation fails). 45 // This is a waste of memory (and potentially time if the speculation fails).
44 // So we limit our outstanding tokens arbitrarily to 10,000. 46 // So we limit our outstanding tokens arbitrarily to 10,000.
45 // Our maximal memory spent speculating will be approximately: 47 // Our maximal memory spent speculating will be approximately:
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 void BackgroundHTMLParser::sendTokensToMainThread() 281 void BackgroundHTMLParser::sendTokensToMainThread()
280 { 282 {
281 if (m_pendingTokens->isEmpty()) 283 if (m_pendingTokens->isEmpty())
282 return; 284 return;
283 285
284 #if ENABLE(ASSERT) 286 #if ENABLE(ASSERT)
285 checkThatTokensAreSafeToSendToAnotherThread(m_pendingTokens.get()); 287 checkThatTokensAreSafeToSendToAnotherThread(m_pendingTokens.get());
286 checkThatPreloadsAreSafeToSendToAnotherThread(m_pendingPreloads); 288 checkThatPreloadsAreSafeToSendToAnotherThread(m_pendingPreloads);
287 checkThatXSSInfosAreSafeToSendToAnotherThread(m_pendingXSSInfos); 289 checkThatXSSInfosAreSafeToSendToAnotherThread(m_pendingXSSInfos);
288 #endif 290 #endif
289 291 double chunkStartTime = monotonicallyIncreasingTimeMS();
290 OwnPtr<HTMLDocumentParser::ParsedChunk> chunk = adoptPtr(new HTMLDocumentPar ser::ParsedChunk); 292 OwnPtr<HTMLDocumentParser::ParsedChunk> chunk = adoptPtr(new HTMLDocumentPar ser::ParsedChunk);
291 TRACE_EVENT_WITH_FLOW0("blink,loading", "BackgroundHTMLParser::sendTokensToM ainThread", chunk.get(), TRACE_EVENT_FLAG_FLOW_OUT); 293 TRACE_EVENT_WITH_FLOW0("blink,loading", "BackgroundHTMLParser::sendTokensToM ainThread", chunk.get(), TRACE_EVENT_FLAG_FLOW_OUT);
294
292 chunk->preloads.swap(m_pendingPreloads); 295 chunk->preloads.swap(m_pendingPreloads);
293 if (m_viewportDescription.set) 296 if (m_viewportDescription.set)
294 chunk->viewport = m_viewportDescription; 297 chunk->viewport = m_viewportDescription;
295 chunk->xssInfos.swap(m_pendingXSSInfos); 298 chunk->xssInfos.swap(m_pendingXSSInfos);
296 chunk->tokenizerState = m_tokenizer->getState(); 299 chunk->tokenizerState = m_tokenizer->getState();
297 chunk->treeBuilderState = m_treeBuilderSimulator.state(); 300 chunk->treeBuilderState = m_treeBuilderSimulator.state();
298 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); 301 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size());
299 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); 302 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint();
300 chunk->tokens = std::move(m_pendingTokens); 303 chunk->tokens = std::move(m_pendingTokens);
301 chunk->startingScript = m_startingScript; 304 chunk->startingScript = m_startingScript;
302 chunk->likelyDocumentWriteScriptIndices.swap(m_likelyDocumentWriteScriptIndi ces); 305 chunk->likelyDocumentWriteScriptIndices.swap(m_likelyDocumentWriteScriptIndi ces);
303 m_startingScript = false; 306 m_startingScript = false;
304 307
305 bool isEmpty = m_parsedChunkQueue->enqueue(std::move(chunk)); 308 bool isEmpty = m_parsedChunkQueue->enqueue(std::move(chunk));
309
310 DEFINE_STATIC_LOCAL(CustomCountHistogram, chunkEnqueueTime, ("Parser.ChunkEn queueTime", 1, 10000, 50));
311 chunkEnqueueTime.count(monotonicallyIncreasingTimeMS() - chunkStartTime);
312
306 if (isEmpty) { 313 if (isEmpty) {
307 m_loadingTaskRunner->postTask( 314 m_loadingTaskRunner->postTask(
308 BLINK_FROM_HERE, 315 BLINK_FROM_HERE,
309 threadSafeBind(&HTMLDocumentParser::notifyPendingParsedChunks, m_par ser)); 316 threadSafeBind(&HTMLDocumentParser::notifyPendingParsedChunks, m_par ser));
310 } 317 }
311 318
312 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); 319 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream);
313 } 320 }
314 321
315 } // namespace blink 322 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698