← Back to Pull requests

[#1664] Make service builder log origins lazy #1877

Closed
unknown closed this pull request without merging on Aug 04, 2026 11:14 UTC
View on GitHub
unknown unknown commented on Aug 03, 2026 12:29 UTC
Author

Notes for Reviewer

Follow up to #1664 and the discussion on #1859. This is only the "stop doing pointless work"
half - it does not touch the size question, which is what I understood you have ideas about
and what we said we would discuss at the meetup.

The logging path is already lazy. __internal_print_log_msg checks the level before touching
the logger and takes core::fmt::Arguments, and warn!(from x, ...) passes format_args!,
so nothing is formatted when a message is filtered out. But these call sites build a String
at function entry, before any of the ifs:

fn adjust_configuration_to_meaningful_values(&mut self) {
    let origin = format!("{self:?}");   // always runs
    ...
    if settings.subscriber_max_borrowed_samples == 0 {
        warn!(from origin, "...");      // may never fire
    }

For a service builder that Debug is 6493 characters, and it is paid on the success path with
logging disabled. warn!(from self, ...) is already what 224 other call sites do, so this just
makes two of the exceptions match.

Two sites only, both on the service creation path. In BuilderWithServiceType::open the
receiver is &self so it is a straight swap. In adjust_configuration_to_meaningful_values
the &mut borrow through settings spans all five warn! calls, so each check now reads
immutably via the existing publish_subscribe() accessor, logs, then mutates.

No behaviour change other than the log text, which actually gets slightly cleaner: the origin
was being formatted twice (call site builds a String, the macro then applies {:?} to it),
which added 58 backslash escapes. That goes to 0.

Measured, 2000 publish-subscribe create-and-destroy cycles, log level Fatal so nothing is
ever emitted, 7 runs, median:

| | before | after | saving |
| --- | --- | --- | --- |
| aarch64 macOS | 825.6 us | 759.9 us | 66 us |
| x86_64 Linux (m5.metal) | 5.887 ms | 5.748 ms | 139 us |

Worth being explicit that this is not a throughput or latency win - none of these sites is
on the send or receive path. It is startup and service creation work, and the percentage it
represents varies a lot with the storage under the temp directory (8.0% on the Mac's local SSD,
2.4% on the Linux box's EBS volume), so the absolute number is the meaningful one.

I left the other 27 sites alone deliberately. 12 more could convert the same way but showed no
measurable benefit, and the remaining 15 consume self, so from self does not compile there
at all. Those are better handled by whatever comes out of the size discussion.

Checked with cargo fmt, cargo clippy and cargo test --workspace on aarch64 macOS - 534
publish-subscribe tests pass. The one clippy warning in iceoryx2-bb-posix is on main too.

Pre-Review Checklist for the PR Author

[x] Add sensible notes for the reviewer
[x] PR title is short, expressive and meaningful
[ ] Consider switching the PR to a draft (Convert to draft)
[x] Relevant issues are linked in the References section
[x] Branch follows the naming format (iox2-1664-make-log-origins-lazy)
[x] Commits messages are according to commit message guidelines
[x] Commit messages have the issue ID ([#1664])
[ ] Tests follow best practice for testing guidelines - no new tests, existing coverage
exercises these paths and the change has no behavioural effect

  • Changelog updated in the unreleased section including API breaking changes
  • References

    Relates to #1664

    Diff: 436 lines (+327 / -109) across 5 files Reviewer: Nawazz-ish Review duration: 1365m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 436 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.364
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1877"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.2% (MEDIUM) · Higher = larger blast radius
    45.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.9% · Safe to merge
    17.9%