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

Unified Diff: tools/android/loading/sandwich_prefetch.py

Issue 2112013003: sandwich: Use cachetool's batch mode to speed-up cache processing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@af00
Patch Set: s/Online/Batch 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/android/loading/request_track.py ('k') | tools/android/loading/sandwich_swr.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/loading/sandwich_prefetch.py
diff --git a/tools/android/loading/sandwich_prefetch.py b/tools/android/loading/sandwich_prefetch.py
index be8f6098136ac8f08da0cab25a1ef291f43d23c1..2f7f7fe321cdaf90bb827240655579ea5c7507de 100644
--- a/tools/android/loading/sandwich_prefetch.py
+++ b/tools/android/loading/sandwich_prefetch.py
@@ -116,7 +116,7 @@ def _FilterOutDataAndIncompleteRequests(requests):
if request.protocol is None:
assert not request.HasReceivedResponse()
continue
- if request.protocol == 'about':
+ if request.protocol in {'about', 'blob'}:
continue
if request.protocol not in {'http/0.9', 'http/1.0', 'http/1.1'}:
raise RuntimeError('Unknown request protocol {}'.format(request.protocol))
@@ -138,11 +138,13 @@ def _PatchCacheArchive(cache_archive_path, loading_trace_path,
archive <cache_archive_path>.
cache_archive_dest_path: Archive destination's path.
"""
+ logging.info('loading trace: %s', loading_trace_path)
trace = loading_trace.LoadingTrace.FromJsonFile(loading_trace_path)
with common_util.TemporaryDirectory(prefix='sandwich_tmp') as tmp_path:
cache_path = os.path.join(tmp_path, 'cache')
chrome_cache.UnzipDirectoryContent(cache_archive_path, cache_path)
- cache_backend = chrome_cache.CacheBackend(cache_path, 'simple')
+ cache_backend = chrome_cache.BatchCacheBackend(
+ cache_path, chrome_cache.CacheBackendType.SIMPLE)
cache_entries = set(cache_backend.ListKeys())
logging.info('Original cache size: %d bytes' % cache_backend.GetSize())
for request in _FilterOutDataAndIncompleteRequests(
@@ -156,21 +158,23 @@ def _PatchCacheArchive(cache_archive_path, loading_trace_path,
# identifier will be different.
#
# The fact that these entries are kept in the cache after closing Chrome
- # properly by closing the Chrome tab as the ChromeControler.SetSlowDeath()
- # do is known chrome bug (crbug.com/610725).
+ # properly by closing the Chrome tab as the
+ # ChromeControler.SetSlowDeath() do is known chrome bug
+ # (crbug.com/610725).
if request.url not in cache_entries:
continue
# Chrome prunes Set-Cookie from response headers before storing them in
- # disk cache. Also, it adds implicit "Vary: cookie" header to all redirect
- # response headers. Sandwich manages the cache, but between recording the
- # cache and benchmarking the cookie jar is invalidated. This leads to
- # invalidation of all cacheable redirects.
+ # disk cache. Also, it adds implicit "Vary: cookie" header to all
+ # redirect response headers. Sandwich manages the cache, but between
+ # recording the # cache and benchmarking the cookie jar is invalidated.
+ # This leads to invalidation of all cacheable redirects.
raw_headers = request.GetRawResponseHeaders()
cache_backend.UpdateRawResponseHeaders(request.url, raw_headers)
# NoState-Prefetch would only fetch the resources, but not parse them.
cache_backend.DeleteStreamForKey(request.url, 2)
- chrome_cache.ZipDirectoryContent(cache_path, cache_archive_dest_path)
+ cache_backend.ProcessBatch()
logging.info('Patched cache size: %d bytes' % cache_backend.GetSize())
+ chrome_cache.ZipDirectoryContent(cache_path, cache_archive_dest_path)
def _DiscoverRequests(dependencies_lens, subresource_discoverer):
@@ -403,8 +407,8 @@ def _ValidateCacheArchiveContent(cache_build_trace_path, cache_archive_path):
logging.info('lists cached urls from %s' % cache_archive_path)
with common_util.TemporaryDirectory() as cache_directory:
chrome_cache.UnzipDirectoryContent(cache_archive_path, cache_directory)
- cache_keys = set(
- chrome_cache.CacheBackend(cache_directory, 'simple').ListKeys())
+ cache_keys = set(chrome_cache.CacheBackend(
+ cache_directory, chrome_cache.CacheBackendType.SIMPLE).ListKeys())
trace = loading_trace.LoadingTrace.FromJsonFile(cache_build_trace_path)
effective_requests = _ListUrlRequests(trace, _RequestOutcome.All)
effective_post_requests = _ListUrlRequests(trace, _RequestOutcome.Post)
« no previous file with comments | « tools/android/loading/request_track.py ('k') | tools/android/loading/sandwich_swr.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698