SlideShare a Scribd company logo
1 of 28
Download to read offline
Cache in Chromium 
Disk Cache & Overall cache flow
Chang W. Doh 
<hi> </hi> 
GDG Korea WebTech Organizer 
HTML5Rocks/KO Contributor/Coordinator
Before stepping into Cache: 
Network stack
Network Stack: 
What’s ‘Network Stack’? 
● A mostly single-threaded cross-platform 
library primarily for resource fetching 
○ URLRequest 
■ represents the request for a URL 
○ URLRequestContext 
■ contains all the associated contexts to fullfill 
the ‘URL request’ 
● e.g. cookies, host resolver, cache
Before stepping into Cache: 
● Some code layouts 
○ /net/base 
Network stack 
■ shared utilities for /net modules 
○ /net/disk_cache 
■ Cache for web resources 
○ /net/url_request 
■ URLRequest, URLRequestContext, ...
Typical request-flow
HttpCache Cache 
check (aka Disk Cache) 
HttpCache::Transaction 
not exist 
notify 
notify 
Cache hit!
Disk Cache: 
(a.k.a. Cache)
DiskCache: 
● Cache 
What’s DiskCache? 
○ Stores resources fetched from the web 
○ A part of ‘/net’ 
■ location: /net/disk_cache 
■ This means ‘DiskCache’ will controll cache-flows 
for network fetches. 
● NOTE: 
○ Android use ‘Simple cache’. 
■ location: /net/disk_cache/simple
DiskCache: 
● Main characteristics: 
Characteristics 
○ The cache should not grow unbounded 
■ Algorithm to decide when removing old entries 
○ Not critical to loose some data 
■ But discarding whole cache should be minimized 
○ Access should be possible to use sync or 
async operations 
○ Design should avoid ‘cache trashing’
DiskCache: 
● Main characteristics: 
Characteristics 
○ Should be possible to remove a entry from 
the cache 
■ and keep working with that entry while same time inaccessible to other requests 
○ Shouldn’t be using explicit multithread sync 
■ Always called from the same thread 
■ However, callbacks must be issued by message 
loop for avoiding reentrancy
DiskCache: 
External interfaces 
● /net/disk_cache/disk_cache.h 
● 2 Interfaces 
○ disk_cache::Backend 
■ manages entries on the cache 
○ disk_cache::Entry 
■ handles operations specific to a given resource
External interfaces: 
● An entry is identified by its key 
○ e.g. http://www.google.com/favicon.ico 
● Once an entry is created, the data is stored in 
separate chunks or data streams: 
○ HTTP headers 
○ Actual resource data 
● Index for the required stream is an argument to 
methods: 
○ Entry::ReadData 
○ Entry::WriteData 
Backend
Very Simple Cache 
(a.k.a. Simple Cache)
Simple cache: 
What is “Simple Cache”? 
● Proposed to a new backend for diskcache 
○ Conforming to the interface in Disk Cache 
○ Very simple 
■ Using 1 file per cache entry + index file 
■ Dealing with I/O bottlenecks
Comparison to 
Blockfile Backend 
?
Simple cache: 
Benefits and goals 
● Comparison to blockfile cache 
○ More resilent under corruption from the 
system crash 
■ Periodcally flushes its entire index 
■ Swaps index in atomically 
■ After system crash, will starts with the stale 
cache 
● NOTE: With the blockfile cache, chrome will drops 
whole cache by default
Simple cache: 
Benefits and goals 
● Comparison to blockfile cache (cont’d) 
○ Doesn’t delay launching network requests 
■ Elimination of delay factors 
● No context switching 
● Not blocks disk I/O before using network 
■ Blockfile has (AVR) 14~25ms delay on requests 
● On Android, slower flash controllers make delays significantly slower.
Simple cache: 
Benefits and goals 
● Comparison to blockfile cache (cont’d) 
○ Lower resident set pressure & fewer IO ops. 
■ Disk format has 
● 256~512B per entry records 
● + rankings & index information(~100B) per entry 
● Not all entries that are heavily used contiguously 
■ Simple cache 
● stores only SMALLNUM bytes per entry in memory 
● doesn’t access the disk where not required
Simple cache: 
Benefits and goals 
● Comparison to blockfile cache (cont’d) 
○ Simpler 
■ Shorter and easier via explicitly avoiding 
implementation of filesystem than blockfile’s
Simple cache: 
Non-goals; Simple cache is 
● Not a log structed cache system 
○ I/O performs by Simple cache is mostly 
sequential. But NOT log structed 
■ If it is, it means “filesystem that itself is log 
structed.” 
● Not a filesystem 
○ Disk cache delegates filesystem. 
■ means “Simple cache uses abstract interface 
of Disk Cache instead implementing its own 
filesystem”.
Simple cache: 
● Entry hash 
Structure on Disk 
○ Hash with 40 bit SHA-2 of url 
○ 2 entries with same EH can’t be stored 
● Stored in single directory 
○ ONE index file 
○ Each entry stored in a single file 
■ named by HexEntryHash_StreamNumber
Simple cache: 
● A file ‘00index’ 
Structure on Disk 
○ contains data for initializing memory index 
● Index (on memory) 
○ used for faster cache performance 
○ consists of entry hashes for records & simple 
eviction information
Simple cache: 
Structure on Disk 
● Formats of entry file 
○ Simple file header 
magic_number version key_length key_hash 
○ Simple file EOF 
final_magic_number flags data_crc32 stream_size 
○ Simple File sparse range header 
sparse_magic_number offset length data_crc32
Term: 
Sparse file
Simple cache: 
Implementation 
● I/O thread operations 
○ public API is called on the I/O thread 
○ The index is updated in the I/O thread 
● Worker pool operations 
○ All I/O operations are performed async on 
the worker pool. 
○ Cache will keep a pool of new entries ready 
to move into final place.
Simple cache: 
Implementation 
● Index flushing & consistency checking 
○ The index is flushed on 
■ shutdown 
■ periodically 
● Operation without index 
○ can operate without the IO thread index by 
directly opening files in the directory. 
○ for avoiding startup speeds & I/O costs
References 
[1] Disk Cache 
[2] Disk Cache 3.0 
[3] Very Simple Cache 
[4] Multi-process Resource Loading 
[5] Network Stack 
[6] Network Stack Use in Chromium

More Related Content

Similar to Chromium Cache Flow and Disk Cache Architecture

Dfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshopDfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshopTamas K Lengyel
 
Introduction to containers
Introduction to containersIntroduction to containers
Introduction to containersNitish Jadia
 
Initial presentation of swift (for montreal user group)
Initial presentation of swift (for montreal user group)Initial presentation of swift (for montreal user group)
Initial presentation of swift (for montreal user group)Marcos García
 
Mongo nyc nyt + mongodb
Mongo nyc nyt + mongodbMongo nyc nyt + mongodb
Mongo nyc nyt + mongodbDeep Kapadia
 
Socket programming, and openresty
Socket programming, and openrestySocket programming, and openresty
Socket programming, and openrestyTavish Naruka
 
Building a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
Building a Unified Logging Layer with Fluentd, Elasticsearch and KibanaBuilding a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
Building a Unified Logging Layer with Fluentd, Elasticsearch and KibanaMushfekur Rahman
 
Linux Stammtisch Munich: Ceph - Overview, Experiences and Outlook
Linux Stammtisch Munich: Ceph - Overview, Experiences and OutlookLinux Stammtisch Munich: Ceph - Overview, Experiences and Outlook
Linux Stammtisch Munich: Ceph - Overview, Experiences and OutlookDanny Al-Gaaf
 
Storing your data in the cloud: doing right reversim 2018
Storing your data in the cloud: doing right reversim 2018Storing your data in the cloud: doing right reversim 2018
Storing your data in the cloud: doing right reversim 2018Orit Wasserman
 
The Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization OpportunitiesThe Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization OpportunitiesDatabricks
 
LAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to EmbeddedLAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to EmbeddedLinaro
 
Toolchain Independent Distributed Compilation
Toolchain Independent Distributed CompilationToolchain Independent Distributed Compilation
Toolchain Independent Distributed CompilationDietmar Hauser
 
Logs @ OVHcloud
Logs @ OVHcloudLogs @ OVHcloud
Logs @ OVHcloudOVHcloud
 
Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersSeravo
 
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, VectorizedData Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, VectorizedHostedbyConfluent
 
Boosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringBoosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringShapeBlue
 
Introduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataIntroduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataJihoon Son
 

Similar to Chromium Cache Flow and Disk Cache Architecture (20)

Caching
CachingCaching
Caching
 
Discoblocks.pptx.pdf
Discoblocks.pptx.pdfDiscoblocks.pptx.pdf
Discoblocks.pptx.pdf
 
Dfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshopDfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshop
 
Introduction to containers
Introduction to containersIntroduction to containers
Introduction to containers
 
Initial presentation of swift (for montreal user group)
Initial presentation of swift (for montreal user group)Initial presentation of swift (for montreal user group)
Initial presentation of swift (for montreal user group)
 
Mongo nyc nyt + mongodb
Mongo nyc nyt + mongodbMongo nyc nyt + mongodb
Mongo nyc nyt + mongodb
 
Socket programming, and openresty
Socket programming, and openrestySocket programming, and openresty
Socket programming, and openresty
 
Building a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
Building a Unified Logging Layer with Fluentd, Elasticsearch and KibanaBuilding a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
Building a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
 
Linux Stammtisch Munich: Ceph - Overview, Experiences and Outlook
Linux Stammtisch Munich: Ceph - Overview, Experiences and OutlookLinux Stammtisch Munich: Ceph - Overview, Experiences and Outlook
Linux Stammtisch Munich: Ceph - Overview, Experiences and Outlook
 
Storing your data in the cloud: doing right reversim 2018
Storing your data in the cloud: doing right reversim 2018Storing your data in the cloud: doing right reversim 2018
Storing your data in the cloud: doing right reversim 2018
 
Mongodb meetup
Mongodb meetupMongodb meetup
Mongodb meetup
 
The Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization OpportunitiesThe Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization Opportunities
 
LAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to EmbeddedLAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
 
Toolchain Independent Distributed Compilation
Toolchain Independent Distributed CompilationToolchain Independent Distributed Compilation
Toolchain Independent Distributed Compilation
 
Logs @ OVHcloud
Logs @ OVHcloudLogs @ OVHcloud
Logs @ OVHcloud
 
Scaling xtext
Scaling xtextScaling xtext
Scaling xtext
 
Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developers
 
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, VectorizedData Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
Data Policies for the Kafka-API with WebAssembly | Alexander Gallego, Vectorized
 
Boosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringBoosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uring
 
Introduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataIntroduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big Data
 

More from Chang W. Doh

Exploring what're new in Web for the Natively app
Exploring what're new in Web for the Natively appExploring what're new in Web for the Natively app
Exploring what're new in Web for the Natively appChang W. Doh
 
Kotlin의 코루틴은 어떻게 동작하는가
Kotlin의 코루틴은 어떻게 동작하는가Kotlin의 코루틴은 어떻게 동작하는가
Kotlin의 코루틴은 어떻게 동작하는가Chang W. Doh
 
Hey Kotlin, How it works?
Hey Kotlin, How it works?Hey Kotlin, How it works?
Hey Kotlin, How it works?Chang W. Doh
 
Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Chang W. Doh
 
introduction to Web Assembly
introduction to Web Assembly introduction to Web Assembly
introduction to Web Assembly Chang W. Doh
 
PWA Roadshow Seoul - Keynote
PWA Roadshow Seoul - KeynotePWA Roadshow Seoul - Keynote
PWA Roadshow Seoul - KeynoteChang W. Doh
 
PWA Roadshow Seoul - HTTPS
PWA Roadshow Seoul - HTTPSPWA Roadshow Seoul - HTTPS
PWA Roadshow Seoul - HTTPSChang W. Doh
 
CSS 다시 파서 어디에 쓰나
CSS 다시 파서 어디에 쓰나CSS 다시 파서 어디에 쓰나
CSS 다시 파서 어디에 쓰나Chang W. Doh
 
Natively Web App & Service Worker
Natively Web App & Service WorkerNatively Web App & Service Worker
Natively Web App & Service WorkerChang W. Doh
 
초보 개발자를 위한 웹 프론트엔드 개발 101
초보 개발자를 위한 웹 프론트엔드 개발 101초보 개발자를 위한 웹 프론트엔드 개발 101
초보 개발자를 위한 웹 프론트엔드 개발 101Chang W. Doh
 
Service Worker 201 (한국어)
Service Worker 201 (한국어)Service Worker 201 (한국어)
Service Worker 201 (한국어)Chang W. Doh
 
Service Worker 201 (en)
Service Worker 201 (en)Service Worker 201 (en)
Service Worker 201 (en)Chang W. Doh
 
Service Worker 101 (en)
Service Worker 101 (en)Service Worker 101 (en)
Service Worker 101 (en)Chang W. Doh
 
Service Worker 101 (한국어)
Service Worker 101 (한국어)Service Worker 101 (한국어)
Service Worker 101 (한국어)Chang W. Doh
 
What is next for the web
What is next for the webWhat is next for the web
What is next for the webChang W. Doh
 
Instant and offline apps with Service Worker
Instant and offline apps with Service WorkerInstant and offline apps with Service Worker
Instant and offline apps with Service WorkerChang W. Doh
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015Chang W. Doh
 
프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기
프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기
프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기Chang W. Doh
 
Polymer Codelab: Before diving into polymer
Polymer Codelab: Before diving into polymerPolymer Codelab: Before diving into polymer
Polymer Codelab: Before diving into polymerChang W. Doh
 
알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web Animations알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web AnimationsChang W. Doh
 

More from Chang W. Doh (20)

Exploring what're new in Web for the Natively app
Exploring what're new in Web for the Natively appExploring what're new in Web for the Natively app
Exploring what're new in Web for the Natively app
 
Kotlin의 코루틴은 어떻게 동작하는가
Kotlin의 코루틴은 어떻게 동작하는가Kotlin의 코루틴은 어떻게 동작하는가
Kotlin의 코루틴은 어떻게 동작하는가
 
Hey Kotlin, How it works?
Hey Kotlin, How it works?Hey Kotlin, How it works?
Hey Kotlin, How it works?
 
Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요
 
introduction to Web Assembly
introduction to Web Assembly introduction to Web Assembly
introduction to Web Assembly
 
PWA Roadshow Seoul - Keynote
PWA Roadshow Seoul - KeynotePWA Roadshow Seoul - Keynote
PWA Roadshow Seoul - Keynote
 
PWA Roadshow Seoul - HTTPS
PWA Roadshow Seoul - HTTPSPWA Roadshow Seoul - HTTPS
PWA Roadshow Seoul - HTTPS
 
CSS 다시 파서 어디에 쓰나
CSS 다시 파서 어디에 쓰나CSS 다시 파서 어디에 쓰나
CSS 다시 파서 어디에 쓰나
 
Natively Web App & Service Worker
Natively Web App & Service WorkerNatively Web App & Service Worker
Natively Web App & Service Worker
 
초보 개발자를 위한 웹 프론트엔드 개발 101
초보 개발자를 위한 웹 프론트엔드 개발 101초보 개발자를 위한 웹 프론트엔드 개발 101
초보 개발자를 위한 웹 프론트엔드 개발 101
 
Service Worker 201 (한국어)
Service Worker 201 (한국어)Service Worker 201 (한국어)
Service Worker 201 (한국어)
 
Service Worker 201 (en)
Service Worker 201 (en)Service Worker 201 (en)
Service Worker 201 (en)
 
Service Worker 101 (en)
Service Worker 101 (en)Service Worker 101 (en)
Service Worker 101 (en)
 
Service Worker 101 (한국어)
Service Worker 101 (한국어)Service Worker 101 (한국어)
Service Worker 101 (한국어)
 
What is next for the web
What is next for the webWhat is next for the web
What is next for the web
 
Instant and offline apps with Service Worker
Instant and offline apps with Service WorkerInstant and offline apps with Service Worker
Instant and offline apps with Service Worker
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
 
프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기
프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기
프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기
 
Polymer Codelab: Before diving into polymer
Polymer Codelab: Before diving into polymerPolymer Codelab: Before diving into polymer
Polymer Codelab: Before diving into polymer
 
알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web Animations알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web Animations
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Chromium Cache Flow and Disk Cache Architecture

  • 1. Cache in Chromium Disk Cache & Overall cache flow
  • 2. Chang W. Doh <hi> </hi> GDG Korea WebTech Organizer HTML5Rocks/KO Contributor/Coordinator
  • 3. Before stepping into Cache: Network stack
  • 4. Network Stack: What’s ‘Network Stack’? ● A mostly single-threaded cross-platform library primarily for resource fetching ○ URLRequest ■ represents the request for a URL ○ URLRequestContext ■ contains all the associated contexts to fullfill the ‘URL request’ ● e.g. cookies, host resolver, cache
  • 5. Before stepping into Cache: ● Some code layouts ○ /net/base Network stack ■ shared utilities for /net modules ○ /net/disk_cache ■ Cache for web resources ○ /net/url_request ■ URLRequest, URLRequestContext, ...
  • 7. HttpCache Cache check (aka Disk Cache) HttpCache::Transaction not exist notify notify Cache hit!
  • 9. DiskCache: ● Cache What’s DiskCache? ○ Stores resources fetched from the web ○ A part of ‘/net’ ■ location: /net/disk_cache ■ This means ‘DiskCache’ will controll cache-flows for network fetches. ● NOTE: ○ Android use ‘Simple cache’. ■ location: /net/disk_cache/simple
  • 10. DiskCache: ● Main characteristics: Characteristics ○ The cache should not grow unbounded ■ Algorithm to decide when removing old entries ○ Not critical to loose some data ■ But discarding whole cache should be minimized ○ Access should be possible to use sync or async operations ○ Design should avoid ‘cache trashing’
  • 11. DiskCache: ● Main characteristics: Characteristics ○ Should be possible to remove a entry from the cache ■ and keep working with that entry while same time inaccessible to other requests ○ Shouldn’t be using explicit multithread sync ■ Always called from the same thread ■ However, callbacks must be issued by message loop for avoiding reentrancy
  • 12. DiskCache: External interfaces ● /net/disk_cache/disk_cache.h ● 2 Interfaces ○ disk_cache::Backend ■ manages entries on the cache ○ disk_cache::Entry ■ handles operations specific to a given resource
  • 13. External interfaces: ● An entry is identified by its key ○ e.g. http://www.google.com/favicon.ico ● Once an entry is created, the data is stored in separate chunks or data streams: ○ HTTP headers ○ Actual resource data ● Index for the required stream is an argument to methods: ○ Entry::ReadData ○ Entry::WriteData Backend
  • 14. Very Simple Cache (a.k.a. Simple Cache)
  • 15. Simple cache: What is “Simple Cache”? ● Proposed to a new backend for diskcache ○ Conforming to the interface in Disk Cache ○ Very simple ■ Using 1 file per cache entry + index file ■ Dealing with I/O bottlenecks
  • 17. Simple cache: Benefits and goals ● Comparison to blockfile cache ○ More resilent under corruption from the system crash ■ Periodcally flushes its entire index ■ Swaps index in atomically ■ After system crash, will starts with the stale cache ● NOTE: With the blockfile cache, chrome will drops whole cache by default
  • 18. Simple cache: Benefits and goals ● Comparison to blockfile cache (cont’d) ○ Doesn’t delay launching network requests ■ Elimination of delay factors ● No context switching ● Not blocks disk I/O before using network ■ Blockfile has (AVR) 14~25ms delay on requests ● On Android, slower flash controllers make delays significantly slower.
  • 19. Simple cache: Benefits and goals ● Comparison to blockfile cache (cont’d) ○ Lower resident set pressure & fewer IO ops. ■ Disk format has ● 256~512B per entry records ● + rankings & index information(~100B) per entry ● Not all entries that are heavily used contiguously ■ Simple cache ● stores only SMALLNUM bytes per entry in memory ● doesn’t access the disk where not required
  • 20. Simple cache: Benefits and goals ● Comparison to blockfile cache (cont’d) ○ Simpler ■ Shorter and easier via explicitly avoiding implementation of filesystem than blockfile’s
  • 21. Simple cache: Non-goals; Simple cache is ● Not a log structed cache system ○ I/O performs by Simple cache is mostly sequential. But NOT log structed ■ If it is, it means “filesystem that itself is log structed.” ● Not a filesystem ○ Disk cache delegates filesystem. ■ means “Simple cache uses abstract interface of Disk Cache instead implementing its own filesystem”.
  • 22. Simple cache: ● Entry hash Structure on Disk ○ Hash with 40 bit SHA-2 of url ○ 2 entries with same EH can’t be stored ● Stored in single directory ○ ONE index file ○ Each entry stored in a single file ■ named by HexEntryHash_StreamNumber
  • 23. Simple cache: ● A file ‘00index’ Structure on Disk ○ contains data for initializing memory index ● Index (on memory) ○ used for faster cache performance ○ consists of entry hashes for records & simple eviction information
  • 24. Simple cache: Structure on Disk ● Formats of entry file ○ Simple file header magic_number version key_length key_hash ○ Simple file EOF final_magic_number flags data_crc32 stream_size ○ Simple File sparse range header sparse_magic_number offset length data_crc32
  • 26. Simple cache: Implementation ● I/O thread operations ○ public API is called on the I/O thread ○ The index is updated in the I/O thread ● Worker pool operations ○ All I/O operations are performed async on the worker pool. ○ Cache will keep a pool of new entries ready to move into final place.
  • 27. Simple cache: Implementation ● Index flushing & consistency checking ○ The index is flushed on ■ shutdown ■ periodically ● Operation without index ○ can operate without the IO thread index by directly opening files in the directory. ○ for avoiding startup speeds & I/O costs
  • 28. References [1] Disk Cache [2] Disk Cache 3.0 [3] Very Simple Cache [4] Multi-process Resource Loading [5] Network Stack [6] Network Stack Use in Chromium