← Back to Pull requests

Skip prefix checks that cannot match the first byte of the input #659

Closed
unknown closed this pull request without merging on Nov 29, 2026 05:38 UTC
View on GitHub
unknown unknown commented on Nov 15, 2026 14:24 UTC
Author

  • I've included my change in CHANGELOG.md
  • The parser tries some fixed prefixes in a row before it parses a value. Each try calls check_str, and most tries cannot match. This PR adds a check of the first byte before each group of tries. The output and the errors do not change.

    There are three commits. You can take each commit alone:

    1. deserialize_any tries 10 keywords, such as true, Some, inff32 and NaN, and the unit (). All of them start with t, f, S, N, i or (.
    2. identifier and skip_identifier try 7 string literal prefixes, such as b" and r#". All of them start with b or r. The two copies of the check are now one helper.
    3. float tries 6 inf and NaN literals. All of them start with i or N after an optional sign.

    | Input | Before | After | Change |
    |---|---:|---:|---:|
    | Value, Bevy scenes and assets | 59.9 µs | 44.0 µs | −27% |
    | Value, Oxide PMBus configs | 2.36 ms | 1.74 ms | −26% |
    | Value, Veloren items | 954 µs | 701 µs | −26% |
    | Value, Veloren manifests | 16.7 ms | 12.8 ms | −23% |
    | IgnoredAny, Veloren entities | 973 µs | 693 µs | −29% |
    | Typed scene, 2,000 entities | 4.92 ms | 3.83 ms | −22% |
    | Typed Vec<f64> | 60.9 µs | 41.1 µs | −33% |

    The table compares master with all the commits of this PR. I measured 8 groups of real files (722 files). On all of them, Value is 21% to 30% faster and IgnoredAny is 25% to 34% faster. Serialization does not change. I also measured inputs that still go through the checks, for example true, Some(..), NaN, r#ident and b"...". I measured no significant slowdown. A comparison of the old code with itself gave differences of up to ±5%. I used 12 interleaved rounds of criterion and a Mann-Whitney test (Apple Silicon, rustc 1.98). I did not measure other architectures.

    Checks:

  • cargo test --all-targets passes with the CI feature sets, and on 1.64 with minimal versions.

  • cargo fmt passes. cargo clippy shows no new warnings.

  • The from_str fuzz target ran for 5 minutes with no failure.

  • Old and new results matched on 45M checks: Value, IgnoredAny and typed targets, with and without extensions, including the error positions.
  • Diff: 275 lines (+206 / -69) across 3 files Reviewer: juntyr Review duration: 19633m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 275 lines diff across 3 files
    0.40
    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.336
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #659"
    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: 39.6% (MEDIUM) · Higher = larger blast radius
    39.6%
    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: 15.6% · Safe to merge
    15.6%
    Repository