Skip to content

Conversation

raulcd
Copy link
Member

@raulcd raulcd commented Oct 7, 2025

Rationale for this change

Experimentation in #47637 suggested that enabling inter-procedural optimization (IPO) could not only improve performance in some workloads, but also reduce the code size of Arrow libraries.

There's around 2% size reduction on the tested examples:

wheel size
last successful nightly wheel-manylinux-2-28-cp312-cp312-arm64 44605918 bytes
with change wheel-manylinux-2-28-cp312-cp312-arm64 43807946 bytes
last successful nightly wheel-windows-cp311-cp311-amd64 28093080 bytes
with change wheel-windows-cp311-cp311-amd64 27391407 bytes

What changes are included in this PR?

Add -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON to Arrow C++ and wheels for both manylinux and windows.

Are these changes tested?

Yes via CI

Are there any user-facing changes?

No

Copy link

github-actions bot commented Oct 7, 2025

⚠️ GitHub issue #47643 has been automatically assigned in GitHub to PR creator.

@github-actions github-actions bot added the awaiting committer review Awaiting committer review label Oct 7, 2025
@raulcd
Copy link
Member Author

raulcd commented Oct 7, 2025

@github-actions crossbow submit wheel-musllinux-1-2-cp313-cp313-amd64 wheel-manylinux-2-28-cp312-cp312-arm64 wheel-windows-cp311-cp311-amd64

Copy link

github-actions bot commented Oct 7, 2025

Revision: 57a1587

Submitted crossbow builds: ursacomputing/crossbow @ actions-cf593156e6

Task Status
wheel-manylinux-2-28-cp312-cp312-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions
wheel-windows-cp311-cp311-amd64 GitHub Actions

@raulcd
Copy link
Member Author

raulcd commented Oct 7, 2025

@github-actions crossbow submit -g wheel

Copy link

github-actions bot commented Oct 7, 2025

Revision: 57a1587

Submitted crossbow builds: ursacomputing/crossbow @ actions-5510c5761f

Task Status
python-sdist GitHub Actions
wheel-macos-monterey-cp310-cp310-amd64 GitHub Actions
wheel-macos-monterey-cp310-cp310-arm64 GitHub Actions
wheel-macos-monterey-cp311-cp311-amd64 GitHub Actions
wheel-macos-monterey-cp311-cp311-arm64 GitHub Actions
wheel-macos-monterey-cp312-cp312-amd64 GitHub Actions
wheel-macos-monterey-cp312-cp312-arm64 GitHub Actions
wheel-macos-monterey-cp313-cp313-amd64 GitHub Actions
wheel-macos-monterey-cp313-cp313-arm64 GitHub Actions
wheel-macos-monterey-cp313-cp313t-amd64 GitHub Actions
wheel-macos-monterey-cp313-cp313t-arm64 GitHub Actions
wheel-manylinux-2-28-cp310-cp310-amd64 GitHub Actions
wheel-manylinux-2-28-cp310-cp310-arm64 GitHub Actions
wheel-manylinux-2-28-cp311-cp311-amd64 GitHub Actions
wheel-manylinux-2-28-cp311-cp311-arm64 GitHub Actions
wheel-manylinux-2-28-cp312-cp312-amd64 GitHub Actions
wheel-manylinux-2-28-cp312-cp312-arm64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-amd64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-arm64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313t-amd64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313t-arm64 GitHub Actions
wheel-musllinux-1-2-cp310-cp310-amd64 GitHub Actions
wheel-musllinux-1-2-cp310-cp310-arm64 GitHub Actions
wheel-musllinux-1-2-cp311-cp311-amd64 GitHub Actions
wheel-musllinux-1-2-cp311-cp311-arm64 GitHub Actions
wheel-musllinux-1-2-cp312-cp312-amd64 GitHub Actions
wheel-musllinux-1-2-cp312-cp312-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313t-amd64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313t-arm64 GitHub Actions
wheel-windows-cp310-cp310-amd64 GitHub Actions
wheel-windows-cp311-cp311-amd64 GitHub Actions
wheel-windows-cp312-cp312-amd64 GitHub Actions
wheel-windows-cp313-cp313-amd64 GitHub Actions
wheel-windows-cp313-cp313t-amd64 GitHub Actions

@raulcd
Copy link
Member Author

raulcd commented Oct 7, 2025

It seems we are getting ODR violations on musllinux when we enable CMAKE_INTERPROCEDURAL_OPTIMIZATION:

ninja: job failed: : && /usr/bin/c++ -fPIC -Wno-noexcept-type -Wno-self-move -Wno-subobject-linkage  -fdiagnostics-color=always  -Wall -fno-semantic-interposition -msse4.2  -O3 -DNDEBUG -O2 -ftree-vectorize  -flto=auto -fno-fat-lto-objects  -Wl,--version-script=/arrow/cpp/src/arrow/symbols.map -shared -Wl,-soname,libarrow.so.2200 -o release/libarrow.so.2200.0.0 src/arrow/CMakeFiles/arrow_objlib.dir/Unity/unity_3_cxx.cxx.o src/arrow/CMakeFiles/arrow_objlib.dir/Unity/unity_2_cxx.cxx.o src/arrow/CMakeFiles/arrow_objlib.dir/Unity/unity_1_cxx.cxx.o src/arrow/CMakeFiles/arrow_objlib.dir/Unity/unity_0_cxx.cxx.o src/arrow/CMakeFiles/arrow_array.dir/Unity/unity_2_cxx.cxx.o src/arrow/CMakeFiles/arrow_array.dir/Unity/unity_1_cxx.cxx.o src/arrow/CMakeFiles/arrow_array.dir/Unity/unity_0_cxx.cxx.o src/arrow/CMakeFiles/arrow_compute_core.dir/Unity/unity_3_cxx.cxx.o src/arrow/CMakeFiles/arrow_compute_core.dir/Unity/unity_2_cxx.cxx.o src/arrow/CMakeFiles/arrow_compute_core.dir/Unity/unity_1_cxx.cxx.o src/arrow/CMakeFiles/arro
/arrow/cpp/src/arrow/io/concurrency.h:162: warning: virtual table of type 'struct RandomAccessFileConcurrencyWrapper' violates one definition rule [-Wodr]
ninja: subcommand failed
  162 | class RandomAccessFileConcurrencyWrapper : public RandomAccessFile {
      | 
/arrow/cpp/src/arrow/io/concurrency.h:162:7: note: the conflicting type defined in another translation unit
  162 | class RandomAccessFileConcurrencyWrapper : public RandomAccessFile {
      |       ^
/arrow/cpp/src/arrow/io/interfaces.cc:108: note: virtual method 'io_context'
  108 | const IOContext& Readable::io_context() const { return default_io_context(); }
      | 
<built-in>: note: ought to match virtual method '__cxa_pure_virtual' but does not
/arrow/cpp/src/arrow/array/builder_nested.h:46:7: warning: virtual table of type 'struct VarLengthListLikeBuilder' violates one definition rule [-Wodr]
   46 | class VarLengthListLikeBuilder : public ArrayBuilder {
      |       ^
/arrow/cpp/src/arrow/array/builder_nested.h:46:7: note: the conflicting type defined in another translation unit
   46 | class VarLengthListLikeBuilder : public ArrayBuilder {
      |       ^
/arrow/cpp/src/arrow/array/builder_nested.h:241:16: note: virtual method 'UnsafeAppendEmptyDimensions'
  241 |   virtual void UnsafeAppendEmptyDimensions(int64_t num_values) {
      |                ^
<built-in>: note: ought to match virtual method '__cxa_pure_virtual' but does not
/arrow/cpp/src/arrow/array/builder_nested.h:46:7: warning: virtual table of type 'struct VarLengthListLikeBuilder' violates one definition rule [-Wodr]
   46 | class VarLengthListLikeBuilder : public ArrayBuilder {
      |       ^
/arrow/cpp/src/arrow/array/builder_nested.h:46:7: note: the conflicting type defined in another translation unit
   46 | class VarLengthListLikeBuilder : public ArrayBuilder {
      |       ^
/arrow/cpp/src/arrow/array/builder_nested.h:241:16: note: virtual method 'UnsafeAppendEmptyDimensions'
  241 |   virtual void UnsafeAppendEmptyDimensions(int64_t num_values) {
      |                ^
<built-in>: note: ought to match virtual method '__cxa_pure_virtual' but does not
/arrow/cpp/src/arrow/array/builder_nested.h:46:7: warning: virtual table of type 'struct VarLengthListLikeBuilder' violates one definition rule [-Wodr]
   46 | class VarLengthListLikeBuilder : public ArrayBuilder {
      |       ^
/arrow/cpp/src/arrow/array/builder_nested.h:46:7: note: the conflicting type defined in another translation unit
   46 | class VarLengthListLikeBuilder : public ArrayBuilder {
      |       ^
/arrow/cpp/src/arrow/array/builder_nested.h:241:16: note: virtual method 'UnsafeAppendEmptyDimensions'
  241 |   virtual void UnsafeAppendEmptyDimensions(int64_t num_values) {
      |                ^
<built-in>: note: ought to match virtual method '__cxa_pure_virtual' but does not
/arrow/cpp/src/arrow/array/builder_nested.h:46:7: warning: virtual table of type 'struct VarLengthListLikeBuilder' violates one definition rule [-Wodr]
   46 | class VarLengthListLikeBuilder : public ArrayBuilder {
      |       ^
/arrow/cpp/src/arrow/array/builder_nested.h:46:7: note: the conflicting type defined in another translation unit
   46 | class VarLengthListLikeBuilder : public ArrayBuilder {
      |       ^
/arrow/cpp/src/arrow/array/builder_nested.h:241:16: note: virtual method 'UnsafeAppendEmptyDimensions'
  241 |   virtual void UnsafeAppendEmptyDimensions(int64_t num_values) {
      |                ^
<built-in>: note: ought to match virtual method '__cxa_pure_virtual' but does not
/usr/include/fortify/stdio.h: In function '__to_xstring.constprop':
/usr/include/fortify/stdio.h:73:28: error: inlining failed in call to 'always_inline' 'vsnprintf': function body can be overwritten at link time
   73 | _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
      |                            ^
/usr/include/c++/13.2.1/ext/string_conversions.h:113:32: note: called from here
  113 |       const int __len = __convf(__s, __n, __fmt, __args);
      |                                ^
make: *** [/tmp/ccICEbbk.mk:362: /tmp/ccGClDbC.ltrans120.ltrans.o] Error 1
make: *** Waiting for unfinished jobs....
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: error: lto-wrapper failed

@raulcd
Copy link
Member Author

raulcd commented Oct 7, 2025

@pitrou should I just disable CMAKE_INTERPROCEDURAL_OPTIMIZATION for musllinux?

@pitrou
Copy link
Member

pitrou commented Oct 7, 2025

Oh, yes, please do :)

@raulcd
Copy link
Member Author

raulcd commented Oct 7, 2025

@github-actions crossbow submit wheel-musllinux-1-2-cp313-cp313-amd64 wheel-manylinux-2-28-cp312-cp312-arm64

Copy link

github-actions bot commented Oct 7, 2025

Revision: df0b2d9

Submitted crossbow builds: ursacomputing/crossbow @ actions-68709fa7c8

Task Status
wheel-manylinux-2-28-cp312-cp312-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions

-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=/tmp/arrow-dist \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=${CMAKE_INTERPROCEDURAL_OPTIMIZATION} \
Copy link
Member

Choose a reason for hiding this comment

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

This is for C++, but can we also try passing it for Python using PYARROW_CMAKE_OPTIONS?

Copy link
Member Author

Choose a reason for hiding this comment

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

that makes sense, let me have all Arrow C++ builds with it correctly and I will try to add it to pyarrow afterwards

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Oct 7, 2025
@raulcd
Copy link
Member Author

raulcd commented Oct 7, 2025

@github-actions crossbow submit wheel-musllinux-1-2-cp313-cp313-amd64 wheel-manylinux-2-28-cp312-cp312-arm64

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 7, 2025
Copy link

github-actions bot commented Oct 7, 2025

Revision: 4be6dc5

Submitted crossbow builds: ursacomputing/crossbow @ actions-3b75f5b645

Task Status
wheel-manylinux-2-28-cp312-cp312-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions

@raulcd
Copy link
Member Author

raulcd commented Oct 7, 2025

@github-actions crossbow submit wheel-musllinux-1-2-cp313-cp313-amd64 wheel-manylinux-2-28-cp312-cp312-arm64 wheel-windows-cp311-cp311-amd64

Copy link

github-actions bot commented Oct 7, 2025

Revision: 5b14294

Submitted crossbow builds: ursacomputing/crossbow @ actions-df10b76e78

Task Status
wheel-manylinux-2-28-cp312-cp312-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions
wheel-windows-cp311-cp311-amd64 GitHub Actions

@raulcd
Copy link
Member Author

raulcd commented Oct 7, 2025

Some examples of wheel sizes after the change, there's around 2% size reduction on the tested examples:

wheel size
last successful nightly wheel-manylinux-2-28-cp312-cp312-arm64 44605918 bytes
with change wheel-manylinux-2-28-cp312-cp312-arm64 43807946 bytes
last successful nightly wheel-windows-cp311-cp311-amd64 28093080 bytes
with change wheel-windows-cp311-cp311-amd64 27391407 bytes

@pitrou is this in-line with what you were expecting from your earlier tests?

@raulcd
Copy link
Member Author

raulcd commented Oct 8, 2025

@github-actions crossbow -g wheel

Copy link

github-actions bot commented Oct 8, 2025

No such option: -g
The Archery job run can be found at: https://github.com/apache/arrow/actions/runs/18339520949

@raulcd
Copy link
Member Author

raulcd commented Oct 8, 2025

@github-actions crossbow submit -g wheel

Copy link

github-actions bot commented Oct 8, 2025

Revision: 5b14294

Submitted crossbow builds: ursacomputing/crossbow @ actions-ac76853b88

Task Status
python-sdist GitHub Actions
wheel-macos-monterey-cp310-cp310-amd64 GitHub Actions
wheel-macos-monterey-cp310-cp310-arm64 GitHub Actions
wheel-macos-monterey-cp311-cp311-amd64 GitHub Actions
wheel-macos-monterey-cp311-cp311-arm64 GitHub Actions
wheel-macos-monterey-cp312-cp312-amd64 GitHub Actions
wheel-macos-monterey-cp312-cp312-arm64 GitHub Actions
wheel-macos-monterey-cp313-cp313-amd64 GitHub Actions
wheel-macos-monterey-cp313-cp313-arm64 GitHub Actions
wheel-macos-monterey-cp313-cp313t-amd64 GitHub Actions
wheel-macos-monterey-cp313-cp313t-arm64 GitHub Actions
wheel-manylinux-2-28-cp310-cp310-amd64 GitHub Actions
wheel-manylinux-2-28-cp310-cp310-arm64 GitHub Actions
wheel-manylinux-2-28-cp311-cp311-amd64 GitHub Actions
wheel-manylinux-2-28-cp311-cp311-arm64 GitHub Actions
wheel-manylinux-2-28-cp312-cp312-amd64 GitHub Actions
wheel-manylinux-2-28-cp312-cp312-arm64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-amd64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-arm64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313t-amd64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313t-arm64 GitHub Actions
wheel-musllinux-1-2-cp310-cp310-amd64 GitHub Actions
wheel-musllinux-1-2-cp310-cp310-arm64 GitHub Actions
wheel-musllinux-1-2-cp311-cp311-amd64 GitHub Actions
wheel-musllinux-1-2-cp311-cp311-arm64 GitHub Actions
wheel-musllinux-1-2-cp312-cp312-amd64 GitHub Actions
wheel-musllinux-1-2-cp312-cp312-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313t-amd64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313t-arm64 GitHub Actions
wheel-windows-cp310-cp310-amd64 GitHub Actions
wheel-windows-cp311-cp311-amd64 GitHub Actions
wheel-windows-cp312-cp312-amd64 GitHub Actions
wheel-windows-cp313-cp313-amd64 GitHub Actions
wheel-windows-cp313-cp313t-amd64 GitHub Actions

@raulcd raulcd marked this pull request as ready for review October 8, 2025 10:10
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Oct 9, 2025
@raulcd raulcd requested a review from pitrou October 10, 2025 09:06
@pitrou
Copy link
Member

pitrou commented Oct 10, 2025

@raulcd Did you update the numbers in the PR description?

@raulcd
Copy link
Member Author

raulcd commented Oct 10, 2025

@raulcd Did you update the numbers in the PR description?

No since I posted them originally. I downloaded the built artifact on the job (wheel.zip) and unzipped to compare, why?

@pitrou
Copy link
Member

pitrou commented Oct 10, 2025

Ah, that was already after you changed PYARROW_CMAKE_OPTIONS, right?

@raulcd
Copy link
Member Author

raulcd commented Oct 10, 2025

Yes, that's with the current changes

@raulcd raulcd merged commit 771e14b into apache:main Oct 13, 2025
19 checks passed
@raulcd raulcd removed the awaiting merge Awaiting merge label Oct 13, 2025
@raulcd raulcd deleted the GH-47643 branch October 13, 2025 07:14
Copy link

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 771e14b.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 3 possible false positives for unstable benchmarks that are known to sometimes produce them.

zanmato1984 pushed a commit to zanmato1984/arrow that referenced this pull request Oct 15, 2025
…MIZATION for wheels (apache#47733)

### Rationale for this change

Experimentation in apache#47637 suggested that [enabling inter-procedural optimization (IPO)](https://cmake.org/cmake/help/latest/variable/CMAKE_INTERPROCEDURAL_OPTIMIZATION.html) could not only improve performance in some workloads, but also reduce the code size of Arrow libraries.

There's around 2% size reduction on the tested examples:

|wheel|size|
|---------|--------|
|last successful nightly `wheel-manylinux-2-28-cp312-cp312-arm64` | 44605918 bytes|
|with change `wheel-manylinux-2-28-cp312-cp312-arm64` | 43807946 bytes|
|last successful nightly `wheel-windows-cp311-cp311-amd64` | 28093080 bytes|
|with change `wheel-windows-cp311-cp311-amd64` | 27391407 bytes|

### What changes are included in this PR?

Add `-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON`  to Arrow C++ and wheels for both manylinux and windows. 

### Are these changes tested?

Yes via CI

### Are there any user-facing changes?

No

* GitHub Issue: apache#47643

Authored-by: Raúl Cumplido <[email protected]>
Signed-off-by: Raúl Cumplido <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants