Skip to content

Revert "Revert "Enable JIT compilation for more expressions"" and Support JIT for decimal and bigint types#73509

Closed
taiyang-li wants to merge 51 commits intoClickHouse:masterfrom
bigo-sg:more_jits_new
Closed

Revert "Revert "Enable JIT compilation for more expressions"" and Support JIT for decimal and bigint types#73509
taiyang-li wants to merge 51 commits intoClickHouse:masterfrom
bigo-sg:more_jits_new

Conversation

@taiyang-li
Copy link
Copy Markdown
Contributor

@taiyang-li taiyang-li commented Dec 18, 2024

Changelog category (leave one):

  • Performance Improvement

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

Revert "Revert "Enable JIT compilation for more expressions""(#73010) and Support JIT for decimal and bigint types

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

CI Settings (Only check the boxes if you know what you are doing):

  • Allow: All Required Checks
  • Allow: Stateless tests
  • Allow: Stateful tests
  • Allow: Integration Tests
  • Allow: Performance tests
  • Allow: All Builds
  • Allow: batch 1, 2 for multi-batch jobs
  • Allow: batch 3, 4, 5, 6 for multi-batch jobs

  • Exclude: Style check
  • Exclude: Fast test
  • Exclude: All with ASAN
  • Exclude: All with TSAN, MSAN, UBSAN, Coverage
  • Exclude: All with aarch64, release, debug

  • Run only fuzzers related jobs (libFuzzer fuzzers, AST fuzzers, etc.)
  • Exclude: AST fuzzers

  • Do not test
  • Woolen Wolfdog
  • Upload binaries for special builds
  • Disable merge-commit
  • Disable CI cache

@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-feature Pull request with new product feature label Dec 18, 2024
@robot-ch-test-poll
Copy link
Copy Markdown
Contributor

robot-ch-test-poll commented Dec 18, 2024

This is an automated comment for commit a09780f with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS❌ failure
Successful checks
Check nameDescriptionStatus
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Dec 18, 2024
@robot-ch-test-poll1 robot-ch-test-poll1 added pr-performance Pull request with some performance improvements and removed pr-feature Pull request with new product feature labels Dec 18, 2024
@taiyang-li taiyang-li marked this pull request as ready for review December 20, 2024 01:28
@alexey-milovidov alexey-milovidov self-assigned this May 20, 2025
@alexey-milovidov
Copy link
Copy Markdown
Member

@taiyang-li, continue?

@taiyang-li
Copy link
Copy Markdown
Contributor Author

taiyang-li commented Jun 16, 2025

@taiyang-li, continue?

I had some issues on making the building success. I had splitted FunctionsConversions.{h,cpp}, but it didn't work. Need your help. Thanks!

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Jul 8, 2025

Workflow [PR], commit [30d9e9e]

Summary:
15 failures out of 110 shown:

job_name test_name status info comment
Style check failure
cpp failure
Docs check dropped
Fast test error
Build (amd_debug) dropped
Build (amd_release) dropped
Build (amd_asan) dropped
Build (amd_tsan) dropped
Build (amd_msan) dropped
Build (amd_ubsan) dropped
Build (amd_binary) dropped
Build (arm_release) dropped
Build (arm_asan) dropped
Build (arm_coverage) dropped
Build (arm_binary) dropped
Build (amd_darwin) dropped

@taiyang-li
Copy link
Copy Markdown
Contributor Author

Failed building seems not related to this PR: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=73509&sha=6a0d47b559681ab8d4e75cbdef7333d15e344593&name_0=PR&name_1=Build%20%28amd_tidy%29

FAILED: contrib/libcxxabi-cmake/CMakeFiles/cxxabi.dir/__/llvm-project/libcxxabi/src/fallback_malloc.cpp.o 
/usr/bin/sccache /usr/bin/clang++-19 --target=x86_64-linux-gnu --sysroot=/home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/cmake/linux/../../contrib/sysroot/linux-x86_64/x86_64-linux-gnu/libc -DHAS_THREAD_LOCAL -DSTD_EXCEPTION_HAS_STACK_TRACE=1 -D_LIBCPP_BUILDING_LIBRARY -D_LIBUNWIND_IS_NATIVE_ONLY -isystem /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/contrib/llvm-project/libcxxabi/../libcxx/src -isystem /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/contrib/llvm-project/libcxxabi/../libcxx/include -isystem /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/contrib/llvm-project/libcxxabi/include -isystem /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/contrib/llvm-project/libunwind/include --gcc-toolchain=/home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/cmake/linux/../../contrib/sysroot/linux-x86_64 -fdiagnostics-color=always -Xclang -fuse-ctor-homing -fsized-deallocation  -UNDEBUG -gdwarf-aranges -pipe -mssse3 -msse4.1 -msse4.2 -mpclmul -mpopcnt -fasynchronous-unwind-tables -falign-functions=32 -mbranches-within-32B-boundaries -ffp-contract=off  -fdiagnostics-absolute-paths -fstrict-vtable-pointers -g -Og -g  -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -std=c++23   -D OS_LINUX -w -nostdinc++ -fno-sanitize=undefined -Wno-macro-redefined -MD -MT contrib/libcxxabi-cmake/CMakeFiles/cxxabi.dir/__/llvm-project/libcxxabi/src/fallback_malloc.cpp.o -MF contrib/libcxxabi-cmake/CMakeFiles/cxxabi.dir/__/llvm-project/libcxxabi/src/fallback_malloc.cpp.o.d -o contrib/libcxxabi-cmake/CMakeFiles/cxxabi.dir/__/llvm-project/libcxxabi/src/fallback_malloc.cpp.o -c /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/contrib/llvm-project/libcxxabi/src/fallback_malloc.cpp
sccache: error: Server startup failed: cache storage failed to read: Unexpected (temporary) at read => send http request

@Felixoid
Copy link
Copy Markdown
Member

The issue with sccache server will probably be addressed in #83600

@alexey-milovidov
Copy link
Copy Markdown
Member

Fuzzer found signal 8 (floating point exception).

@taiyang-li
Copy link
Copy Markdown
Contributor Author

Fuzzer found signal 8 (floating point exception).

@alexey-milovidov how to process it when division with zero happens in llvm ir ?

  1. Throw exceptions. It behaves the same as without JIT, but I found it is difficult to capture exceptions throw from generated code.
  2. Return zero. It is easy to implement, but its behavior is not consistent with that without JIT.

@alexey-milovidov
Copy link
Copy Markdown
Member

Avoid using JIT for integer divisions (intDiv, modulo).

@alexey-milovidov
Copy link
Copy Markdown
Member

Note: I also considered another way with sigsetjmp/siglongjmp before a loop where nothing besides computations happens (no memory allocations, no exceptions) and using it to catch divisions by zero.

@taiyang-li
Copy link
Copy Markdown
Contributor Author

Note: I also considered another way with sigsetjmp/siglongjmp before a loop where nothing besides computations happens (no memory allocations, no exceptions) and using it to catch divisions by zero.

@alexey-milovidov Thanks for your advice. I'll try this.

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Aug 19, 2025

Dear @alexey-milovidov, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@alexey-milovidov
Copy link
Copy Markdown
Member

@taiyang-li, let's continue.

Compile some scalar functions and operators to native code.
)", 0) \
DECLARE(UInt64, min_count_to_compile_expression, 3, R"(
DECLARE(UInt64, min_count_to_compile_expression, 0, R"(
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.

Change before merge.

{"enable_vector_similarity_index", false, false, "Added an alias for setting `allow_experimental_vector_similarity_index`"},
{"distributed_plan_max_rows_to_broadcast", 20000, 20000, "New experimental setting."},
{"min_joined_block_size_rows", 0, DEFAULT_BLOCK_SIZE, "New setting."},
{"min_count_to_compile_expression", 3, 1, "For ci tests"},
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.

Remove before merge.

template <typename A, typename B>
inline void throwIfDivisionLeadsToFPE(A a, B b)
{
std::cout << "jit stacktrace:" << StackTrace().toString() << std::endl;
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.

Remove before merge.

}
}

/*
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.

Remove before merge.

throw Exception(ErrorCodes::LOGICAL_ERROR, "ModuloImpl compilation expected integer types in (U)Int8|16|32|64|128|256");

auto * mod = b.GetInsertBlock()->getParent()->getParent();
// for (const auto & func : mod->functions())
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.

Remove before merge.

@@ -1,3 +1,8 @@
-- When compilation is enabled, the query result is more accurate compared to when compilation is disabled.
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.

Should be checked in another way.

@taiyang-li
Copy link
Copy Markdown
Contributor Author

taiyang-li commented Oct 23, 2025

@alexey-milovidov sorry, I've been a bit busy lately and may not have more time to devote to it. I'm really grateful that you could continue my previous work.

alexey-milovidov added a commit that referenced this pull request Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-performance Pull request with some performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants