Skip to content

perf(riscv64): fast path interrupt polling#1074

Open
xiaokamikami wants to merge 1 commit into
masterfrom
perf/execute-intr-research
Open

perf(riscv64): fast path interrupt polling#1074
xiaokamikami wants to merge 1 commit into
masterfrom
perf/execute-intr-research

Conversation

@xiaokamikami

@xiaokamikami xiaokamikami commented Jun 15, 2026

Copy link
Copy Markdown
Member

Optimize the hot RISC-V interrupt polling path in isa_query_intr().

Most polling calls do not result in a taken interrupt. Avoid constructing the pending interrupt state when no interrupt is enabled, M-mode interrupts are globally disabled, or NMIE is closed.

After observing a pending interrupt, compute the effective privilege and delegation mask once. Use a static byte-sized priority table to reduce the overhead of the cold interrupt selection path.

The RISC-V interrupt priority, privilege, delegation, RVH, and Sscofpmf semantics are preserved.

DynamoRIO shared REF CoreMark results with identical guest instruction counts:

Before: 6,466,360,574 host instructions
After:  5,507,075,491 host instructions
Reduction: 14.835%

@xiaokamikami xiaokamikami force-pushed the perf/execute-intr-research branch from 7417b12 to 1e396b2 Compare June 29, 2026 02:17
@xiaokamikami xiaokamikami force-pushed the perf/execute-intr-research branch 2 times, most recently from fcbee9e to 4ec2445 Compare July 9, 2026 02:30
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

NEMU Performance Results - XS Interpreter

Test Guest Instructions Host Instructions Estimated Host Throughput (instr/s) Actual NEMU Throughput (instr/s) Baseline Host Instructions Baseline Actual NEMU Throughput (instr/s) Change vs Baseline (Instructions)
bitmanip.bin 1.385e+05 5.747e+07 2.410e+07 2.782e+07 5.748e+07 2.283e+07 +0.01%
coremark-riscv64-xs-rv64gc-o2.bin 3.354e+06 1.946e+08 1.723e+08 1.590e+08 1.946e+08 1.585e+08 +0.00%
coremark-riscv64-xs-rv64gc-o3.bin 3.394e+06 1.940e+08 1.750e+08 1.394e+08 1.940e+08 1.808e+08 +0.00%
coremark-riscv64-xs-rv64gcb-o3.bin 3.035e+06 1.911e+08 1.588e+08 1.501e+08 1.911e+08 1.640e+08 +0.00%
amtest-riscv64-xs.bin 1.587e+04 8.829e+06 1.798e+07 1.643e+07 8.829e+06 1.802e+07 +0.00%
aliastest-riscv64-xs.bin 1.376e+03 7.729e+06 1.780e+06 3.466e+06 7.730e+06 2.972e+06 +0.02%
softprefetchtest-riscv64-xs.bin 2.643e+03 7.783e+06 3.396e+06 5.993e+06 7.783e+06 5.822e+06 +0.01%
zacas-riscv64-xs.bin 6.470e+04 1.266e+07 5.111e+07 1.984e+07 1.266e+07 1.968e+07 +0.00%
rvv-workload-suite 4.566e+04 1.112e+08 4.107e+06 4.728e+06 1.112e+08 4.628e+06 +0.01%
linux-hello 6.677e+07 1.690e+10 3.951e+07 4.831e+07 1.690e+10 4.957e+07 -0.00%

NEMU Performance Results - XS Ref Shared Object

Test Guest Instructions Host Instructions Estimated Host Throughput (instr/s) Actual NEMU Throughput (instr/s) Baseline Host Instructions Baseline Actual NEMU Throughput (instr/s) Change vs Baseline (Instructions)
bitmanip.bin 1.385e+05 1.058e+09 1.309e+06 1.197e+06 1.097e+09 1.044e+06 +3.61%
coremark-riscv64-xs-rv64gc-o2.bin 3.354e+06 5.487e+09 6.113e+06 5.437e+06 6.447e+09 4.715e+06 +14.88%
coremark-riscv64-xs-rv64gc-o3.bin 3.394e+06 5.505e+09 6.166e+06 5.361e+06 6.475e+09 4.556e+06 +14.99%
coremark-riscv64-xs-rv64gcb-o3.bin 3.035e+06 5.222e+09 5.812e+06 4.627e+06 6.090e+09 4.628e+06 +14.25%
amtest-riscv64-xs.bin 1.588e+04 3.010e+07 5.275e+06 2.188e+06 3.464e+07 1.826e+06 +13.11%
aliastest-riscv64-xs.bin 1.379e+03 4.482e+06 3.077e+06 7.787e+05 4.877e+06 7.552e+05 +8.09%
softprefetchtest-riscv64-xs.bin 2.646e+03 6.231e+06 4.247e+06 1.097e+06 6.987e+06 1.296e+06 +10.83%
zacas-riscv64-xs.bin 6.471e+04 1.115e+08 5.806e+06 2.317e+06 1.300e+08 1.996e+06 +14.24%
rvv-workload-suite 4.568e+04 4.180e+08 1.093e+06 6.541e+05 4.311e+08 6.445e+05 +3.03%
linux-hello 7.522e+07 6.698e+11 1.123e+06 1.156e+06 6.683e+11 1.158e+06 -0.22%
  • Host Instructions is measured by DynamoRIO's inscount client.
  • Estimated Host Throughput assumes a fixed 4GHz CPU and IPC=2.5.
  • Actual NEMU Throughput is a single native NEMU run and may vary with host CPU performance.
  • Baseline columns are populated on pull_request runs when the PR base contains the same defconfig.
  • Change vs Baseline (Instructions) is computed from host instruction count; positive means fewer host instructions than baseline.

@OpenXiangShan OpenXiangShan deleted a comment from github-actions Bot Jul 10, 2026
@OpenXiangShan OpenXiangShan deleted a comment from github-actions Bot Jul 10, 2026
@OpenXiangShan OpenXiangShan deleted a comment from github-actions Bot Jul 10, 2026
@OpenXiangShan OpenXiangShan deleted a comment from github-actions Bot Jul 10, 2026
Skip pending-state assembly when no interrupt is enabled, M-mode has interrupts globally disabled, or NMIE is closed.

After a pending bit is observed, compute the effective global-enable mask once. Keeping delegation filtering after get_mip avoids adding get_hideleg to the common no-pending S/U path. Use a static byte-sized priority table so the cold selection path stays compact without rebuilding an array on every query.

DynamoRIO shared-ref CoreMark host instructions drop from 6,466,360,574 to 5,507,075,491 (-14.835%) with identical guest instruction counts.
@xiaokamikami xiaokamikami force-pushed the perf/execute-intr-research branch from 544d5c3 to 6b85e24 Compare July 10, 2026 08:09
@github-actions

Copy link
Copy Markdown

NEMU Performance Results - XS Interpreter

Test Guest Instructions Host Instructions Estimated Host Throughput (instr/s) Actual NEMU Throughput (instr/s) Baseline Host Instructions Baseline Actual NEMU Throughput (instr/s) Change vs Baseline (Instructions)
bitmanip.bin 1.385e+05 5.742e+07 2.412e+07 3.423e+07 5.742e+07 3.479e+07 +0.00%
coremark-riscv64-xs-rv64gc-o2.bin 3.354e+06 1.946e+08 1.723e+08 1.941e+08 1.946e+08 2.602e+08 +0.00%
coremark-riscv64-xs-rv64gc-o3.bin 3.394e+06 1.940e+08 1.750e+08 2.468e+08 1.940e+08 2.511e+08 +0.00%
coremark-riscv64-xs-rv64gcb-o3.bin 3.035e+06 1.911e+08 1.588e+08 2.301e+08 1.911e+08 2.395e+08 +0.00%
amtest-riscv64-xs.bin 1.587e+04 8.829e+06 1.798e+07 2.552e+07 8.829e+06 2.168e+07 +0.00%
aliastest-riscv64-xs.bin 1.376e+03 7.732e+06 1.780e+06 4.059e+06 7.733e+06 3.965e+06 +0.01%
softprefetchtest-riscv64-xs.bin 2.643e+03 7.785e+06 3.395e+06 4.931e+06 7.786e+06 7.796e+06 +0.01%
zacas-riscv64-xs.bin 6.470e+04 1.266e+07 5.111e+07 3.205e+07 1.266e+07 1.960e+07 +0.00%
rvv-workload-suite 4.566e+04 1.111e+08 4.110e+06 7.322e+06 1.111e+08 6.478e+06 +0.01%
linux-hello 6.677e+07 1.688e+10 3.955e+07 6.014e+07 1.688e+10 5.885e+07 +0.00%

NEMU Performance Results - XS Ref Shared Object

Test Guest Instructions Host Instructions Estimated Host Throughput (instr/s) Actual NEMU Throughput (instr/s) Baseline Host Instructions Baseline Actual NEMU Throughput (instr/s) Change vs Baseline (Instructions)
bitmanip.bin 1.385e+05 1.058e+09 1.309e+06 1.426e+06 1.097e+09 1.409e+06 +3.61%
coremark-riscv64-xs-rv64gc-o2.bin 3.354e+06 5.487e+09 6.113e+06 6.953e+06 6.447e+09 6.049e+06 +14.88%
coremark-riscv64-xs-rv64gc-o3.bin 3.394e+06 5.505e+09 6.166e+06 7.095e+06 6.475e+09 6.128e+06 +14.99%
coremark-riscv64-xs-rv64gcb-o3.bin 3.035e+06 5.222e+09 5.812e+06 6.735e+06 6.090e+09 5.726e+06 +14.25%
amtest-riscv64-xs.bin 1.588e+04 3.010e+07 5.275e+06 2.995e+06 3.464e+07 2.260e+06 +13.11%
aliastest-riscv64-xs.bin 1.379e+03 4.484e+06 3.076e+06 1.029e+06 4.878e+06 1.019e+06 +8.09%
softprefetchtest-riscv64-xs.bin 2.646e+03 6.232e+06 4.246e+06 1.030e+06 6.989e+06 1.482e+06 +10.83%
zacas-riscv64-xs.bin 6.471e+04 1.115e+08 5.805e+06 3.246e+06 1.300e+08 3.072e+06 +14.24%
rvv-workload-suite 4.568e+04 4.181e+08 1.093e+06 9.081e+05 4.311e+08 8.908e+05 +3.03%
linux-hello 7.522e+07 6.656e+11 1.130e+06 1.339e+06 6.683e+11 1.314e+06 +0.41%
  • Host Instructions is measured by DynamoRIO's inscount client.
  • Estimated Host Throughput assumes a fixed 4GHz CPU and IPC=2.5.
  • Actual NEMU Throughput is a single native NEMU run and may vary with host CPU performance.
  • Baseline columns are populated on pull_request runs when the PR base contains the same defconfig.
  • Change vs Baseline (Instructions) is computed from host instruction count; positive means fewer host instructions than baseline.

@github-actions

Copy link
Copy Markdown

NEMU Performance Results - XS Interpreter

Test Guest Instructions Host Instructions Estimated Host Throughput (instr/s) Actual NEMU Throughput (instr/s) Baseline Host Instructions Baseline Actual NEMU Throughput (instr/s) Change vs Baseline (Instructions)
bitmanip.bin 1.385e+05 5.742e+07 2.412e+07 2.824e+07 5.742e+07 2.840e+07 +0.00%
coremark-riscv64-xs-rv64gc-o2.bin 3.354e+06 1.946e+08 1.723e+08 2.178e+08 1.946e+08 1.996e+08 +0.00%
coremark-riscv64-xs-rv64gc-o3.bin 3.394e+06 1.940e+08 1.750e+08 2.240e+08 1.940e+08 2.155e+08 +0.00%
coremark-riscv64-xs-rv64gcb-o3.bin 3.035e+06 1.911e+08 1.588e+08 1.965e+08 1.911e+08 1.930e+08 +0.00%
amtest-riscv64-xs.bin 1.587e+04 8.830e+06 1.798e+07 1.602e+07 8.830e+06 2.151e+07 -0.00%
aliastest-riscv64-xs.bin 1.376e+03 7.733e+06 1.779e+06 5.313e+06 7.734e+06 3.689e+06 +0.01%
softprefetchtest-riscv64-xs.bin 2.643e+03 7.786e+06 3.395e+06 9.974e+06 7.787e+06 7.086e+06 +0.01%
zacas-riscv64-xs.bin 6.470e+04 1.266e+07 5.110e+07 1.962e+07 1.266e+07 2.434e+07 +0.01%
rvv-workload-suite 4.566e+04 1.111e+08 4.110e+06 4.979e+06 1.111e+08 4.731e+06 +0.01%
linux-hello 6.677e+07 1.688e+10 3.955e+07 4.814e+07 1.688e+10 4.802e+07 +0.00%

NEMU Performance Results - XS Ref Shared Object

Test Guest Instructions Host Instructions Estimated Host Throughput (instr/s) Actual NEMU Throughput (instr/s) Baseline Host Instructions Baseline Actual NEMU Throughput (instr/s) Change vs Baseline (Instructions)
bitmanip.bin 1.385e+05 1.058e+09 1.309e+06 1.292e+06 1.097e+09 1.394e+06 +3.61%
coremark-riscv64-xs-rv64gc-o2.bin 3.354e+06 5.487e+09 6.113e+06 5.508e+06 6.447e+09 5.060e+06 +14.88%
coremark-riscv64-xs-rv64gc-o3.bin 3.394e+06 5.505e+09 6.166e+06 5.871e+06 6.475e+09 5.151e+06 +14.99%
coremark-riscv64-xs-rv64gcb-o3.bin 3.035e+06 5.222e+09 5.812e+06 5.536e+06 6.090e+09 4.933e+06 +14.25%
amtest-riscv64-xs.bin 1.588e+04 3.010e+07 5.275e+06 2.314e+06 3.464e+07 2.013e+06 +13.11%
aliastest-riscv64-xs.bin 1.379e+03 4.484e+06 3.076e+06 7.540e+05 4.878e+06 7.661e+05 +8.09%
softprefetchtest-riscv64-xs.bin 2.646e+03 6.232e+06 4.246e+06 1.485e+06 6.989e+06 1.375e+06 +10.83%
zacas-riscv64-xs.bin 6.471e+04 1.115e+08 5.805e+06 2.495e+06 1.300e+08 2.294e+06 +14.24%
rvv-workload-suite 4.568e+04 4.181e+08 1.093e+06 7.983e+05 4.311e+08 8.112e+05 +3.03%
linux-hello 7.522e+07 6.656e+11 1.130e+06 1.240e+06 6.683e+11 1.235e+06 +0.41%
  • Host Instructions is measured by DynamoRIO's inscount client.
  • Estimated Host Throughput assumes a fixed 4GHz CPU and IPC=2.5.
  • Actual NEMU Throughput is a single native NEMU run and may vary with host CPU performance.
  • Baseline columns are populated on pull_request runs when the PR base contains the same defconfig.
  • Change vs Baseline (Instructions) is computed from host instruction count; positive means fewer host instructions than baseline.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes the RISC-V (riscv64) interrupt polling hot path in isa_query_intr() by adding early-exit checks and reducing work in the common “no interrupt taken” case, while keeping the existing interrupt priority/delegation semantics.

Changes:

  • Add fast-path early returns when no interrupts are enabled, M-mode global interrupts are disabled, or NMIE is closed.
  • Compute delegation/effective global-enable mask once per poll and apply it to the pending vector before selection.
  • Replace per-call priority arrays/loop bounds with a single static byte-sized priority table and iterate via ARRLEN.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Lemover Lemover requested review from sinceforYy and wissygh July 15, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants