← Back to Pull requests

8398424: x86: Align vector constant stubs to 64 bytes to avoid cache-line split loads #34085

Open
unknown opened this pull request with 538 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 26, 2026 08:03 UTC
Author

Hi All,

With default settings on x86_64, several 64-byte vector constant stubs are not aligned to a 64-byte (cache line) boundary.
Taking each start address reported by -XX:+PrintStubCode modulo 64 gives an offset of 32:

StubRoutines::vector_float_sign_mask_stub
    (stub gen) [0x00007f190f7c6f60, 0x00007f190f7c6fa0] (64 bytes) // offset 32
StubRoutines::vector_float_sign_flip_stub
    (stub gen) [0x00007f190f7c6fa0, 0x00007f190f7c6fe0] (64 bytes) // offset 32
StubRoutines::vector_double_sign_mask_stub
    (stub gen) [0x00007f190f7c6fe0, 0x00007f190f7c7020] (64 bytes) // offset 32
StubRoutines::vector_double_sign_flip_stub
    (stub gen) [0x00007f190f7c7020, 0x00007f190f7c7060] (64 bytes) // offset 32
StubRoutines::vector_all_bits_set_stub
    (stub gen) [0x00007f190f7c7060, 0x00007f190f7c70a0] (64 bytes) // offset 32
StubRoutines::vector_short_to_byte_mask_stub
    (stub gen) [0x00007f190f7c70e0, 0x00007f190f7c7120] (64 bytes) // offset 32
StubRoutines::vector_byte_perm_mask_stub
    (stub gen) [0x00007f190f7c7120, 0x00007f190f7c7160] (64 bytes) // offset 32

These stubs are emitted by StubGenerator::generate_vector_mask() and StubGenerator::generate_vector_byte_perm_mask().
Both currently align to CodeEntryAlignment, which is 32 on x86.

C2 reads these constants as 64-byte (ZMM) memory operands. With the stub at offset 32, every such access is split across two cache lines. This patch emits align64() before each generated stub, so every mask starts at a cache-line boundary.

The gains come from the sign mask and sign flip stubs, which are used by vector neg, abs and FP-to-integral casts.
vector_byte_perm_mask and vector_short_to_byte_mask are aligned for consistency.

Performance (existing JMH benchmarks, TypeVectorOperations.TypeVectorOperationsSuperWord, COUNT=2048, lower ns/op is better):

  • System: AMD EPYC 9996 256-Core Processor (Venice), fixed frequency 2.5 GHz

  • Baseline: JDK 28 EA+25; Opt: baseline + this patch

  • Split loads/op: measured with -prof perfnorm:events=ls_misal_loads.ma64
  • <img width="1421" height="379" alt="image" src="https://github.com/user-attachments/assets/d895408a-b04b-4dd1-9f04-5f3a3af78b37" />

    Kindly review and share your feedback.

    Best Regards,
    Jatin

    ---------

  • I confirm that I make this contribution in accordance with the OpenJDK Interim AI Policy.
  • <!-- Anything below this marker will be automatically updated, please do not edit manually! -->
    ---------

    Progress


  • \[x\] Change must not contain extraneous whitespace

  • \[x\] Commit message must refer to an issue

  • \[ \] Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)
  • Issue


    JDK-8398424: x86: Align vector constant stubs to 64 bytes to avoid cache-line split loads (Enhancement - P4)

    Reviewers


    Quan Anh Mai (@merykitty - Reviewer) 🔄 Re-review required (review applies to 913e971f)
    * Vladimir Kozlov (@vnkozlov - Reviewer) 🔄 Re-review required (review applies to 913e971f)

    Reviewing


    <details><summary>Using <code>git</code></summary>

    Checkout this PR locally: \
    $ git fetch https://git.openjdk.org/jdk.git pull/34085/head:pull/34085 \
    $ git checkout pull/34085

    Update a local copy of the PR: \
    $ git checkout pull/34085 \
    $ git pull https://git.openjdk.org/jdk.git pull/34085/head

    </details>
    <details><summary>Using Skara CLI tools</summary>

    Checkout this PR locally: \
    $ git pr checkout 34085

    View PR using the GUI difftool: \
    $ git pr show -t 34085

    </details>
    <details><summary>Using diff file</summary>

    Download this PR as a diff file: \
    <a href="https://git.openjdk.org/jdk/pull/34085.diff">https://git.openjdk.org/jdk/pull/34085.diff</a>

    </details>
    <details><summary>Using Webrev</summary>

    Link to Webrev Comment
    </details>

    Diff: 538 lines (+403 / -135) across 6 files Reviewer: vnkozlov Review duration: 7204m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 538 lines diff across 6 files
    0.48
    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.376
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #34085"
    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: 47.9% (MEDIUM) · Higher = larger blast radius
    47.9%
    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: 25.6% · Safe to merge
    25.6%
    Repository