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

Add new metrics to monitor memory #2650

Merged
merged 5 commits into from
Oct 15, 2024
Merged

Conversation

lmuntaner
Copy link
Collaborator

@lmuntaner lmuntaner commented Oct 15, 2024

Motivation

To introduce new metrics that will be used to monitor the memory usage as requested by security.

Changes

  • Introduce ii_archive_stable_memory_bytes, ii_archive_heap_pages and ii_archive_heap_memory_bytes metrics to the archive canister.
  • Introduce internet_identity_heap_memory_bytes and internet_identity_stable_memory_bytes metrics to main II canister.

@lmuntaner lmuntaner marked this pull request as ready for review October 15, 2024 08:08
@lmuntaner lmuntaner requested a review from a team as a code owner October 15, 2024 08:08
@lmuntaner
Copy link
Collaborator Author

@frederikrothenberger please review

@frederikrothenberger frederikrothenberger changed the title Add new metrocs to monitor memory Add new metrics to monitor memory Oct 15, 2024
Copy link
Contributor

@frederikrothenberger frederikrothenberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I would just go with ii_archive_heap_pages which is clearly missing. The rest can be deduced from pages when processing the data.

@@ -575,6 +575,7 @@ fn http_request(req: HttpRequest) -> HttpResponse {
}

fn encode_metrics(w: &mut MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
const WASM_PAGE_SIZE_IN_BYTES: f64 = 65536.0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a constant for that in the cdk. Also, as a side-note: I would not do floating point calculations unless absolutely necessary. Floating point calculations could introduce rounding errors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Fixed!

src/archive/src/main.rs Show resolved Hide resolved
@lmuntaner lmuntaner requested review from frederikrothenberger and a team October 15, 2024 10:03
@lmuntaner
Copy link
Collaborator Author

Honestly, I would just go with ii_archive_heap_pages which is clearly missing. The rest can be deduced from pages when processing the data.

Alarms for memory threshold will be added if we expose this metrics.

Copy link
Contributor

@frederikrothenberger frederikrothenberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@lmuntaner lmuntaner added this pull request to the merge queue Oct 15, 2024
Merged via the queue into main with commit 1f69be6 Oct 15, 2024
66 checks passed
@lmuntaner lmuntaner deleted the lm-add-metrics-for-memory-alerts branch October 15, 2024 11:14
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.

2 participants