You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(relay): reconcile multiline env values without rescanning prefixes - #31196
reconcileEnvFile restarts its closing-quote search at line zero for every targeted multiline assignment. Repeated multiline values therefore cause quadratic prefix scans.
Solution
Start each closing-quote scan at the next line and skip the same completed span. This focused performance fix preserves existing .env output, duplicate handling and unclosed-value behavior. For B input characters and E update entries, time becomes O(B + E); existing O(B + E) space is unchanged. Successful scans cover disjoint spans, and only three quote types can cause an unsuccessful suffix scan.
Validation (tests extended before production code):
vp test run infra/relay/src/clientConfig.test.ts: 10 tests passed before and after, including filesystem publication through the Alchemy action.
vp run check:changed: all selected checks passed.
Actual-source differential proof: 10,005 exact-output cases passed. At 1,024 repeated multiline assignments, instrumented callbacks plus includes calls drop from 1,051,648 to 2,048. These are operation counts, not elapsed time or production-latency measurements.
Three independent Codex reviews returned clean.
Related configuration pipeline: #12401. #31111 changes a separate error field in this module; its complete diff does not overlap this algorithm. This is a small, behavior-preserving performance fix, not a new feature; no maintainer approval is claimed.
Reviewing files that changed from the base of the PR and between 9d0c904 and f8f883b.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
reconcileEnvFile now scans forward when it processes a multiline quoted assignment. Tests cover replacement of repeated assignments, preservation of unrelated lines, and later assignments after an unterminated quote.
The scan checks later lines for the first occurrence of the opening quote and skips through that line. Tests cover multiline values with different quote styles, repeated assignments, and later assignments after an unterminated quote.
This change removes repeated prefix scanning when reconciling multiline environment values, and its tests cover repeated assignments and unclosed quotes. No concrete merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: reconciling multiline env values in relay config without rescanning prefixes. It uses a conventional commit prefix and matches the performance fix in reconcileEnvFile …
Description check
The description follows the template well. It has a clear Problem section, a Solution (Change) section that explains the algorithm fix, and a Verification section with specific test commands, results,…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: reconciling multiline env values in relay config without rescanning prefixes. It uses a conventional commit prefix and matches the performance fix in reconcileEnvFile described in the summary and objectives.
Full details: Description check
Explanation
The description follows the template well. It has a clear Problem section, a Solution (Change) section that explains the algorithm fix, and a Verification section with specific test commands, results, and operation counts. It also states that the change is a bug-style performance fix with no maintainer approval claimed. The Scope section does not link an issue and does not explain why no issue is needed. The author cites related PR #12401 but does not say whether it is an issue. Measured counts are reported as operation counts, not timings, and the description states this. The model/harness line is present as the template requests.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between 0025e63 and 9d0c904.
Files selected for processing: 1
infra/relay/src/clientConfig.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
This repeats the duplicate multiline behavior already covered above without checking the scan cost, so it cannot catch the performance regression. Consider removing it.
Macroscope's review found this PR approvable — The multiline environment-value search now skips already-scanned prefixes while preserving existing reconciliation behavior. File destinations, configuration defaults, and secret handling are unchanged.
You can add or adjust custom eligibility rules. Learn more.
@maria-rcks could you review this focused reconciliation change? All eligible current-head checks pass on 0025e63, CodeRabbit has no actionable findings or unresolved threads, and the 15-minute quiet gate passed. The change avoids rescanning earlier lines while preserving multiline quote handling. Tests were extended before the implementation; the 10 focused tests, 10,005 actual-source equivalence cases, and changed-file checks pass.
Ran production PublishClientConfig against identical synthetic files on Linux x64 / Ryzen 9 9950X / Node v26.13.1. Each case used five warmups and 31 measured invocations, with two rounds in base/head/head/base order. Input restoration and byte verification were untimed.
16,384 multiline assignments: round 1 median 155.199 ms, range 127.865–177.172 ms; round 2 median 151.945 ms, range 133.107–167.747 ms.
Same input: round 1 median 8.081 ms, range 6.660–11.288 ms; round 2 median 5.841 ms, range 4.035–8.439 ms.
Median improvements of 147.118 ms and 146.104 ms exceed even the combined before/after spreads in their respective rounds. Every multiline case produced exactly the same seven entries once; single-line controls preserved every KEEP=1 line. All output hashes matched across commits. The 1,024-assignment improvement was smaller than run-to-run noise.
Full relay deployment was not exercised: the driver invoked the production publishing action locally without provisioning cloud resources.
Measurements establish the improvement for the reported repeated closed multiline assignments; they do not prove the general O(B + E) bound for every possible input.
At 1024 assignments, the measured improvement did not exceed run-to-run spread.
Measured the production PublishClientConfig action with real file reads and writes on Linux x64, Node v26.13.1. Identical synthetic inputs, five warmups and 31 measured calls per size per session; two sessions per commit in base/head/head/base order. Seed creation excluded. Every output checked byte-for-byte.
16,384 multiline: median 117.995 ms; range 107.351–161.786 ms
16,384 multiline: median 3.955 ms; range 3.189–6.360 ms
At 16,384 assignments, the action is 29.84× faster. The 114.041 ms median improvement exceeds the base's 54.435 ms full spread and head's 3.171 ms full spread. All 1,440 production writes matched expected contents, including preservation of control KEEP lines. At 1,024 assignments, the difference is smaller than observed noise.
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
size:XS0-9 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
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.
Problem
reconcileEnvFilerestarts its closing-quote search at line zero for every targeted multiline assignment. Repeated multiline values therefore cause quadratic prefix scans.Solution
Start each closing-quote scan at the next line and skip the same completed span. This focused performance fix preserves existing
.envoutput, duplicate handling and unclosed-value behavior. For B input characters and E update entries, time becomes O(B + E); existing O(B + E) space is unchanged. Successful scans cover disjoint spans, and only three quote types can cause an unsuccessful suffix scan.Validation (tests extended before production code):
vp test run infra/relay/src/clientConfig.test.ts: 10 tests passed before and after, including filesystem publication through the Alchemy action.vp run check:changed: all selected checks passed.includescalls drop from 1,051,648 to 2,048. These are operation counts, not elapsed time or production-latency measurements.Related configuration pipeline: #12401. #31111 changes a separate error field in this module; its complete diff does not overlap this algorithm. This is a small, behavior-preserving performance fix, not a new feature; no maintainer approval is claimed.
TLDR
complexity-env.mp4
Model: GPT-6.1 Sol. Harness: Codex in T3 Code.