Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lock from OptimisticCache and unmerge it from MemoryCache #5662

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

BoD
Copy link
Contributor

@BoD BoD commented Feb 28, 2024

A followup to #5651.

I reverted the merge of OptimisticCache with MemoryCache after all, as doing the same with SqlCache would duplicate the code for no good reason. The important change was to remove the use of a lock, using ConcurrentHashMap instead (JVM only).

While the benchmarks tended to show some improvement with the MemoryCache, the same change here with SqlCache seems to make no significant impact:

ApolloStoreIncubatingTests Sql MemoryThenSql
Before 814,997,144 1,109,686,100
After 784,362,731 1,091,352,269
Improvement 3.76% 1.65%
CacheIncubatingIntegrationTests Sql MemoryThenSql
Before 1,069,503,201 39,206,260
After 1,042,806,258 37,213,591
Improvement 2.50% 5.08%

@BoD BoD merged commit 951e46e into cache-store Feb 29, 2024
5 checks passed
@BoD BoD deleted the merge-sql-optimistic-caches branch February 29, 2024 11:11
BoD added a commit that referenced this pull request Mar 7, 2024
* Add a benchmark: CacheIncubatingTests.concurrentReadWriteFromCache

* Use guava in JVM

* Refact to prepare merging MemoryCache and OptimisticCache: NormalizedCache and OptimisticNormalizedCache are now interfaces. Also remove chaining.

* Make NormalizedCache implement OptimisticNormalizedCache

* Fix unit tests

* Use Store's Guava port instead of Guava JVM

* Add Cache.asMap()

* Use Store based LRUCache on all platforms

* Move Store classes to own package

* Distinguish caches in dump()

* Add header to Store files.

* Fix some compilation errors in tests

* Update libraries/apollo-normalized-cache-api-incubating/src/wasmJsMain/kotlin/com/apollographql/apollo3/cache/normalized/api/internal/ConcurrentMap.wasmJs.kt

Co-authored-by: Martin Bonnin <martin@mbonnin.net>

* Update libraries/apollo-normalized-cache-api-incubating/src/jsMain/kotlin/com/apollographql/apollo3/cache/normalized/api/internal/ConcurrentMap.js.kt

Co-authored-by: Martin Bonnin <martin@mbonnin.net>

* Suppress unused parameters

* Tweak NormalizedCache.remove()'s KDoc

* Remove lock from OptimisticCache and unmerge it from MemoryCache (#5662)

* Fix atomicfu dependency

---------

Co-authored-by: Martin Bonnin <martin@mbonnin.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants