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

Optimized Persisted Cache for Cardinality Queries #385

Open
keski opened this issue Feb 11, 2025 · 0 comments
Open

Optimized Persisted Cache for Cardinality Queries #385

keski opened this issue Feb 11, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@keski
Copy link
Collaborator

keski commented Feb 11, 2025

Description

To improve performance and scalability in cardinality queries, an optimized persisted cache with eviction policies will be implemented. Below follows the requirements that should be supported, along with a proposed order of implementation.

Requirements

  • Persistence: It must be able to store cached data on disk to survive restarts.
  • Concurrent access from multiple JVMs: It must be possible to execute queries in parallel using, e.g., hefquin-cli. This means that the solution cannot assume a single-JVM access pattern, since if multiple JVMs attempt to access the same file can lead to file corruption or locking issues.
  • Eviction Policies: It must support eviction policies that apply if the cache reaches its maximum size, e.g., LRU, LFU, or FIFO.
  • Time-Based Expiration (TTL, time-to-live): It must support time-based expiration that automatically invalidates cache entries after a given amount of time, as well as manual invalidation. Evicted items should be removed from both in-memory and persistent stores.

Approach

Following a review of possible approaches, the implementation will use a hybrid approach combining Chronicle Map (persistence) and Caffeine (in-memory). Chronicle Map supports persistence and access from multiple JVMs but does not support eviction policies och time-based expiration. Caffeine an efficient in-memory caching library with support for eviction and time-based invalidation policies.

Implementation steps

  1. Persisted cache based onChronicleMap (no eviction policies, no time-based invalidation) + tests
  2. In-memory cache on top of ChronicleMap based on Caffeine (eviction policy, time-based invalidation) + tests
  3. Restore in-memory cache from ChronicleMap with timestamped keys + tests
@keski keski added the enhancement New feature or request label Feb 11, 2025
@keski keski self-assigned this Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant