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

feat: add metrics manager cache #1625

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zealchen
Copy link
Contributor

@zealchen zealchen commented Feb 9, 2025

Rationale

#1623

Detailed Changes

  1. Create a metric cache for both read and write scenarios.
type MetricsData = RwLock<HashMap<MetricName, (FieldName, FieldType)>>;

struct MetricsCache {
    pub inner: Arc<RwLock<MetricsInner>>,
}

struct MetricsInner {
    // global cache data older than X days
    pub global: Arc<SectionedHashMap<Arc<MetricsData>>>,
    // section of cache data for latest X days
    pub local: Arc<SectionedHashMap<Arc<MetricsData>>>,
    // TODO: compute next day cache in advance
    pub next_day: Arc<MetricsData>,
}
  1. The local cache contains the latest 30 days metrics data.
  2. The global cache contains data older than 30 days.
  1. If missing the write cache, the metric data will be asynchronously written to storage.

Test Plan

@github-actions github-actions bot added the feature New feature or request label Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant