Yida Wu has uploaded a new patch set (#4). ( http://gerrit.cloudera.org:8080/20733 )
Change subject: IMPALA-11805: Use llvm ObjectCache for codegen caching ...................................................................... IMPALA-11805: Use llvm ObjectCache for codegen caching Currently, we employ llvm::ExecutionEngine for codegen caching, providing access to compiled functions within the cached engine. However, the real challenge is the ExecutionEngine uses a lot of memory which largely exceeds our memory estimates and it is very hard to predict. This patch addresses this issue by using llvm::ObjectCache for codegen caching. The approach involves associating an ObjectCache with the module (execution engine). During function compilation within the module, if an ObjectCache is set, the pre-compiled codegened functions are written into the cache. This way, when revisiting the same module (fragment), we can efficiently reuse the specific ObjectCache, loading pre-compiled codegened functions and saving time. The tpch performance test indicates no significant regression compared to the previous use of ExecutionEngine. Post-change, the actual memory usage of each codegen caching entry is notably reduced. +----------+----------+-----------------------+--------+-------------+------------+-----------+----------------+-------+----------------+---------+-------+ | Workload | Query | File Format | Avg(s) | Base Avg(s) | Delta(Avg) | StdDev(%) | Base StdDev(%) | Iters | Median Diff(%) | MW Zval | Tval | +----------+----------+-----------------------+--------+-------------+------------+-----------+----------------+-------+----------------+---------+-------+ | TPCH(1) | TPCH-Q15 | parquet / none / none | 0.48 | 0.46 | +5.16% | 4.31% | 4.78% | 8 | +3.51% | 2.11 | 2.22 | | TPCH(1) | TPCH-Q17 | parquet / none / none | 1.28 | 1.25 | +1.76% | 1.83% | 1.88% | 8 | +3.53% | 1.34 | 1.88 | | TPCH(1) | TPCH-Q8 | parquet / none / none | 0.77 | 0.75 | +3.11% | 3.88% | 2.75% | 8 | +0.79% | 0.83 | 1.81 | | TPCH(1) | TPCH-Q7 | parquet / none / none | 0.72 | 0.71 | +1.89% | 3.48% | 3.15% | 8 | +1.61% | 0.83 | 1.13 | | TPCH(1) | TPCH-Q22 | parquet / none / none | 0.43 | 0.41 | +3.40% | 1.21% | 6.11% | 8 | +0.05% | 0.45 | 1.54 | | TPCH(1) | TPCH-Q10 | parquet / none / none | 0.74 | 0.73 | +2.04% | 0.75% | 2.57% | 8 | +1.13% | 2.11 | 2.16 | | TPCH(1) | TPCH-Q20 | parquet / none / none | 0.55 | 0.54 | +1.42% | 2.95% | 1.14% | 8 | +0.19% | 0.57 | 1.25 | | TPCH(1) | TPCH-Q11 | parquet / none / none | 0.25 | 0.25 | +0.37% | 2.41% | 3.09% | 8 | +0.82% | 0.45 | 0.27 | | TPCH(1) | TPCH-Q19 | parquet / none / none | 0.62 | 0.61 | +0.92% | 3.17% | 1.53% | 8 | +0.05% | 0.19 | 0.73 | | TPCH(1) | TPCH-Q4 | parquet / none / none | 0.42 | 0.42 | +0.37% | 1.24% | 1.08% | 8 | +0.03% | 0.19 | 0.63 | | TPCH(1) | TPCH-Q5 | parquet / none / none | 0.72 | 0.72 | +0.19% | 3.08% | 3.23% | 8 | +0.07% | 0.57 | 0.12 | | TPCH(1) | TPCH-Q18 | parquet / none / none | 1.20 | 1.19 | +0.04% | 0.12% | 0.15% | 8 | +0.03% | 0.57 | 0.53 | | TPCH(1) | TPCH-Q9 | parquet / none / none | 1.13 | 1.13 | +0.02% | 2.05% | 2.04% | 8 | -0.01% | -0.57 | 0.02 | | TPCH(1) | TPCH-Q3 | parquet / none / none | 0.60 | 0.60 | +0.03% | 3.71% | 3.99% | 8 | -0.04% | -0.06 | 0.01 | | TPCH(1) | TPCH-Q2 | parquet / none / none | 0.44 | 0.44 | -0.70% | 8.56% | 7.42% | 8 | +0.61% | 0.45 | -0.18 | | TPCH(1) | TPCH-Q6 | parquet / none / none | 0.31 | 0.31 | -0.07% | 1.73% | 1.56% | 8 | -0.06% | -1.34 | -0.09 | | TPCH(1) | TPCH-Q14 | parquet / none / none | 0.48 | 0.48 | -0.25% | 1.20% | 1.47% | 8 | -0.09% | -0.57 | -0.37 | | TPCH(1) | TPCH-Q12 | parquet / none / none | 0.54 | 0.54 | -0.86% | 1.90% | 4.48% | 8 | +0.11% | 0.32 | -0.50 | | TPCH(1) | TPCH-Q21 | parquet / none / none | 1.35 | 1.37 | -1.56% | 3.11% | 2.55% | 8 | -0.19% | -0.70 | -1.11 | | TPCH(1) | TPCH-Q16 | parquet / none / none | 0.26 | 0.27 | -1.74% | 9.53% | * 13.61% * | 8 | -0.32% | -0.06 | -0.30 | | TPCH(1) | TPCH-Q1 | parquet / none / none | 0.64 | 0.67 | -4.64% | 1.13% | * 12.59% * | 8 | -0.28% | -0.19 | -1.04 | | TPCH(1) | TPCH-Q13 | parquet / none / none | 0.96 | 0.99 | -3.73% | 2.61% | 1.75% | 8 | -5.08% | -2.62 | -3.44 | +----------+----------+-----------------------+--------+-------------+------------+-----------+----------------+-------+----------------+---------+-------+ We are no longer using ExecutionEngine for caching, so we got rid of the LlvmExecutionEngineWrapper class. Instead, we brought in a new class CodeGenObjectCache to implement llvm::ObjectCache. Testing: Passed LlvmCodeGenCacheTest and custom_cluster/test_codegen_cache.py. Change-Id: Ic3c1b46bb9018ed0320817141785a3bdc41fa677 --- M be/src/codegen/CMakeLists.txt M be/src/codegen/llvm-codegen-cache-test.cc M be/src/codegen/llvm-codegen-cache.cc M be/src/codegen/llvm-codegen-cache.h A be/src/codegen/llvm-codegen-object-cache.cc A be/src/codegen/llvm-codegen-object-cache.h M be/src/codegen/llvm-codegen.cc M be/src/codegen/llvm-codegen.h D be/src/codegen/llvm-execution-engine-wrapper.h M tests/custom_cluster/test_codegen_cache.py 10 files changed, 369 insertions(+), 242 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/33/20733/4 -- To view, visit http://gerrit.cloudera.org:8080/20733 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic3c1b46bb9018ed0320817141785a3bdc41fa677 Gerrit-Change-Number: 20733 Gerrit-PatchSet: 4 Gerrit-Owner: Yida Wu <wydbaggio...@gmail.com> Gerrit-Reviewer: Daniel Becker <daniel.bec...@cloudera.com> Gerrit-Reviewer: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Gerrit-Reviewer: Michael Smith <michael.sm...@cloudera.com> Gerrit-Reviewer: Yida Wu <wydbaggio...@gmail.com>