Commit 3188edc1 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Add a web test for V8 code cache for module scripts

The newly added test and its expected.txt are mostly the same
as its classic version of same-origin-test.js, except for:
- notStreamedReason (it's always "module script"),
- tracing event name (v8.compileModule), and
- Set type=module.

Bug: 841466
Change-Id: Id64fdbb91ffd406a002c3e907065720e475d157b
Reviewed-on: https://chromium-review.googlesource.com/c/1475071
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#633816}
parent dc956b25
...@@ -88,14 +88,11 @@ crbug.com/450493 http/tests/devtools/csp/ [ Slow ] ...@@ -88,14 +88,11 @@ crbug.com/450493 http/tests/devtools/csp/ [ Slow ]
crbug.com/450493 http/tests/devtools/profiler/ [ Slow ] crbug.com/450493 http/tests/devtools/profiler/ [ Slow ]
crbug.com/420008 http/tests/devtools/tracing/ [ Slow ] crbug.com/420008 http/tests/devtools/tracing/ [ Slow ]
crbug.com/420008 virtual/threaded/http/tests/devtools/tracing/ [ Slow ] crbug.com/420008 virtual/threaded/http/tests/devtools/tracing/ [ Slow ]
crbug.com/902685 http/tests/devtools/isolated-code-cache/same-origin-test.js [ Slow ] crbug.com/902685 http/tests/devtools/isolated-code-cache/ [ Slow ]
crbug.com/902685 http/tests/devtools/isolated-code-cache/cross-origin-test.js [ Slow ] crbug.com/902685 virtual/site-isolated-code-cache/http/tests/devtools/isolated-code-cache/ [ Slow ]
crbug.com/902685 virtual/not-site-per-process/http/tests/devtools/isolated-code-cache/ [ Slow ]
crbug.com/902685 http/tests/devtools/wasm-isolated-code-cache/wasm-cache-test.js [ Slow ] crbug.com/902685 http/tests/devtools/wasm-isolated-code-cache/wasm-cache-test.js [ Slow ]
crbug.com/902685 virtual/site-isolated-code-cache/http/tests/devtools/isolated-code-cache/same-origin-test.js [ Slow ]
crbug.com/902685 virtual/site-isolated-code-cache/http/tests/devtools/isolated-code-cache/cross-origin-test.js [ Slow ]
crbug.com/902685 virtual/wasm-site-isolated-code-cache/http/tests/devtools/wasm-isolated-code-cache/wasm-cache-test.js [ Slow ] crbug.com/902685 virtual/wasm-site-isolated-code-cache/http/tests/devtools/wasm-isolated-code-cache/wasm-cache-test.js [ Slow ]
crbug.com/902685 virtual/not-site-per-process/http/tests/devtools/isolated-code-cache/same-origin-test.js [ Slow ]
crbug.com/902685 virtual/not-site-per-process/http/tests/devtools/isolated-code-cache/cross-origin-test.js [ Slow ]
# Misc DevTools tests that are slow # Misc DevTools tests that are slow
crbug.com/246190 [ Release ] http/tests/devtools/indexeddb/ [ Slow ] crbug.com/246190 [ Release ] http/tests/devtools/indexeddb/ [ Slow ]
......
<script type="module" src="http://localhost:8000/devtools/resources/v8-cache-script.cgi"></script>
<script type="module" src="/devtools/resources/v8-cache-script.cgi"></script>
Tests V8 code cache for javascript resources
--- Trace events related to code caches ------
v8.compileModule Properties:
{
data : {
columnNumber : 1
lineNumber : 1
notStreamedReason : "module script"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
type : "v8.compileModule"
}
Text details for v8.compileModule: v8-cache-script.cgi
v8.compileModule Properties:
{
data : {
columnNumber : 1
lineNumber : 1
notStreamedReason : "module script"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
type : "v8.compileModule"
}
Text details for v8.compileModule: v8-cache-script.cgi
v8.compileModule Properties:
{
data : {
cacheProduceOptions : "code"
columnNumber : 1
lineNumber : 1
notStreamedReason : "module script"
producedCacheSize : <number>
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
type : "v8.compileModule"
}
Text details for v8.compileModule: v8-cache-script.cgi
v8.compileModule Properties:
{
data : {
cacheConsumeOptions : "code"
cacheRejected : false
columnNumber : 1
consumedCacheSize : <number>
lineNumber : 1
notStreamedReason : "module script"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
type : "v8.compileModule"
}
Text details for v8.compileModule: v8-cache-script.cgi
v8.compileModule Properties:
{
data : {
columnNumber : 1
lineNumber : 1
notStreamedReason : "module script"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
type : "v8.compileModule"
}
Text details for v8.compileModule: v8-cache-script.cgi
v8.compileModule Properties:
{
data : {
cacheConsumeOptions : "code"
cacheRejected : false
columnNumber : 1
consumedCacheSize : <number>
lineNumber : 1
notStreamedReason : "module script"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
type : "v8.compileModule"
}
Text details for v8.compileModule: v8-cache-script.cgi
v8.compileModule Properties:
{
data : {
cacheConsumeOptions : "code"
cacheRejected : false
columnNumber : 1
consumedCacheSize : <number>
lineNumber : 1
notStreamedReason : "module script"
streamed : <boolean>
url : .../devtools/resources/v8-cache-script.cgi
}
endTime : <number>
startTime : <number>
type : "v8.compileModule"
}
Text details for v8.compileModule: v8-cache-script.cgi
-----------------------------------------------
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Tests V8 code cache for javascript resources\n`);
await TestRunner.loadModule('performance_test_runner');
await TestRunner.showPanel('timeline');
// Clear browser cache to avoid any existing entries for the fetched
// scripts in the cache.
SDK.multitargetNetworkManager.clearBrowserCache();
// There are two scripts:
// [A] http://127.0.0.1:8000/devtools/resources/v8-cache-script.cgi
// [B] http://localhost:8000/devtools/resources/v8-cache-script.cgi
// An iframe that loads [A].
// The script is executed as a parser-inserted script,
// to keep the ScriptResource on the MemoryCache.
// ScriptResources for dynamically-inserted <script>s can be
// garbage-collected and thus removed from MemoryCache after its execution.
const scope = 'resources/same-origin-module-script.html';
// An iframe that loads [B].
const scopeCrossOrigin = 'resources/cross-origin-module-script.html';
TestRunner.addResult('--- Trace events related to code caches ------');
await PerformanceTestRunner.startTimeline();
// Load [A] thrice. With the current V8 heuristics (defined
// in third_party/blink/renderer/bindings/core/v8/v8_code_cache.cc) we produce
// cache on second fetch and consume it in the third fetch. This tests these
// heuristics.
// Note that addIframe() waits for iframe's load event, which waits for the
// <script> loading.
await TestRunner.addIframe(scope);
await TestRunner.addIframe(scope);
await TestRunner.addIframe(scope);
// Load [B]. Should not use the cached code.
await TestRunner.addIframe(scopeCrossOrigin);
// Load [A] again from MemoryCache. Should use cached code.
await TestRunner.addIframe(scope);
// Clear [A] from MemoryCache. Blink evicts previous Resource when a
// new request to the same URL but with different resource type is started.
// We fetch() to the URL of [A], and thus evicts the previous ScriptResource
// of [A].
await TestRunner.evaluateInPageAsync(
`fetch('/devtools/resources/v8-cache-script.cgi')`);
// Load [A] from Disk Cache. As we cleared [A] from MemoryCache, this
// doesn't hit MemoryCache, but still hits Disk Cache.
await TestRunner.addIframe(scope);
await PerformanceTestRunner.stopTimeline();
PerformanceTestRunner.printTimelineRecordsWithDetails(
TimelineModel.TimelineModel.RecordType.CompileModule);
TestRunner.addResult('-----------------------------------------------');
TestRunner.completeTest();
})();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment