Skip to content

Enable JIT compilation on macOS - #100947

Merged
alexey-milovidov merged 15 commits into
masterfrom
enable-jit-on-macos
Apr 25, 2026
Merged

alexey-milovidov merged 15 commits into
masterfrom
enable-jit-on-macos

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Mar 27, 2026 •

Copy link
Copy Markdown
Member

The APPLE condition was disabling the embedded compiler (JIT) and DWARF parser on macOS. The comment only explains the MSAN exclusion, and the Apple exclusion appears to be a leftover from early days when LLVM didn't build cleanly on macOS. Remove it to enable JIT on macOS by default.

Changelog category (leave one):

  • Improvement

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

Enable JIT compilation on macOS.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.83

The `APPLE` condition was disabling the embedded compiler (JIT) and DWARF parser on macOS. The comment only explains the MSAN exclusion, and the Apple exclusion appears to be a leftover from early days when LLVM didn't build cleanly on macOS. Remove it to enable JIT on macOS by default.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d19aa2d]

Summary: ✅


AI Review

Summary

This PR removes the unconditional APPLE disablement for LLVM features in contrib/llvm-project-cmake/CMakeLists.txt, so ENABLE_EMBEDDED_COMPILER and ENABLE_DWARF_PARSER now default to enabled on macOS (still disabled for MSan). The change is small, consistent with existing options, and I did not find correctness, safety, or compatibility issues in the diff.

Missing context
  • ⚠️ Full CI is still running (Fast test and Build (arm_tidy) were in progress during review), so final runtime/build validation is not yet visible.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ➖
No test removal ✅
Experimental gate ✅
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements submodule changed At least one submodule changed in this PR. labels Mar 27, 2026
alexey-milovidov and others added 4 commits March 27, 2026 22:13
When cross-compiling to macOS, LLVM's `config-ix.cmake` detects
`HAVE_LIBRT` from the Linux build host, but `librt` doesn't exist
on macOS. The LLVM Orc JIT libraries (`LLVMOrcTargetProcess`,
`LLVMOrcJIT`, `LLVMOrcDebugging`) link `rt` when `HAVE_LIBRT` is
set, causing: `ld: library not found for -lrt`.

Fix by setting `HAVE_LIBRT` to false for Apple targets before
entering the LLVM subdirectory.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100947&sha=98ea2118ba286f3973765cc477b882e5ecd12080&name_0=PR&name_1=Build%20%28amd_darwin%29

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alexey-milovidov added a commit that referenced this pull request Mar 29, 2026
…es than `skip_first_lines`

When `input_format_csv_skip_first_lines` or `input_format_tsv_skip_first_lines`
is set to a value larger than the number of lines in the file,
`skipPrefixBeforeHeader` enters an infinite loop doing `pread` at EOF.
Each call to `readRow` succeeds with an empty result even at EOF, so the
loop never terminates.

Add an EOF check before each `readRow` call to break out of the loop
when the file is exhausted.

Found via AST fuzzer in Stress test (amd_msan) on PR #100947.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@Algunenano Algunenano 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.

Seems to work fine:

:)         SELECT
            COUNT()
        FROM
            jit_test
        WHERE
            NOT ignore(a / b + c / d + e / f + g / h + i / j)
        SETTINGS
            compile_expressions = 0;

SELECT COUNT()
FROM jit_test
WHERE NOT ignore(((((a / b) + (c / d)) + (e / f)) + (g / h)) + (i / j))
SETTINGS compile_expressions = 0

Query id: 4d9b1028-d3aa-483b-a93a-2c682b905323

   ┌───COUNT()─┐
1. │ 200000000 │ -- 200.00 million
   └───────────┘

1 row in set. Elapsed: 1.774 sec. Processed 190.86 million rows, 15.27 GB (107.58 million rows/s., 8.61 GB/s.)
Peak memory usage: 294.53 KiB.

:)         SELECT
            COUNT()
        FROM
            jit_test
        WHERE
            NOT ignore(a / b + c / d + e / f + g / h + i / j)
        SETTINGS
            compile_expressions = 1,
            min_count_to_compile_expression = 1

SELECT COUNT()
FROM jit_test
WHERE NOT ignore(((((a / b) + (c / d)) + (e / f)) + (g / h)) + (i / j))
SETTINGS compile_expressions = 1, min_count_to_compile_expression = 1

Query id: e05cbfe2-85d5-4a6f-85af-3f8c9315eb23

   ┌───COUNT()─┐
1. │ 200000000 │ -- 200.00 million
   └───────────┘

1 row in set. Elapsed: 0.211 sec. Processed 200.00 million rows, 16.00 GB (949.12 million rows/s., 75.93 GB/s.)
Peak memory usage: 295.34 KiB.

@Algunenano Algunenano self-assigned this Mar 30, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

The MSan stress test failure (MemorySanitizer: use-of-uninitialized-value, STID 4179-5154 or 4148-3044) is a known pre-existing issue unrelated to this PR. Fix: #102158

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Apr 25, 2026
Merged via the queue into master with commit a27a1f1 Apr 25, 2026
165 checks passed
@alexey-milovidov
alexey-milovidov deleted the enable-jit-on-macos branch April 25, 2026 13:04
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 25, 2026
@Algunenano Algunenano mentioned this pull request May 15, 2026
47 of 72 tasks
alexey-milovidov added a commit that referenced this pull request May 18, 2026
…ex_granularity (#104162)

Random settings limit only had an upper bound on `index_granularity` and no
limits on `index_granularity_bytes`. With no lower bound, the test runner
randomized `index_granularity` down to 27 (and `index_granularity_bytes` can
be as low as 1024), producing 7400+ granules over the 200K-row table.

The 300s client timeout fired while `ALTER TABLE test MODIFY COLUMN json JSON
SETTINGS mutations_sync=1` rewrote all parts. Each granule contributes
per-mark overhead that compounds with MSan + WasmEdge slowdown plus parallel
CI contention.

CIDB shows the same failure across 3 unrelated runs in 30 days (PR #100947,
master 76e37f1, PR #100375), all in
`Stateless tests (amd_msan, WasmEdge, parallel, 1/2)`, all with
`index_granularity` in {27, 18, 28}.

Locally measured (debug build, 200K rows, JSON `ALTER MODIFY`):
- default `index_granularity=8192`           24 granules, 0.21s
- failing  `index_granularity=27`           7408 granules, 1.62s
- pathological `index_granularity_bytes=1024` 7408 granules, 1.62s
- proposed floor `index_granularity=100, bytes=10000` 2001 granules, 0.59s

Mirrors the limits already used by the source test
`03246_alter_from_string_to_json.gen.sql` from which 03381 was derived.

Per @alexey-milovidov's request on
#100375 (comment)...

Co-authored-by: Groene AI <[email protected]>
Co-authored-by: Alexey Milovidov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants