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

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: Remove trace event Created 4 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/PtrUtil.h" 38 #include "wtf/PtrUtil.h"
37 #include "wtf/text/TextPosition.h" 39 #include "wtf/text/TextPosition.h"
38 #include <memory> 40 #include <memory>
39 41
40 namespace blink { 42 namespace blink {
41 43
42 // On a network with high latency and high bandwidth, using a device 44 // On a network with high latency and high bandwidth, using a device
43 // with a fast CPU, we could end up speculatively tokenizing 45 // with a fast CPU, we could end up speculatively tokenizing
44 // the whole document, well ahead of when the main-thread actually needs it. 46 // the whole document, well ahead of when the main-thread actually needs it.
45 // This is a waste of memory (and potentially time if the speculation fails). 47 // This is a waste of memory (and potentially time if the speculation fails).
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 { 284 {
283 if (m_pendingTokens->isEmpty()) 285 if (m_pendingTokens->isEmpty())
284 return; 286 return;
285 287
286 #if ENABLE(ASSERT) 288 #if ENABLE(ASSERT)
287 checkThatTokensAreSafeToSendToAnotherThread(m_pendingTokens.get()); 289 checkThatTokensAreSafeToSendToAnotherThread(m_pendingTokens.get());
288 checkThatPreloadsAreSafeToSendToAnotherThread(m_pendingPreloads); 290 checkThatPreloadsAreSafeToSendToAnotherThread(m_pendingPreloads);
289 checkThatXSSInfosAreSafeToSendToAnotherThread(m_pendingXSSInfos); 291 checkThatXSSInfosAreSafeToSendToAnotherThread(m_pendingXSSInfos);
290 #endif 292 #endif
291 293
294 double chunkStartTime = monotonicallyIncreasingTimeMS();
292 std::unique_ptr<HTMLDocumentParser::ParsedChunk> chunk = wrapUnique(new HTML DocumentParser::ParsedChunk); 295 std::unique_ptr<HTMLDocumentParser::ParsedChunk> chunk = wrapUnique(new HTML DocumentParser::ParsedChunk);
293 TRACE_EVENT_WITH_FLOW0("blink,loading", "BackgroundHTMLParser::sendTokensToM ainThread", chunk.get(), TRACE_EVENT_FLAG_FLOW_OUT); 296 TRACE_EVENT_WITH_FLOW0("blink,loading", "BackgroundHTMLParser::sendTokensToM ainThread", chunk.get(), TRACE_EVENT_FLAG_FLOW_OUT);
297
294 chunk->preloads.swap(m_pendingPreloads); 298 chunk->preloads.swap(m_pendingPreloads);
295 if (m_viewportDescription.set) 299 if (m_viewportDescription.set)
296 chunk->viewport = m_viewportDescription; 300 chunk->viewport = m_viewportDescription;
297 chunk->xssInfos.swap(m_pendingXSSInfos); 301 chunk->xssInfos.swap(m_pendingXSSInfos);
298 chunk->tokenizerState = m_tokenizer->getState(); 302 chunk->tokenizerState = m_tokenizer->getState();
299 chunk->treeBuilderState = m_treeBuilderSimulator.state(); 303 chunk->treeBuilderState = m_treeBuilderSimulator.state();
300 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); 304 chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size());
301 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); 305 chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint();
302 chunk->tokens = std::move(m_pendingTokens); 306 chunk->tokens = std::move(m_pendingTokens);
303 chunk->startingScript = m_startingScript; 307 chunk->startingScript = m_startingScript;
304 chunk->likelyDocumentWriteScriptIndices.swap(m_likelyDocumentWriteScriptIndi ces); 308 chunk->likelyDocumentWriteScriptIndices.swap(m_likelyDocumentWriteScriptIndi ces);
305 m_startingScript = false; 309 m_startingScript = false;
306 310
307 bool isEmpty = m_parsedChunkQueue->enqueue(std::move(chunk)); 311 bool isEmpty = m_parsedChunkQueue->enqueue(std::move(chunk));
312
313 DEFINE_STATIC_LOCAL(CustomCountHistogram, chunkEnqueueTime, ("Parser.ChunkEn queueTime", 1, 10000, 50));
314 chunkEnqueueTime.count(monotonicallyIncreasingTimeMS() - chunkStartTime);
315
308 if (isEmpty) { 316 if (isEmpty) {
309 m_loadingTaskRunner->postTask( 317 m_loadingTaskRunner->postTask(
310 BLINK_FROM_HERE, 318 BLINK_FROM_HERE,
311 threadSafeBind(&HTMLDocumentParser::notifyPendingParsedChunks, m_par ser)); 319 threadSafeBind(&HTMLDocumentParser::notifyPendingParsedChunks, m_par ser));
312 } 320 }
313 321
314 m_pendingTokens = wrapUnique(new CompactHTMLTokenStream); 322 m_pendingTokens = wrapUnique(new CompactHTMLTokenStream);
315 } 323 }
316 324
317 } // namespace blink 325 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698