Skip to content

[rocjitsu] Allocate decoder pools on demand - #13074

Merged
kuhar merged 1 commit into
developfrom
users/kuhar/lazy-decoder-pool
Oct 8, 2026
Merged

kuhar merged 1 commit into
developfrom
users/kuhar/lazy-decoder-pool

Conversation

@kuhar

@kuhar kuhar commented Oct 8, 2026

Copy link
Copy Markdown
Member

Allocate the instruction pool on first enablement instead of embedding its 64 KiB backing in every decoder. Production decoders use heap storage and never enable the pool. On Linux x86-64, shrink Decoder from 65,568 to 16 bytes and the CDNA5 decoder from 65,584 to 32 bytes, saving 16 MiB for 256 CUs.

Retain the pool across disable/enable cycles and invalidate active and suppressed TLS references before destruction. Keep pool ownership private and document that pooled instructions must be deleted with their pool active. Guard the compact layout and cover heap allocation while disabled, repeated enablement, and preservation of unrelated allocator state.

Validate with 529 focused tests and 74 smoke runs across five GPU targets. Matching Clang 23 Release builds reduce median peak RSS by 18.7 MiB for gfx1250 Gluon and 23.9 MiB for gfx950 IREE over three runs each. Runtime changes remain workload dependent.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 01:27
@kuhar
kuhar requested review from a team and atgutier as code owners October 8, 2026 01:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@therock-pr-bot

therock-pr-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

❌ PR Check — Action Required

Check Status Details
📝 PR Description ❌ Fail Error: PR description must reference a JIRA ID, ISSUE ID, or a GitHub closing keyword.
Expected: include a JIRA ID / ISSUE ID line (separator : or -, or omitted; value may be a JIRA key, a number with/without #, or a link), OR a closing keyword + issue reference. Accepted examples:
• JIRA ID : TESTAUTO-6039
• JIRA ID - #330
• JIRA ID #330
• JIRA ID (on separate line)
ROCM-25757
• ISSUE ID : TESTUTO-3334
• ISSUE ID #3334
• ISSUE ID - TESTAUTO-3433
• ISSUE ID (on separate line)
AIRUNTIME-2352
• ISSUE ID : https://github.com/<org_name>/<repo_name>/issues/1234
• Closes #10
• Fixes octo-org/octo-repo#100
• Resolves: #123
• #123
• https://github.com/<org_name>/<repo_name>/issues/123
Current: no valid JIRA/ISSUE/closing-keyword reference found
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

⚠️ 1 policy check(s) failed. Please address the issues above before this PR can be Reviewed.

🚫 Please fix the failed policies

  • ❌ PR Description

The Not ready to Review label was added to this PR. Once all policies pass, the label is removed automatically.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Description

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

@sjain-stanford sjain-stanford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it would help to tighten the new regressions in emulation/rocjitsu/tests/decoder_c_api_test.cpp:

  • At decoder_c_api_test.cpp:159, use EXPECT_NE instead of ASSERT_NE, or restore the pool on every exit. A fatal assertion returns while first is still pool-backed and the pool is disabled, sending its storage to global delete. A standalone ASan probe reproduces a double-free during decoder teardown. pool->owns(nullptr) is safe, so the nonfatal check can continue to the existing re-enablement.
  • At decoder_c_api_test.cpp:171, add non-null allocator hooks with alloc_pool_ == nullptr, then disable and destroy an unused decoder and check that the hooks survive. Both existing scenarios still pass with an unguarded invalidate_allocator_pool(nullptr); the null-context case distinguishes the new guard. This covers manually installed hooks beyond ordinary decoder pools.
  • At decoder_c_api_test.cpp:18, use a small layout budget for both Decoder and a representative IsaDecoder. The current comparison against the 65,552-byte pool allows a 32 KiB embedded buffer to pass. The measured Linux x86-64 sizes are 16 and 32 bytes; any exact assertions should be scoped to the supported ABI.

@kuhar
kuhar force-pushed the users/kuhar/lazy-decoder-pool branch from d8f5ee9 to 92cef83 Compare October 8, 2026 03:05
@kuhar
kuhar requested a review from sjain-stanford October 8, 2026 03:07

@sjain-stanford sjain-stanford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just one suggestion

@sjain-stanford sjain-stanford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM apart from one comment.

Allocate the instruction pool on first enablement instead of embedding its
64 KiB backing in every decoder. Production decoders use heap storage and
never enable the pool. On Linux x86-64, shrink Decoder from 65,568 to 16 bytes
and the CDNA5 decoder from 65,584 to 32 bytes, saving 16 MiB for 256 CUs.

Retain the pool across disable/enable cycles and invalidate active and
suppressed TLS references before destruction. Keep pool ownership private
and document that pooled instructions must be deleted with their pool
active. Guard the compact layout and verify that construction and decoding
leave the pool absent until first enablement. Cover retained pool ownership,
heap allocation while disabled, repeated enablement, and preservation of
unrelated allocator state.

Validate with 589 focused tests after rebase. Confirm that the allocation
regression rejects an eager-pool factory mutation. Earlier qualification
includes 74 smoke runs across five GPU targets. Matching Clang 23 Release
builds reduce median peak RSS by 18.7 MiB for gfx1250 Gluon and 23.9 MiB for
gfx950 IREE over three runs each. Runtime changes remain workload dependent.
@kuhar
kuhar force-pushed the users/kuhar/lazy-decoder-pool branch from 92cef83 to 962a758 Compare October 8, 2026 14:20
@kuhar
kuhar merged commit 5df6b61 into develop Oct 8, 2026
58 of 60 checks passed
@kuhar
kuhar deleted the users/kuhar/lazy-decoder-pool branch October 8, 2026 15:00
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

anujshuk-amd pushed a commit that referenced this pull request Oct 12, 2026
Allocate the instruction pool on first enablement instead of embedding
its 64 KiB backing in every decoder. Production decoders use heap
storage and never enable the pool. On Linux x86-64, shrink Decoder from
65,568 to 16 bytes and the CDNA5 decoder from 65,584 to 32 bytes, saving
16 MiB for 256 CUs.

Retain the pool across disable/enable cycles and invalidate active and
suppressed TLS references before destruction. Keep pool ownership
private and document that pooled instructions must be deleted with their
pool active. Guard the compact layout and cover heap allocation while
disabled, repeated enablement, and preservation of unrelated allocator
state.

Validate with 529 focused tests and 74 smoke runs across five GPU
targets. Matching Clang 23 Release builds reduce median peak RSS by 18.7
MiB for gfx1250 Gluon and 23.9 MiB for gfx950 IREE over three runs each.
Runtime changes remain workload dependent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants