Skip to content

Add a WebAssembly build to CI: clickhouse-local runs in the browser - #113404

Merged
alexey-milovidov merged 18 commits into
masterfrom
wasm-build-in-ci
Aug 11, 2026
Merged

alexey-milovidov merged 18 commits into
masterfrom
wasm-build-in-ci

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Related: #112911

#112911 made emcmake cmake configure this tree and the layers up to clickhouse_common_io compile to wasm64. This PR takes that to its conclusion: the whole multicall clickhouse binary builds and links for WebAssembly, and clickhouse local executes queries under Node.js ≥ 24 and in the browser — and a Build (wasm64) CI job among the special builds (PR and master workflows) pins the build and the Node.js execution path so they cannot regress. (The browser path is verified manually as below; CI does not cover it yet.) The job provides the emcc output pair (clickhouse.wasm, 236 MB, plus the clickhouse.js instantiation script) as an artifact.

What runs today, verified in both Node.js 24 and headless Chromium 149 (served with the COOP/COEP headers that SharedArrayBuffer, and therefore pthreads-on-Workers, require):

$ node clickhouse.js local --multiquery "
    CREATE TABLE t (id UInt64, s String, d Date) ENGINE = MergeTree ORDER BY id;
    INSERT INTO t SELECT number, concat('row-', toString(number)), toDate('2026-01-01') + number % 365 FROM numbers(100000);
    SELECT count(), uniqExact(s), min(d), max(d) FROM t;
    SELECT toStartOfMonth(d) AS m, count() FROM t GROUP BY m ORDER BY m LIMIT 3"
100000  100000  2026-01-01      2026-12-31
2026-01-01      8494
2026-02-01      7672
2026-03-01      8494

MergeTree parts written to the in-memory filesystem; SELECT sum(number) FROM numbers(100000000) in ~2 seconds of wall time including engine startup and module instantiation; 1847 functions in system.functions; JSONEachRow from stdin; Pretty formats; syntax errors with positions. In the browser, the same module aggregates 10 million rows in a page (~5 s from page load to result, including fetching and compiling the 236 MB module).

The changes

The build system (cmake/target.cmake, on top of the dbms step below):

  • ENABLE_CAPNP off for OS_WASM — its kj library calls fallocate unconditionally in its POSIX branch, which the Emscripten libc lacks. USE_MONGODB off — raw sockets like the other disabled integrations, and its mlib has an explicit #error for platforms it does not recognize.
  • Executable link options: an 8 MiB shadow stack and 256 MiB of growable memory (Emscripten's defaults are 64 KiB and a fixed 16 MiB, while clickhouse needs ~50 MiB for static data alone); -g0 at the link, because binaryen's wasm-opt asserts in its DWARF bookkeeping (AddrExprMap::add) on a module with this much debug info; -sPROXY_TO_PTHREAD, because this code blocks its calling thread freely and in a browser the main thread must keep running the event loop that spawns the Web Workers backing new pthreads — without it the first blocking pthread_create deadlocks the page; -sEXIT_RUNTIME so a finished query tears the runtime down.

The platform arms (all small, in the spirit of #112911):

  • The dlopen-blocking override in programs/main.cpp yields on OS_WASM: Emscripten's libc unconditionally defines dlerror, so the override was a duplicate symbol at the link — and a sandbox cannot load libraries in the first place.
  • initgroups for clickhouse-su — the one libc symbol the entire binary found missing. It fails closed with ENOSYS.
  • The explicit Field::safeGet<unsigned long> and ColumnVector::indexImpl<size_t> instantiations extend from OS_DARWIN to OS_WASM: both are LP64 platforms where uint64_t is unsigned long long, so size_t matches no UInt* type.
  • The SignalListener thread follows OS_HAS_SIGNAL_HANDLERS (the capability macro from Recognize an Emscripten/WebAssembly target #112911) in every entry point that starts one — ClientApplicationBase, DisksApp and BaseDaemon: without signals nothing ever writes to the signal pipe, and the blocking read of that pipe — all the thread does — fails with EAGAIN on Emscripten, which took the whole process down through KillingErrorHandler. With no listener, BaseDaemon::waitForTerminationRequest has nothing to wait on and nothing could ever deliver a request to it, so it throws NOT_IMPLEMENTED instead of blocking forever.

The dbms step (earlier commit): everything above clickhouse_common_io needed exactly two lines — USE_MONGODB off, and a suppression of -Wlifetime-safety-return-stack-addr-moved gated on clang ≥ 24 in cmake/warnings.cmake, the way cmake/add_warning.cmake prescribes. That analysis is experimental, exists only in clang 24 (nothing links clang 24 today except Emscripten's bundled compiler), and flags the pervasive and correct idiom of taking a raw pointer out of a unique_ptr, moving the owner into a container and returning the pointer; its own diagnostic text concedes the report "could be a false positive".

The CI job configures through emcmake (Emscripten's toolchain file supplies emcc/em++, so no compiler is passed), with the compiler cache disabled because emcc is a Python driver that sccache cannot cache. The binary-builder image gets the Emscripten SDK pinned to 6.0.5 and pre-generates the wasm64 variant of the system libraries (-sMEMORY64, -fwasm-exceptions and -pthread are ABI flags), so CI builds do not compile them lazily at first use.

Verification

Ran the exact CI configure and build on an arm64 machine (same architecture as the arm-large runners): all 11343 edges compile with -Weverything -Werror and zero diagnostics; the link takes ~7 minutes at 13.4 GiB peak RSS; llvm-readobj reports Arch: wasm64, AddressSize: 64bit. Runtime verified as above, plus wasm exceptions (a DB::Exception thrown and caught through the native exception-handling proposal) and std::thread on Web Workers.

Known wart, upstream: after the runtime reaches exit(0) (verified with -sPTHREADS_DEBUG: all threads clean up, exitRuntime runs), one Web Worker survives Emscripten's teardown and keeps the Node.js process alive — a CLI invocation needs an external timeout for now. The browser does not care: results are delivered and the page keeps running.

Node.js ≥ 24 is required at runtime (Emscripten 6 emits Memory64 code and refuses older engines); in browsers this means Chrome ≥ 133 or equivalent, plus cross-origin isolation for threads.

Changelog category (leave one):

  • Experimental Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Experimental: the clickhouse binary builds for WebAssembly (wasm64, via Emscripten), and clickhouse local runs queries — including MergeTree tables — under Node.js ≥ 24 and in the browser. A new Build (wasm64) CI job pins the build and the Node.js execution path (the browser path is not covered by CI yet) and provides the WebAssembly module as an artifact.

Version info

  • Merged into: 26.8.1.1188 (included in 26.8 and later)

PR #112911 made `emcmake cmake` configure this tree and the layers up to
`clickhouse_common_io` compile to `wasm64`. Pin that state in CI so it
cannot regress: a `Build (wasm64)` job among the special builds, running
in both the PR and master workflows.

The job configures through `emcmake` (Emscripten's toolchain file supplies
`emcc`/`em++`, so no compiler is passed) and builds exactly the targets
that are known to work: `common` and `clickhouse_common_io`. The compiler
cache is disabled because `emcc` is a Python driver that sccache cannot
cache. The binary-builder image gets the Emscripten SDK pinned to 6.0.5,
the version the target was verified with, and pre-generates the wasm64
variant of the system libraries (`-sMEMORY64`, `-fwasm-exceptions` and
`-pthread` are ABI flags, see cmake/target.cmake), so CI builds do not
compile them lazily at first use.

Verified with the exact CI configure and build commands: 2539 objects
across 28 contrib libraries, base and src compile with zero warnings, and
both archives link; `llvm-readobj` confirms `Arch: wasm64`. The whole
build takes ~30 seconds of wall time on a 96-core machine, making it one
of the cheapest build jobs.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov
alexey-milovidov requested a review from a team as a code owner August 5, 2026 02:09
@mintlify

mintlify Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Aug 5, 2026, 2:44 AM

@clickhouse-gh

clickhouse-gh Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [eb0b421]

Summary: ✅


AI Review

Summary

This PR adds a Build (wasm64) CI variant, wires the CH_WASM64 artifact through Praktika/workflows, and completes the OS_WASM platform guards needed for the multicall clickhouse binary plus a Node.js smoke test. I did not find a new correctness or safety defect in the current head state.

Missing context / blind spots
  • ⚠️ I did not independently execute the browser path from this checkout. The new automated evidence added here covers Node.js only; the browser-runtime claim in the PR description is still backed by manual verification unless a headless-browser smoke or equivalent attached run evidence is added.
Final Verdict

✅ No new inline findings on the current PR head.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.00% 79.00% +0.00%

Changed lines: Changed C/C++ lines covered: 48/48 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-build Pull request with build/testing/packaging improvement label Aug 5, 2026
@alexey-milovidov
alexey-milovidov marked this pull request as draft August 5, 2026 02:39
Everything above `clickhouse_common_io` turns out to need exactly two
lines: `USE_MONGODB` off in the `OS_WASM` arm of cmake/target.cmake
(raw sockets like the other disabled integrations, and its `mlib` has an
explicit #error for platforms it does not recognize), and a suppression
of `-Wlifetime-safety-return-stack-addr-moved` gated on clang >= 24, the
way cmake/add_warning.cmake prescribes. That analysis is experimental,
only exists in clang 24 (which nothing links today except Emscripten's
bundled compiler), and flags the pervasive and correct idiom of taking a
raw pointer out of a `unique_ptr`, moving the owner into a container and
returning the pointer; its own diagnostic text concedes the report "could
be a false positive".

With those two, `ninja dbms` compiles all 3211 edges - Interpreters,
Processors, Storages/MergeTree, the parsers, the compression codecs and
their contribs - with zero errors and zero warnings, and links a wasm64
`libdbms.a`. The CI job's pinned target becomes `dbms`.

Also verified at runtime, not just at link: a demo linked against the
built archives - `parseQuery` producing and formatting a `SELECT` AST,
`DB::Exception` thrown and caught through WebAssembly exceptions, and a
`std::thread` on a Web Worker - runs to completion under Node.js 24 and
in headless Chromium 149 served with cross-origin isolation.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov alexey-milovidov changed the title Add a WebAssembly (wasm64) build to CI Add a WebAssembly (wasm64) build to CI, building the whole dbms Aug 5, 2026
…wser

The whole multicall `clickhouse` binary now compiles (11343 edges) and links
(a 236 MB wasm64 module) with Emscripten, and `clickhouse local` executes
queries correctly under Node.js >= 24 and in Chromium 149: MergeTree tables
on the in-memory filesystem, aggregations over 100 million rows of `numbers`
in ~2 seconds including engine startup, 1847 SQL functions, JSONEachRow from
stdin, Pretty formats. The CI job's pinned target becomes `clickhouse` and
the job provides the module as an artifact.

What it took, beyond the `dbms` step:

* `ENABLE_CAPNP` off for `OS_WASM`: its `kj` library calls `fallocate`
  unconditionally in its POSIX branch, which the Emscripten libc lacks.
* Executable link options for `OS_WASM` in cmake/target.cmake: an 8 MiB shadow
  stack and 256 MiB of growable memory (the defaults are 64 KiB and a fixed
  16 MiB, while `clickhouse` needs ~50 MiB for static data alone); `-g0` at
  the link, because binaryen's `wasm-opt` asserts in its DWARF bookkeeping
  (`AddrExprMap::add`) on a module with this much debug info;
  `-sPROXY_TO_PTHREAD` so `main`, which blocks its thread freely, runs on a
  pthread while the browser main thread keeps servicing the event loop that
  spawns the Web Workers backing new pthreads - without it the first blocking
  `pthread_create` deadlocks the page; and `-sEXIT_RUNTIME` so a finished
  query tears the runtime down.
* The `dlopen`-blocking override in programs/main.cpp yields on `OS_WASM`:
  Emscripten's libc unconditionally defines `dlerror`, so the override was a
  duplicate symbol - and a sandbox cannot load libraries in the first place.
* `initgroups` for `clickhouse-su`: the one libc symbol the entire binary
  found missing. Emscripten has the other identity stubs; this one fails
  closed with ENOSYS.
* Explicit `Field::safeGet<unsigned long>` and `ColumnVector::indexImpl<size_t>`
  instantiations extend from `OS_DARWIN` to `OS_WASM`: both are LP64 platforms
  where `uint64_t` is `unsigned long long`, so `size_t` matches no `UInt*` type.
* The `SignalListener` thread in `ClientApplicationBase` follows
  `OS_HAS_SIGNAL_HANDLERS`: without signals nothing ever writes to the signal
  pipe, and the blocking read of that pipe - all the thread does - fails with
  EAGAIN on Emscripten, which took the whole process down through
  `KillingErrorHandler`.

Known wart, upstream: after the runtime reaches `exit(0)` (verified with
`-sPTHREADS_DEBUG`), one Web Worker survives teardown and keeps the Node.js
process alive; the browser does not care.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov alexey-milovidov changed the title Add a WebAssembly (wasm64) build to CI, building the whole dbms Add a WebAssembly build to CI: clickhouse-local runs in the browser Aug 5, 2026
Comment thread ci/defs/defs.py Resolved
Comment thread ci/jobs/build_clickhouse.py Resolved
alexey-milovidov and others added 2 commits August 6, 2026 04:31
…the wasm module under Node.js

The `Build (wasm64)` link failed in CI: the image pre-warms Emscripten's
system-library cache, but the pre-warm link did not pass `-sPROXY_TO_PTHREAD`,
which selects the `crt1_proxy_main.o` startup object instead of `crt1.o` —
so `em++` tried to generate it lazily into the root-owned cache and died with
`PermissionError`. The pre-warm link flags now mirror the `clickhouse` link
options from `cmake/target.cmake` exactly.

Address review: the job now runs `clickhouse local` under Node.js 24 (added to
the image) instead of merely linking it. The query executes from a directory
holding only the two files the `CH_WASM64` artifact uploads, which also proves
the artifact is complete — since Emscripten 3.1.58 the pthread worker code is
embedded in the main JS file, so no `.worker.js` sidecar exists. Because of the
known upstream wart where one Web Worker outlives runtime teardown and keeps the
Node.js process alive, the query runs under `timeout` and success is judged by
the produced output.

Build log: https://s3.amazonaws.com/clickhouse-test-reports/PRs/113404/68886ff39afea772561db32e3e1ed3c2f067a3b4/build_wasm64/build_clickhouse/build_clickhouse.log
PR: #113404

Co-Authored-By: Claude Fable 5 <[email protected]>
# Conflicts:
#	.github/workflows/master.yml
#	.github/workflows/pull_request.yml
#	src/Columns/ColumnVector.cpp
#	src/Core/Field.cpp
Comment thread ci/jobs/build_clickhouse.py Resolved
alexey-milovidov and others added 3 commits August 8, 2026 01:00
The `Build (wasm64)` job failed at the final link: `em++` tried to
generate `libstubs.a` lazily into the root-owned image cache and got
`PermissionError`. The pre-warm link in the `binary-builder` image
mirrored the `add_link_options` of the `OS_WASM` branch but ran
unoptimized, and the optimization level at the link is part of
Emscripten's library-variant selection: `-O0` picks the `-debug`
builds (`libstubs-debug.a`, `libc-mt-debug.a`, ...) while the
`-O3 ... -g0` CI link needs the release ones (`libstubs.a`,
`libc-mt.a`, `libdlmalloc-mt.a`, `libc++-mt-legacyexcept.a`,
`libc++abi-mt-legacyexcept.a`). Add `-O3` and `-g0` to the pre-warm;
verified against a fresh cache that the exact CI link line then
generates nothing lazily.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113404&sha=9091d549a6cd034e6781f2db531e379030d3b245&name_0=PR&name_1=Build%20%28wasm64%29
#113404

Co-Authored-By: Claude Fable 5 <[email protected]>
The Node.js smoke test now runs a `--multiquery`: `CREATE TABLE ...
ENGINE = MergeTree`, an `INSERT` of 1000 rows, and a deterministic
aggregate over them, so the in-memory filesystem and the
`CREATE`/`INSERT`/`SELECT` path are covered rather than only constant
expression evaluation. Expected output verified against a native
`clickhouse local`.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The Build (wasm64) failure on 9091d54 is fixed in 5df8e7b: the image pre-warm ran unoptimized, and the optimization level at the link is part of Emscripten's library-variant selection — the -O3 ... -g0 CI link needed the release variants (libstubs.a, libc-mt.a, ...) while only the -debug ones were cached, so em++ fell into lazy generation in the root-owned cache and got PermissionError.

The remaining failures on that head are unrelated to this PR (it only touches the wasm build path and CI):

@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

The Stress test (arm_asan_ubsan, s3) hung check on 9091d549 is not the same failure as the one you reported on #113722, so it needs a different answer. I pulled both jobs' logs and compared the stuck stacks frame by frame:

#113722 / ceedb772 #113404 / 9091d549
hung query SELECT ... FROM system.parts_columns, is_internal = 1 (server-side AST fuzzer) SELECT count() FROM tab_multi ... hasAllTokens(...) from 04403_text_index_push_ranges_first_token_postings.sql, is_internal = 0
elapsed 251.996213 1199.831476
deepest frames StorageSystemPartsColumns::processNextStorage <- initializePipeline ReadBufferFromRemoteFSGather::readImpl <- CachedOnDiskReadBufferFromFile::nextImplStep <- MergeTreeMarksLoader::loadMarksImpl <- MergeTreeIndexReader::initStreamIfNeeded <- filterMarksUsingIndex

processNextStorage and StorageSystemPartsColumns appear 0 times in this job's log, and MergeTreeMarksLoader / ReadBufferFromRemoteFSGather / FileSegment::lock appear 0 times in the #113722 job's log. Different subsystems, so #113909 does not cover this one.

This failure is the skip-index marks read blocking past cancellation, which is already fixed in my open #113436. That PR makes ReadBufferFromRemoteFSGather::readImpl call throwIfKilled before the blocking fill, opted in at the two MergeTreeDataSelectExecutor index-analysis sites, one of which is filterMarksUsingIndex (MergeTreeDataSelectExecutor.cpp:2568) exactly where this stack sits. So the fix is in progress rather than something new to send, and I have linked it here as you asked.

Your remaining bullets need nothing from me: the assertTypeEquality failure is the master-wide STID 2508-2e0c family tracked by #113534, and I agree with your reading of 02015_async_inserts_5 and test_keeper_dynamic_log_level.

Comment thread ci/jobs/build_clickhouse.py Resolved
Comment thread ci/jobs/build_clickhouse.py Resolved
The wasm64 link failed with `PermissionError` on
`symbol_lists/<hash>.json.lock`: pre-warming cannot cover the
`symbol_lists` cache entries, because their hash covers the resolved
link settings and some settings are derived from the program being
linked (e.g. `MAIN_READS_PARAMS`, from the signature of `main`), so
the real `clickhouse` link always misses the entry cached by the
trivial pre-warm program and generates its own - into a root-owned
cache. Open the cache up for the unprivileged CI build user instead
of chasing every lazily written file.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113404&sha=b073abe0805ac673f00fd7d4099c217fb1dc9d60&name_0=PR&name_1=Build%20%28wasm64%29
PR: #113404
…ot browsers

The wasm64 smoke test no longer hides every nonzero exit status behind
`|| true`: it accepts only 0 and 124 (the known upstream wart - one
Web Worker survives the runtime teardown and keeps the Node.js process
alive, so the query runs under `timeout`), and any other status fails
the job even when the expected output was produced.

The comments and the CI documentation now state exactly what the job
verifies: the build and query execution under Node.js >= 24; running
in browsers works but is not covered by CI yet.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The Build (wasm64) failure on b073abe is fixed in 22e752f: pre-warming cannot cover the symbol_lists/<hash>.json cache entries (their hash covers settings derived from the program being linked, e.g. MAIN_READS_PARAMS), so the real clickhouse link fell into lazy generation in the root-owned cache and got PermissionError — the image now makes the Emscripten cache writable for the CI build user.

The Stress test (arm_asan_ubsan, s3) failure is the master-wide LeakSanitizer red (all-indirect leaks from the materialized-CTE plan reference cycle), unrelated to this PR; the fix is in progress in #113397.

@clickhouse-gh clickhouse-gh Bot added pr-experimental Experimental Feature and removed pr-build Pull request with build/testing/packaging improvement labels Aug 8, 2026
Comment thread src/Client/ClientApplicationBase.cpp Resolved
Comment thread ci/jobs/build_clickhouse.py Resolved
… as soon as it succeeds

Two Majors from the AI review on f018f45:
- `clickhouse disks` (shipped in the wasm multicall binary) still started and
  stopped `SignalListener` unconditionally; apply the same
  `OS_HAS_SIGNAL_HANDLERS` guard as in `ClientApplicationBase`.
- The smoke test paid the full 300-second `timeout` on every green run because
  Node.js never exits (one Web Worker survives the runtime teardown). Node.js
  now runs in the background and is killed as soon as the expected output
  appears; the 300-second polling loop remains only as the worst-case deadline,
  and a process that dies on its own without the output still fails the job by
  its exit status.
@clickhouse-gh

clickhouse-gh Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

No arm_release build profile data for commit eb0b421 - the build was skipped, reused from cache, or predates profile upload.

…-inflicted kill (137)

The predicate `[ "$found" -eq 1 ] || [ "$status" -eq 0 ]` made any nonzero
exit status acceptable once `smoke.out` contained the expected line, so a
wasm run that prints the result and then aborts during shutdown still made
`Build (wasm64)` green. Now status 0 is always acceptable (the final grep
still checks the output), and 137 (128+SIGKILL, our own early kill of the
surviving-worker hang) is acceptable only when the expected output was seen
first; any other status fails the job.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The three red checks on e3e2644 are unrelated to this PR (it only touches the wasm build path and CI; Build (wasm64) itself, including the Node.js smoke test, was green):

Pushed cccc2ef addressing the remaining AI-review Major (the smoke test accepts only exit status 0, or 137 after the expected output), and merged the latest master (dbed330).

Comment thread ci/jobs/build_clickhouse.py Resolved
Comment thread ci/jobs/build_clickhouse.py Resolved
@alexey-milovidov
alexey-milovidov marked this pull request as ready for review August 9, 2026 19:39
… the SIGKILL

The check claimed that only the harness's own `SIGKILL` is an acceptable
non-zero status, but it never recorded whether its `kill -9` actually fired:
a module that printed the expected line and was then `SIGKILL`ed by someone
else - the out-of-memory killer, the job timeout, the CI infrastructure -
also reached `found=1` and `137`, and passed.

Now the `137` allowance is gated on this script being the sender: the kill is
still always attempted so nothing is leaked, but `killed=1` is set only when
the expected output was seen *and* the `kill` succeeded, and the predicate
tests `killed` instead of `found`. Verified with stub processes: print-then-hang
(our kill) and clean self-exit pass; print-then-external-`SIGKILL` now fails
where the previous predicate returned success; print-then-`exit 7` and
killed-before-any-output fail.
…IGNAL_HANDLERS`

`ClientApplicationBase` and `DisksApp` no longer start a `SignalListener` on a
platform without signals, but `BaseDaemon` still did - and the multicall
`clickhouse` binary built for WebAssembly contains the daemon-style entry
points too. `SignalListener::run` does nothing but block on a read of
`HandledSignals::signal_pipe`, which nothing can ever write to when there are
no signals, so the thread was pure overhead at best.

The listener creation, the `StopThread` write and the thread join are now
compiled out without `OS_HAS_SIGNAL_HANDLERS`; the surrounding
`HandledSignals` setup and `reset` are already no-ops there. Since there is
then no listener, and nothing could deliver a termination request to one
anyway, `waitForTerminationRequest` throws `NOT_IMPLEMENTED` rather than
blocking forever or dereferencing a null listener.

Verified that `OS_HAS_SIGNAL_HANDLERS` is defined in this translation unit
natively (dumped the macros with the real compile command), so native builds
keep the listener, and that both arms compile.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 CI on dbed330f1f5b was green except one check, which is unrelated to this PR (it only touches the wasm build path and CI; Build (wasm64), including the Node.js smoke test, passed):

Pushed 8ffc230d350f and 6d865450f2e3 addressing both AI-review Majors — the smoke test now accepts 137 only when it is the one that delivered the SIGKILL, and BaseDaemon gets the same OS_HAS_SIGNAL_HANDLERS guard as ClientApplicationBase and DisksApp — and merged the latest master (1812632a4ca5).

@clickhouse-gh

clickhouse-gh Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 37 queries analysed

This PR adds an experimental wasm64 (WebAssembly via Emscripten) build target: a new CI build job, Emscripten/Node toolchain in the builder image, an OS_WASM cmake branch, and C++ edits that are all guarded behind OS_WASM / OS_HAS_SIGNAL_HANDLERS (plus a trivial host.contains refactor). None of that changes the query-execution path in the standard build under test. The single flagged improvement on clickbench Q17 (-11.2%) cannot plausibly be caused by this change, so it is downgraded to not-sure as run-to-run variance rather than a real speedup. No regressions were flagged.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 17 not_sure 556 494 -11.2% <0.0001 This PR only adds an experimental WebAssembly build target (CI job, Dockerfile, cmake OS_WASM arm) with C++ edits gated behind OS_WASM/OS_HAS_SIGNAL_HANDLERS, so a normal build's query path is unchanged; the -11.2% on Q17 is run-to-run variance.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 41dc669b-b5d2-48b2-a2dd-bbfcc4e5afef
  • MIRAI run: 732409e1-1fde-46ae-8bcd-a380f8213fca
  • PR check IDs:
    • clickbench_724627_1786447073
    • clickbench_724633_1786447073
    • clickbench_724644_1786447073
    • tpch_adapted_1_official_724652_1786447073
    • tpch_adapted_1_official_724669_1786447073
    • tpch_adapted_1_official_724698_1786447073

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All good.

@alexey-milovidov alexey-milovidov self-assigned this Aug 11, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 11, 2026
Merged via the queue into master with commit 36b6c39 Aug 11, 2026
182 checks passed
@alexey-milovidov
alexey-milovidov deleted the wasm-build-in-ci branch August 11, 2026 22:49
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 11, 2026

This branch was successfully deployed

1 active deployment
staging - docs — eb0b421a Deployed Aug 11, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-experimental Experimental Feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants