Repository navigation
perf: cache /tmp/dash0_env_vars instead of re-reading it on every call - #97
Open
RaphaelManke wants to merge 1 commit into
Open
RaphaelManke wants to merge 1 commit into
RaphaelManke wants to merge 1 commit into
Conversation
RaphaelManke
temporarily deployed
to
staging
September 10, 2026 14:09 — with
GitHub Actions
Inactive
RaphaelManke
temporarily deployed
to
staging
September 10, 2026 14:09 — with
GitHub Actions
Inactive
RaphaelManke
temporarily deployed
to
staging
September 10, 2026 14:09 — with
GitHub Actions
Inactive
RaphaelManke
temporarily deployed
to
staging
September 10, 2026 14:09 — with
GitHub Actions
Inactive
3 tasks done
RaphaelManke
had a problem deploying
to
staging
September 10, 2026 14:15 — with
GitHub Actions
Failure
RaphaelManke
temporarily deployed
to
staging
September 10, 2026 14:15 — with
GitHub Actions
Inactive
RaphaelManke
temporarily deployed
to
staging
September 10, 2026 14:15 — with
GitHub Actions
Inactive
RaphaelManke
had a problem deploying
to
staging
September 10, 2026 14:33 — with
GitHub Actions
Failure
RaphaelManke
force-pushed
the
perf/cache-env-vars-file
branch
from
October 20, 2026 05:35
7939a69 to
289d831
Compare
|
Darkplane Automerge is enabled for this repository (mode: Dry run). Trigger an evaluation for this pull request when it is ready: Evaluations on this repository start manually. To have Darkplane Automerge evaluate each pull request on its own, set Trigger to Automatic in the repository's configuration. |
|
Darkplane Automerge would approve this pull request. It scored 77.79 of 100, clearing the threshold of 75. Dry-run mode is on, so nothing was approved or merged.
The other 3 criteria
An AI evaluator produced these scores from the diff, the repository history, and the pull request text. The pull request text is author-controlled, so treat the scores as signals rather than proof. Reviewed for commit 6882ae3. |
RaphaelManke
force-pushed
the
perf/cache-env-vars-file
branch
from
October 28, 2026 14:31
289d831 to
6882ae3
Compare
try_read_env_from_file() did a blocking std::fs::read_to_string plus a fresh serde_json parse, with no caching, on every call. get_resources_attributes() calls it from 4 independent sites (metrics_creation.rs, span_creation.rs, span_mutations.rs, exporter.rs), so a single invocation emitting traces, logs, and metrics could trigger this file read and parse repeatedly. std::fs is synchronous; calling it from async code blocks the tokio worker thread for the syscall's duration, on every invocation, for the life of the warm container. The file is written once by opt/shared.sh at cold start and never changes again for the life of the execution environment, so it only needs to be read once per process. Cached behind a Mutex<Option<Arc<...>>> (matching the existing pattern in state/global.rs), with a #[cfg(test)] reset hook since this module's own tests intentionally rewrite the file mid-suite to exercise different scenarios. Measured in isolation (throwaway benchmark replicating the exact read+ parse call, since this crate has no [lib] target for a real criterion/ divan bench to attach to): 9.4us/call uncached vs 35ns/call cached, a 265x difference.
RaphaelManke
force-pushed
the
perf/cache-env-vars-file
branch
from
November 3, 2026 14:52
6882ae3 to
990cfa3
Compare
RaphaelManke
had a problem deploying
to
staging
November 3, 2026 14:55 — with
GitHub Actions
Failure
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
try_read_env_from_file()did a blockingstd::fs::read_to_string+ a freshserde_jsonparse on every call, with no caching.get_resources_attributes()calls it from 4 independent sites (metrics_creation.rs,span_creation.rs,span_mutations.rs,exporter.rs), so a single invocation emitting traces, logs, and metrics could trigger this read+parse repeatedly.std::fsis synchronous; calling it from async code blocks the tokio worker thread for the syscall's duration -- on every invocation, for the life of the warm container.opt/shared.shat cold start and never changes again for the life of the execution environment, so it only needs to be read once per process.Fix
Cached behind
Mutex<Option<Arc<Option<serde_json::Value>>>>, matching the existing shared-state pattern already used instate/global.rs. Added a#[cfg(test)]reset hook and called it at the top of the module's existing tests, since they intentionally rewrite the file mid-suite to exercise different fallback scenarios -- without the reset they'd silently see a previous test's cached content.Measured
This crate has no
[lib]target for a realcriterion/divanbench to attach to, so measured in isolation by replicating the exact read+parse call in a throwaway benchmark: 9.4us/call uncached vs. 35ns/call cached -- a 265x difference.Test plan
cargo build --releasecargo test --release(325/325 passing, including all 7otlp::resources::tests::*)