SlideShare a Scribd company logo
1 of 17
Download to read offline
0Virtual Gerrit User Summit 2020 – On-line GerritForge.com 0
Gerrit 3.3 – pluggable cache
Luca Milanesio
Gerrit Code Review Maintainer
GerritForge
1Virtual Gerrit User Summit 2020 – On-line GerritForge.com 1
About GerritForge
Founded in
the UK
HQ in London with
presence in Europe and
the USA (GerritForge Inc.)
Committed to
OpenSource
and to Gerrit
Code Review
since 2009
2Virtual Gerrit User Summit 2020 – On-line GerritForge.com 2
Gerrit caches: the problem
Gerrit <= v2.16: ReviewDB + indexes
• Low latency for reading review data
• Ability to join across tables (changes, patch_sets, messages, …)
• DB auto-vacuuming
3Virtual Gerrit User Summit 2020 – On-line GerritForge.com 3
Gerrit caches: the problem
Gerrit >= v2.16: NoteDb + Lucene indexes
• Low latency for reading index data: change details?
• Change data is all de-normalized on NoteDb: huge JSON payload
• No auto-vacuuming: frequent JGit needed
4Virtual Gerrit User Summit 2020 – On-line GerritForge.com 4
Gerrit caches: the problem
Gerrit guava caches to the rescue
• Increase in number of Gerrit caches
• Increase in use of caches for NoteDb, where possible
• Migration to a Java Caffeine cache backend: much faster
5Virtual Gerrit User Summit 2020 – On-line GerritForge.com 5
Gerrit caches: the problem
What about Gerrit restarts?
• In-memory caches are empty
• High pressure on JGit and repository access at startup
• Higher costs in terms of NFS data utilization (e.g. AWS’s EFS)
6Virtual Gerrit User Summit 2020 – On-line GerritForge.com 6
Gerrit caches: the problem
GerritHub.io enables persistent NoteDb cache
commit 83008efeaf9c987b3bfe2a8da23f21c73ccc620a
Author: David Ostrovsky <david.ostrovsky@gmail.com>
Date: Tue Sep 24 20:28:43 2019 +0000
Enable change_notes persistent cache
Change-Id: I5f875bc2b630bf8b25843d29e946995cc6d221ab
diff --git a/etc/gerrit.config b/etc/gerrit.config
index 330ba45..d88bd89 100644
--- a/etc/gerrit.config
+++ b/etc/gerrit.config
@@ -149,6 +149,9 @@
+[cache "change_notes"]
+ memoryLimit = 32768
+ diskLimit = 1g
7Virtual Gerrit User Summit 2020 – On-line GerritForge.com 7
Gerrit caches: the problem
GerritHub.io experiences outages in some sites
commit 87c332644c0442c33227750e0d29381798577d55
Author: Luca Milanesio <luca.milanesio@gmail.com>
Date: Sat Oct 26 20:03:06 2019 +0000
Revert "Enable change_notes persistent cache"
This reverts commit 83008efeaf9c987b3bfe2a8da23f21c73ccc620a.
Reason for revert: Blocks the JVM during the huge H2 defragmentation
Change-Id: Ib42a425dbc13bafc219e0625d7ce999f2e8afc2b
8Virtual Gerrit User Summit 2020 – On-line GerritForge.com 8
Gerrit caches: the problem
GerritHub.io: H2-based persistent GitHub caches
(https://bugs.chromium.org/p/gerrit/issues/detail?id=10276)
Not so easy to reproduce: the problem is not when GitHub denies access straight away but rather when it is
stuck for minutes, and that creates a series of deadlocks in the H2 cache.
GitHub groups are already cached in the github-plugin and the cache is persisted also. However, H2 locking
isn't great and when you have multiple concurrent requests for different groups to be loaded from GitHub, the
APIs are stuck (because of whatever happens on their side) Gerrit gets stuck for a *very long time* because
the H2 table is huge.
9Virtual Gerrit User Summit 2020 – On-line GerritForge.com 9
H2 background: fragmentation + compaction
H2 is a RDBMS: vacuum & compaction
(http://www.h2database.com/html/features.html#compacting)
Empty space in the database file re-used automatically. When
closing the database, the database is automatically compacted for
up to 200 milliseconds by default.
The problem:
JVM threads accessing cache locked for > 200 ms
10Virtual Gerrit User Summit 2020 – On-line GerritForge.com 10
H2 background: locking
H2 is a RDBMS: needs locking on read/writes
(http://www.h2database.com/html/advanced.html)
If a connection wants to write to a table (update or delete a row), an
exclusive lock is required. To get the exclusive lock, other
connection must not have any locks on the object.
The problem:
Concurrent writes to the same cache are locking each other
11Virtual Gerrit User Summit 2020 – On-line GerritForge.com 11
Gerrit solution: pluggable persistent cache
Gerrit v2.14 allows non-H2 implementations
(https://gerrit-review.googlesource.com/c/gerrit/+/176973)
Introduce CacheImpl annotation
There is existing mechanism to provide different implementation for
instance to secure-store but one can replace only certain binding
with it (through provider class). In this case when H2CacheImpl is
installed it adds more bindings and replacing only this class would
keep leftovers being still initiated/running in Gerrit core.
CacheImpl annotation contains 2 types:
MEMORY
PERSISTENT
It is applied to modules that provide corresponding default caches
implementations.
When CacheImpl annotation is added to lib module then it will
override particular default implementation.
Change-Id: I7562b210fad4c5f6dc67887f627cf76815a378cb
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
12Virtual Gerrit User Summit 2020 – On-line GerritForge.com 12
Gerrit solution: pluggable persistent cache
Gerrit v3.3 allows to use it in production
(https://gerrit-review.googlesource.com/c/gerrit/+/284195)
Owner:Marcin Czech
Use persistent cache provided by libModule for offline reindex
Gerrit offline reindexing ignores persistent cache implementation
provided as libModule and always generates caches using H2
implementation. This fix allows to use a different persistent cache
backend.
Using different cache implementation during the offline reindexing
and at runtime causes situation when Gerrit starts without any
precomputed caches which significantly impacts overall performance.
On the other hand offline reindexing cannot reuse existing caches
which impacts reindexing performance.
Bug: Issue 13464
Change-Id: I36305282e8ea583dfb37f629e41d219762c3b4a3
13Virtual Gerrit User Summit 2020 – On-line GerritForge.com 13
First NoSQL implementation: ChronicleMap
First production-ready libModule for Gerrit cache
(https://gerrit.googlesource.com/modules/cache-chroniclemap/)
• Based on Open-Source ChronicleMap high-speed persistent cache
(https://github.com/OpenHFT/Chronicle-Map)
• Designed for low-latency
• Never blocks, read or write operations
• Static file allocation: no need to vacuum or compaction
14Virtual Gerrit User Summit 2020 – On-line GerritForge.com 14
First NoSQL implementation: ChronicleMap
DEMO
15Virtual Gerrit User Summit 2020 – On-line GerritForge.com 15
Q&A: excited about the future of Gerrit?
Image from: http://cypp.rutgers.edu/ru-voting/political-information/public-opinion-polls/
16Virtual Gerrit User Summit 2020 – On-line GerritForge.com 16
Wants to know more?
GerritForge.com/contact

More Related Content

What's hot

Preventing Supply Chain Attacks on Open Source Software
Preventing Supply Chain Attacks on Open Source SoftwarePreventing Supply Chain Attacks on Open Source Software
Preventing Supply Chain Attacks on Open Source Software
All Things Open
 

What's hot (20)

stackconf 2021 | GitOps: yea or nay?
stackconf 2021 | GitOps: yea or nay?stackconf 2021 | GitOps: yea or nay?
stackconf 2021 | GitOps: yea or nay?
 
Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...
Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...
Control Plane: Continuous Kubernetes Security (DevSecOps - London Gathering, ...
 
Managing Docker containers
Managing Docker containersManaging Docker containers
Managing Docker containers
 
Grails 4: Upgrade your Game!
Grails 4: Upgrade your Game!Grails 4: Upgrade your Game!
Grails 4: Upgrade your Game!
 
Continuous Security for GitOps
Continuous Security for GitOpsContinuous Security for GitOps
Continuous Security for GitOps
 
Your own full blown Gerrit plugin
Your own full blown Gerrit pluginYour own full blown Gerrit plugin
Your own full blown Gerrit plugin
 
Go for Operations
Go for OperationsGo for Operations
Go for Operations
 
Kubernetes - security you need to know about it
Kubernetes - security you need to know about itKubernetes - security you need to know about it
Kubernetes - security you need to know about it
 
Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!
Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!
Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!
 
JSS build and deployment
JSS build and deploymentJSS build and deployment
JSS build and deployment
 
What’s new in grails framework 5?
What’s new in grails framework 5?What’s new in grails framework 5?
What’s new in grails framework 5?
 
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
 
LinuxKit and Moby, News from DockerCon 2017
LinuxKit and Moby, News from DockerCon 2017LinuxKit and Moby, News from DockerCon 2017
LinuxKit and Moby, News from DockerCon 2017
 
Writing Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future SelfWriting Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future Self
 
Infinite gerrit
Infinite gerritInfinite gerrit
Infinite gerrit
 
Help , My Datacenter is on fire
Help , My Datacenter is on fireHelp , My Datacenter is on fire
Help , My Datacenter is on fire
 
Preventing Supply Chain Attacks on Open Source Software
Preventing Supply Chain Attacks on Open Source SoftwarePreventing Supply Chain Attacks on Open Source Software
Preventing Supply Chain Attacks on Open Source Software
 
stackconf 2021 | Embracing change: Policy-as-code for Kubernetes with OPA and...
stackconf 2021 | Embracing change: Policy-as-code for Kubernetes with OPA and...stackconf 2021 | Embracing change: Policy-as-code for Kubernetes with OPA and...
stackconf 2021 | Embracing change: Policy-as-code for Kubernetes with OPA and...
 
London Java Community: Spring Cloud -> Docker -> Kubernetes
London Java Community: Spring Cloud -> Docker -> KubernetesLondon Java Community: Spring Cloud -> Docker -> Kubernetes
London Java Community: Spring Cloud -> Docker -> Kubernetes
 
Control Plane: Security Rationale for Istio (DevSecOps - London Gathering, Ja...
Control Plane: Security Rationale for Istio (DevSecOps - London Gathering, Ja...Control Plane: Security Rationale for Istio (DevSecOps - London Gathering, Ja...
Control Plane: Security Rationale for Istio (DevSecOps - London Gathering, Ja...
 

Similar to ChronicleMap non-blocking cache for Gerrit v3.3

Git Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdfGit Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdf
uzair
 
Rc094 010d-git 2 - desconocido
Rc094 010d-git 2 - desconocidoRc094 010d-git 2 - desconocido
Rc094 010d-git 2 - desconocido
Luis Bertel
 
Conflicting Advice on Git Usage Patterns & Their Implications
Conflicting Advice on Git Usage Patterns & Their ImplicationsConflicting Advice on Git Usage Patterns & Their Implications
Conflicting Advice on Git Usage Patterns & Their Implications
YoungSeok Yoon
 

Similar to ChronicleMap non-blocking cache for Gerrit v3.3 (20)

Gerrit Code Review v3.2 and v3.3
Gerrit Code Review v3.2 and v3.3Gerrit Code Review v3.2 and v3.3
Gerrit Code Review v3.2 and v3.3
 
Web 3.12: A browser to make us proud (GUADEC 2014)
Web 3.12: A browser to make us proud (GUADEC 2014)Web 3.12: A browser to make us proud (GUADEC 2014)
Web 3.12: A browser to make us proud (GUADEC 2014)
 
Git Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdfGit Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdf
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
 
Gitops Hands On
Gitops Hands OnGitops Hands On
Gitops Hands On
 
Git version control
Git version controlGit version control
Git version control
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing self
 
Git Basics
Git BasicsGit Basics
Git Basics
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administration
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
 
Gerrit linuxtag2011
Gerrit linuxtag2011Gerrit linuxtag2011
Gerrit linuxtag2011
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Rc094 010d-git 2 - desconocido
Rc094 010d-git 2 - desconocidoRc094 010d-git 2 - desconocido
Rc094 010d-git 2 - desconocido
 
Git for developers
Git for developersGit for developers
Git for developers
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and Github
 
Conflicting Advice on Git Usage Patterns & Their Implications
Conflicting Advice on Git Usage Patterns & Their ImplicationsConflicting Advice on Git Usage Patterns & Their Implications
Conflicting Advice on Git Usage Patterns & Their Implications
 
Lessons from Contributing to WebKit and Blink
Lessons from Contributing to WebKit and BlinkLessons from Contributing to WebKit and Blink
Lessons from Contributing to WebKit and Blink
 
Git for work groups ironhack talk
Git for work groups ironhack talkGit for work groups ironhack talk
Git for work groups ironhack talk
 
Git 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizationsGit 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizations
 

More from Luca Milanesio

More from Luca Milanesio (20)

What's new in Gerrit Code Review v3.1 and beyond
What's new in Gerrit Code Review v3.1 and beyondWhat's new in Gerrit Code Review v3.1 and beyond
What's new in Gerrit Code Review v3.1 and beyond
 
Gerrit Analytics applied to Android source code
Gerrit Analytics applied to Android source codeGerrit Analytics applied to Android source code
Gerrit Analytics applied to Android source code
 
Cloud-native Gerrit Code Review
Cloud-native Gerrit Code ReviewCloud-native Gerrit Code Review
Cloud-native Gerrit Code Review
 
Gerrit Code Review migrations step-by-step
Gerrit Code Review migrations step-by-stepGerrit Code Review migrations step-by-step
Gerrit Code Review migrations step-by-step
 
Gerrit Code Review multi-site
Gerrit Code Review multi-siteGerrit Code Review multi-site
Gerrit Code Review multi-site
 
What's new in Gerrit Code Review 3.0
What's new in Gerrit Code Review 3.0What's new in Gerrit Code Review 3.0
What's new in Gerrit Code Review 3.0
 
Gerrit User Summit 2019 Keynote
Gerrit User Summit 2019 KeynoteGerrit User Summit 2019 Keynote
Gerrit User Summit 2019 Keynote
 
Gerrit multi-master / multi-site at GerritHub
Gerrit multi-master / multi-site at GerritHubGerrit multi-master / multi-site at GerritHub
Gerrit multi-master / multi-site at GerritHub
 
GerritHub a true Gerrit migration story to v2.15
GerritHub a true Gerrit migration story to v2.15GerritHub a true Gerrit migration story to v2.15
GerritHub a true Gerrit migration story to v2.15
 
Gerrit User Summit 2018 - Keynote
Gerrit User Summit 2018 - Keynote Gerrit User Summit 2018 - Keynote
Gerrit User Summit 2018 - Keynote
 
Jenkins plugin for Gerrit Code Review pipelines
Jenkins plugin for Gerrit Code Review pipelinesJenkins plugin for Gerrit Code Review pipelines
Jenkins plugin for Gerrit Code Review pipelines
 
Gerrit User Summit 2017 Keynote
Gerrit User Summit 2017 KeynoteGerrit User Summit 2017 Keynote
Gerrit User Summit 2017 Keynote
 
How to keep Jenkins logs forever without performance issues
How to keep Jenkins logs forever without performance issuesHow to keep Jenkins logs forever without performance issues
How to keep Jenkins logs forever without performance issues
 
Jenkins Pipeline on your Local Box to Reduce Cycle Time
Jenkins Pipeline on your Local Box to Reduce Cycle TimeJenkins Pipeline on your Local Box to Reduce Cycle Time
Jenkins Pipeline on your Local Box to Reduce Cycle Time
 
Jenkins world 2017 - Data-Driven CI Pipeline with Gerrit Code Review
Jenkins world 2017 - Data-Driven CI Pipeline with Gerrit Code ReviewJenkins world 2017 - Data-Driven CI Pipeline with Gerrit Code Review
Jenkins world 2017 - Data-Driven CI Pipeline with Gerrit Code Review
 
Stable master workflow with Gerrit Code Review
Stable master workflow with Gerrit Code ReviewStable master workflow with Gerrit Code Review
Stable master workflow with Gerrit Code Review
 
Gerrit Code Review Analytics
Gerrit Code Review AnalyticsGerrit Code Review Analytics
Gerrit Code Review Analytics
 
Zero-Downtime Gerrit Code Review Upgrade
Zero-Downtime Gerrit Code Review UpgradeZero-Downtime Gerrit Code Review Upgrade
Zero-Downtime Gerrit Code Review Upgrade
 
Speed up Continuous Delivery with BigData Analytics
Speed up Continuous Delivery with BigData AnalyticsSpeed up Continuous Delivery with BigData Analytics
Speed up Continuous Delivery with BigData Analytics
 
Devoxx 2016 Using Jenkins, Gerrit and Spark for Continuous Delivery Analytics
Devoxx 2016 Using Jenkins, Gerrit and Spark for Continuous Delivery AnalyticsDevoxx 2016 Using Jenkins, Gerrit and Spark for Continuous Delivery Analytics
Devoxx 2016 Using Jenkins, Gerrit and Spark for Continuous Delivery Analytics
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

ChronicleMap non-blocking cache for Gerrit v3.3

  • 1. 0Virtual Gerrit User Summit 2020 – On-line GerritForge.com 0 Gerrit 3.3 – pluggable cache Luca Milanesio Gerrit Code Review Maintainer GerritForge
  • 2. 1Virtual Gerrit User Summit 2020 – On-line GerritForge.com 1 About GerritForge Founded in the UK HQ in London with presence in Europe and the USA (GerritForge Inc.) Committed to OpenSource and to Gerrit Code Review since 2009
  • 3. 2Virtual Gerrit User Summit 2020 – On-line GerritForge.com 2 Gerrit caches: the problem Gerrit <= v2.16: ReviewDB + indexes • Low latency for reading review data • Ability to join across tables (changes, patch_sets, messages, …) • DB auto-vacuuming
  • 4. 3Virtual Gerrit User Summit 2020 – On-line GerritForge.com 3 Gerrit caches: the problem Gerrit >= v2.16: NoteDb + Lucene indexes • Low latency for reading index data: change details? • Change data is all de-normalized on NoteDb: huge JSON payload • No auto-vacuuming: frequent JGit needed
  • 5. 4Virtual Gerrit User Summit 2020 – On-line GerritForge.com 4 Gerrit caches: the problem Gerrit guava caches to the rescue • Increase in number of Gerrit caches • Increase in use of caches for NoteDb, where possible • Migration to a Java Caffeine cache backend: much faster
  • 6. 5Virtual Gerrit User Summit 2020 – On-line GerritForge.com 5 Gerrit caches: the problem What about Gerrit restarts? • In-memory caches are empty • High pressure on JGit and repository access at startup • Higher costs in terms of NFS data utilization (e.g. AWS’s EFS)
  • 7. 6Virtual Gerrit User Summit 2020 – On-line GerritForge.com 6 Gerrit caches: the problem GerritHub.io enables persistent NoteDb cache commit 83008efeaf9c987b3bfe2a8da23f21c73ccc620a Author: David Ostrovsky <david.ostrovsky@gmail.com> Date: Tue Sep 24 20:28:43 2019 +0000 Enable change_notes persistent cache Change-Id: I5f875bc2b630bf8b25843d29e946995cc6d221ab diff --git a/etc/gerrit.config b/etc/gerrit.config index 330ba45..d88bd89 100644 --- a/etc/gerrit.config +++ b/etc/gerrit.config @@ -149,6 +149,9 @@ +[cache "change_notes"] + memoryLimit = 32768 + diskLimit = 1g
  • 8. 7Virtual Gerrit User Summit 2020 – On-line GerritForge.com 7 Gerrit caches: the problem GerritHub.io experiences outages in some sites commit 87c332644c0442c33227750e0d29381798577d55 Author: Luca Milanesio <luca.milanesio@gmail.com> Date: Sat Oct 26 20:03:06 2019 +0000 Revert "Enable change_notes persistent cache" This reverts commit 83008efeaf9c987b3bfe2a8da23f21c73ccc620a. Reason for revert: Blocks the JVM during the huge H2 defragmentation Change-Id: Ib42a425dbc13bafc219e0625d7ce999f2e8afc2b
  • 9. 8Virtual Gerrit User Summit 2020 – On-line GerritForge.com 8 Gerrit caches: the problem GerritHub.io: H2-based persistent GitHub caches (https://bugs.chromium.org/p/gerrit/issues/detail?id=10276) Not so easy to reproduce: the problem is not when GitHub denies access straight away but rather when it is stuck for minutes, and that creates a series of deadlocks in the H2 cache. GitHub groups are already cached in the github-plugin and the cache is persisted also. However, H2 locking isn't great and when you have multiple concurrent requests for different groups to be loaded from GitHub, the APIs are stuck (because of whatever happens on their side) Gerrit gets stuck for a *very long time* because the H2 table is huge.
  • 10. 9Virtual Gerrit User Summit 2020 – On-line GerritForge.com 9 H2 background: fragmentation + compaction H2 is a RDBMS: vacuum & compaction (http://www.h2database.com/html/features.html#compacting) Empty space in the database file re-used automatically. When closing the database, the database is automatically compacted for up to 200 milliseconds by default. The problem: JVM threads accessing cache locked for > 200 ms
  • 11. 10Virtual Gerrit User Summit 2020 – On-line GerritForge.com 10 H2 background: locking H2 is a RDBMS: needs locking on read/writes (http://www.h2database.com/html/advanced.html) If a connection wants to write to a table (update or delete a row), an exclusive lock is required. To get the exclusive lock, other connection must not have any locks on the object. The problem: Concurrent writes to the same cache are locking each other
  • 12. 11Virtual Gerrit User Summit 2020 – On-line GerritForge.com 11 Gerrit solution: pluggable persistent cache Gerrit v2.14 allows non-H2 implementations (https://gerrit-review.googlesource.com/c/gerrit/+/176973) Introduce CacheImpl annotation There is existing mechanism to provide different implementation for instance to secure-store but one can replace only certain binding with it (through provider class). In this case when H2CacheImpl is installed it adds more bindings and replacing only this class would keep leftovers being still initiated/running in Gerrit core. CacheImpl annotation contains 2 types: MEMORY PERSISTENT It is applied to modules that provide corresponding default caches implementations. When CacheImpl annotation is added to lib module then it will override particular default implementation. Change-Id: I7562b210fad4c5f6dc67887f627cf76815a378cb Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
  • 13. 12Virtual Gerrit User Summit 2020 – On-line GerritForge.com 12 Gerrit solution: pluggable persistent cache Gerrit v3.3 allows to use it in production (https://gerrit-review.googlesource.com/c/gerrit/+/284195) Owner:Marcin Czech Use persistent cache provided by libModule for offline reindex Gerrit offline reindexing ignores persistent cache implementation provided as libModule and always generates caches using H2 implementation. This fix allows to use a different persistent cache backend. Using different cache implementation during the offline reindexing and at runtime causes situation when Gerrit starts without any precomputed caches which significantly impacts overall performance. On the other hand offline reindexing cannot reuse existing caches which impacts reindexing performance. Bug: Issue 13464 Change-Id: I36305282e8ea583dfb37f629e41d219762c3b4a3
  • 14. 13Virtual Gerrit User Summit 2020 – On-line GerritForge.com 13 First NoSQL implementation: ChronicleMap First production-ready libModule for Gerrit cache (https://gerrit.googlesource.com/modules/cache-chroniclemap/) • Based on Open-Source ChronicleMap high-speed persistent cache (https://github.com/OpenHFT/Chronicle-Map) • Designed for low-latency • Never blocks, read or write operations • Static file allocation: no need to vacuum or compaction
  • 15. 14Virtual Gerrit User Summit 2020 – On-line GerritForge.com 14 First NoSQL implementation: ChronicleMap DEMO
  • 16. 15Virtual Gerrit User Summit 2020 – On-line GerritForge.com 15 Q&A: excited about the future of Gerrit? Image from: http://cypp.rutgers.edu/ru-voting/political-information/public-opinion-polls/
  • 17. 16Virtual Gerrit User Summit 2020 – On-line GerritForge.com 16 Wants to know more? GerritForge.com/contact