← Back to Pull requests

Optimize SliceUtf8 continuation-byte counting for AArch64 / Graviton #206

Open
unknown opened this pull request with 319 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 24, 2026 19:04 UTC
Author

Summary

Optimizes SliceUtf8 continuation-byte counting (countCodePoints, offsetOfCodePoint) for AArch64 / AWS Graviton CPUs:

  • Replaces Long.bitCount / Integer.bitCount (which require GPR↔NEON fmov/cnt/addv/umov transfers on Graviton2/3/4) with pure-GPR byte accumulation (up to 31 words / 248 bytes per multiply-shift reduction in countCodePoints, and single-word multiply-shift in countContinuationBytes).

  • Uses overflow-safe remaining-length arithmetic (offset + Math.min(end8 - offset, 31 * 8) and end - offset >= 4).

  • Adds unit test coverage in TestSliceUtf8.testCodePointCountRange for non-zero offsets, exact 4/8-byte remainders, and >248-byte multi-chunk inputs.
  • Benchmarks (EC2 Graviton4 c8g.2xlarge, Corretto 25.0.5.1 LTS, 2 forks × 5 iterations)

    Comparing upstream/master (4b24603) vs. this PR (ae81744) on SliceUtf8Benchmark (avgt, ns/op — lower is better):

    | Benchmark | ASCII | Length / Offset | Baseline | Patched | Speedup |
    |---|---:|---:|---:|---:|---:|
    | benchmarkCountCodePoints | true | 10 | 5.38 | 5.38 | 1.00× |
    | benchmarkCountCodePoints | true | 100 | 38.60 | 9.38 | 4.12× |
    | benchmarkCountCodePoints | true | 1000 | 402.09 | 84.02 | 4.79× |
    | benchmarkCountCodePoints | true | 10000 | 4021.01 | 817.24 | 4.92× |
    | benchmarkCountCodePoints | false | 10 | 16.09 | 7.33 | 2.20× |
    | benchmarkCountCodePoints | false | 100 | 157.62 | 35.53 | 4.44× |
    | benchmarkCountCodePoints | false | 1000 | 1582.65 | 326.78 | 4.84× |
    | benchmarkCountCodePoints | false | 10000 | 15839.63 | 3191.85 | 4.96× |
    | benchmarkCountCodePointsRange | true | 1000 (off 1/7/31) | 402.10 | 84.00 | 4.79× |
    | benchmarkCountCodePointsRange | false | 1000 (off 1/7/31) | 1582.66 | 322.92 | 4.90× |
    | benchmarkOffsetByCodePoints | true | 10 | 9.85 | 9.63 | 1.02× |
    | benchmarkOffsetByCodePoints | true | 100 | 35.39 | 19.40 | 1.82× |
    | benchmarkOffsetByCodePoints | true | 1000 | 376.32 | 106.90 | 3.52× |
    | benchmarkOffsetByCodePoints | true | 10000 | 4007.26 | 1074.66 | 3.73× |
    | benchmarkOffsetByCodePoints | false | 10 | 18.94 | 18.80 | 1.01× |
    | benchmarkOffsetByCodePoints | false | 100 | 151.52 | 56.97 | 2.66× |
    | benchmarkOffsetByCodePoints | false | 1000 | 1576.57 | 442.65 | 3.56× |
    | benchmarkOffsetByCodePoints | false | 10000 | 15872.17 | 4181.58 | 3.80× |

    Test Plan


  • Compiled with javac --release 25 --add-modules jdk.incubator.vector and ran JUnit 5 TestSliceUtf8: 51/51 tests passed.
  • Diff: 319 lines (+239 / -80) across 3 files Reviewer: raunaqmorarka Review duration: 3850m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 319 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #206"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 21.6% · Safe to merge
    21.6%
    Repository