[Runtime][WASM] Keep draining queued inline completions (#25245) I hit a hang while running a WebGPU model when several operations completed together. Inline completions share a drain notification, but a poll only consumes one batch. Remaining entries can stay queued until another operation wakes the proactor. This schedules another drain when completions remain. I've added a regression test with three completions and a two-entry drain buffer. Before the fix, the third completion stays queued, afterward, all three arrive in order. The test runs in the existing runtime Wasm CI job using Node. Signed-off-by: anutosh491 <andersonbhat491@gmail.com>
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12828da..7cb25c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml
@@ -182,6 +182,8 @@ node-version: "22" - name: Test WebGPU import pointers run: node --test runtime/src/iree/hal/drivers/webgpu/webgpu_imports_test.mjs + - name: Test JS inline completion progress + run: node --test runtime/src/iree/async/platform/js/proactor_imports_test.mjs - name: Install requirements run: sudo apt update && sudo apt install -y ninja-build - name: Checkout runtime submodules
diff --git a/runtime/src/iree/async/platform/js/proactor_imports.mjs b/runtime/src/iree/async/platform/js/proactor_imports.mjs index 38d74a5..6aa185b 100644 --- a/runtime/src/iree/async/platform/js/proactor_imports.mjs +++ b/runtime/src/iree/async/platform/js/proactor_imports.mjs
@@ -159,6 +159,8 @@ wasmView[i * 2 + 1] = entry.statusCode; } completionQueue.splice(0, count); + // Schedule another poll if this batch did not consume all completions. + if (completionQueue.length > 0) scheduleDrain(); return count; },
diff --git a/runtime/src/iree/async/platform/js/proactor_imports_test.mjs b/runtime/src/iree/async/platform/js/proactor_imports_test.mjs new file mode 100644 index 0000000..75ba4af --- /dev/null +++ b/runtime/src/iree/async/platform/js/proactor_imports_test.mjs
@@ -0,0 +1,33 @@ +// Copyright 2026 The IREE Authors +// +// Licensed under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +import assert from 'node:assert/strict'; +import {test} from 'node:test'; + +import {createImports} from './proactor_imports.mjs'; + +test('inline completions continue after a partial drain', async () => { + const context = { + inline: true, + memory: new WebAssembly.Memory({initial: 1}), + }; + const imports = createImports(context); + const received = []; + context.exports = { + proactor_drain() { + const count = imports.ring_drain(0, 2); + received.push(...new Int32Array(context.memory.buffer, 0, count * 2)); + }, + }; + + // One burst exceeds the two-entry drain buffer; no later completion wakes it. + context.complete(1, 0); + context.complete(2, 1); + context.complete(3, 2); + await new Promise(resolve => setTimeout(resolve, 0)); + + assert.deepEqual(received, [1, 0, 2, 1, 3, 2]); +});