Skip to content

Commit 8f83771

Browse files
gerashegalovigorpeshansky
authored andcommitted
Reduce packaged native library size (#4881)
## Summary - rely on the static nvCOMP copy already linked into `libcudf.so` - stop packaging and loading the redundant nvCOMP shared libraries - localize symbols from statically linked CUDA compiler and nvCOMP implementation archives with `--exclude-libs` - retain the regular ELF symbol table for stack traces and debugging No GPU architectures are removed. No upstream cuDF change is required. cuDF already selects `nvcomp_static` when `CUDF_BUILD_STATIC_DEPS=FORCE`, as used by this build. This supersedes the previous dependency on rapidsai/cudf#23415. Related to NVIDIA/cudf-spark#15145. ## Size results Focused CUDA 12.9.1 Release builds with `CMAKE_CUDA_ARCHITECTURES=75`: | Variant | Packaged native bytes | ZIP level 6 | | --- | ---: | ---: | | main: static nvCOMP in `libcudf.so` plus packaged `libnvcomp.so` | 754,765,376 B | 389,662,932 B | | this PR: static nvCOMP only in `libcudf.so`, private symbols localized | 693,387,896 B | 354,470,480 B | The focused build reduces packaged native data by 58.53 MiB uncompressed (8.13%) and 33.56 MiB after DEFLATE (9.03%). `libcudfjni.so` is unchanged and omitted from both rows. These measurements use one architecture to make repeated comparisons practical. The implementation does not change the production architecture list. ## Linking and symbol compatibility - the JAR contains `libcudf.so` and `libcudfjni.so`, with no nvCOMP shared-library entries - `libcudf.so` has no nvCOMP `DT_NEEDED` entry - all 12 nvCOMP JNI entry points remain dynamically exported - nvCOMP implementation symbols are absent from `.dynsym` - the regular ELF `.symtab` remains available for diagnostics ## Validation - native CUDA 12.9.1 Release build with `CMAKE_CUDA_ARCHITECTURES=75` - `mvn package -DskipTests` through the normal patch lifecycle - `NativeDepsLoaderTest`: 4 passed - GPU `NvcompTest` LZ4 and Zstd cases: 2 passed - `git diff --check` --------- Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
1 parent 52598d9 commit 8f83771

4 files changed

Lines changed: 30 additions & 8 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/java/src/main/java/ai/rapids/cudf/NativeDepsLoader.java b/java/src/main/java/ai/rapids/cudf/NativeDepsLoader.java
2+
index 0ab9ec79d1..3d42449128 100755
3+
--- a/java/src/main/java/ai/rapids/cudf/NativeDepsLoader.java
4+
+++ b/java/src/main/java/ai/rapids/cudf/NativeDepsLoader.java
5+
@@ -69,9 +69,6 @@ public class NativeDepsLoader {
6+
* subsequent stages are loaded.
7+
*/
8+
private static final String[][] loadOrder = new String[][]{
9+
- new String[]{
10+
- "nvcomp"
11+
- },
12+
new String[]{
13+
"cudf"
14+
},

patches/noop.patch

Whitespace-only changes.

pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,6 @@
570570
<include>libprofilerjni.so</include>
571571
</includes>
572572
</resource>
573-
<resource>
574-
<directory>${libcudfjni.build.path}</directory>
575-
<includes>
576-
<include>libnvcomp.so</include>
577-
<include>libnvcomp_gdeflate.so</include>
578-
<include>libnvcomp_bitcomp.so</include>
579-
</includes>
580-
</resource>
581573
</resources>
582574
</configuration>
583575
</execution>

src/main/cpp/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ option(BUILD_TESTS "Configure CMake to build tests" OFF)
6262
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF)
6363
option(BUILD_FAULTINJ "Configure CMake to build fault injection" ON)
6464
option(BUILD_PROFILER "Configure CMake to build profiler" ON)
65+
option(HIDE_PRIVATE_CUDA_SYMBOLS "Hide private symbols from static CUDA compiler libraries" ON)
6566

6667
message(
6768
VERBOSE "SPARK_RAPIDS_JNI: Build with per-thread default stream:
@@ -70,6 +71,9 @@ message(
7071
message(VERBOSE "SPARK_RAPIDS_JNI: Configure CMake to build tests: ${BUILD_TESTS}")
7172
message(VERBOSE "SPARK_RAPIDS_JNI: Configure CMake to build (nvbench) benchmarks: ${BUILD_BENCHMARKS}")
7273
message(VERBOSE "SPARK_RAPIDS_JNI: Configure CMake to build fault injection: ${BUILD_FAULTINJ}")
74+
message(VERBOSE
75+
"SPARK_RAPIDS_JNI: Hide private static CUDA compiler symbols: ${HIDE_PRIVATE_CUDA_SYMBOLS}"
76+
)
7377

7478
set(SPARK_RAPIDS_JNI_BUILD_TESTS ${BUILD_TESTS})
7579
set(SPARK_RAPIDS_JNI_BUILD_BENCHMARKS ${BUILD_BENCHMARKS})
@@ -349,6 +353,18 @@ target_link_libraries(
349353
${PARQUET_LIB}
350354
${THRIFT_LIB}
351355
)
356+
if(HIDE_PRIVATE_CUDA_SYMBOLS)
357+
# These toolkit implementation symbols are not part of the cuDF or JNI ABI. Localizing them keeps
358+
# the regular ELF symbol table for diagnostics while removing them from the dynamic export table.
359+
target_link_options(
360+
spark_rapids_jni
361+
PRIVATE "LINKER:--exclude-libs,libnvrtc_static.a"
362+
"LINKER:--exclude-libs,libnvrtc-builtins_static.a"
363+
"LINKER:--exclude-libs,libnvptxcompiler_static.a"
364+
"LINKER:--exclude-libs,libnvJitLink_static.a"
365+
"LINKER:--exclude-libs,libnvcomp_static.a"
366+
)
367+
endif()
352368
rapids_cuda_set_runtime(spark_rapids_jni USE_STATIC ON)
353369
set_target_properties(spark_rapids_jni PROPERTIES LINK_LANGUAGE "CXX")
354370
# For backwards-compatibility with the cudf Java bindings and RAPIDS accelerated UDFs,

0 commit comments

Comments
 (0)