Skip to content

[VL] Avoid PLT overhead for intra-library calls in libgluten and libvelox - #13819

Open
zhulipeng wants to merge 1 commit into
apache:mainfrom
zhulipeng:bsymbolic-functions
Open

zhulipeng wants to merge 1 commit into
apache:mainfrom
zhulipeng:bsymbolic-functions

Conversation

@zhulipeng

@zhulipeng zhulipeng commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

libvelox.so and libgluten.so are not linked with -Bsymbolic, so calls between exported functions in the same library go through PLT stubs (an extra indirect jump each). Hot small functions like snappy::MemCopy64 and DecodedVector::isNullAt make these stubs 2.0–2.4% of all cycles on TPC-H / TPC-DS.

How was this patch tested?

TPC-H / TPC-DS SF300 (snappy Parquet) on an Intel Xeon 6960P, 3 executors × 4 cores. Each build ran 3 times, interleaved with the baseline; numbers are the mean.

Benchmark Total
TPC-H (22 queries) -3.6%
TPC-DS (103 queries) -3.3%

Query results match the baseline.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)

Copilot AI balanced review requested due to automatic review settings November 27, 2026 03:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Global ELF function-binding changes require runtime compatibility validation for JNI, native UDF plugins, Bolt, and vcpkg/non-vcpkg builds that query benchmarks and mostly object-linked native tests do not provide.

No open issues 🎉

What changed in this PR

Optimizes Gluten’s native core and Velox backend by reducing indirect-call overhead within their shared libraries on non-Darwin platforms.

Changes:

  • Adds -Wl,-Bsymbolic-functions to the gluten and velox shared-library targets.
  • Preserves normal data-symbol binding and leaves Darwin linking unchanged.
File Description
cpp/​velox/​CMakeLists.txt Enables local function binding within libvelox.
cpp/​core/​CMakeLists.txt Enables local function binding within libgluten, including statically linked dependencies.

Review effort: Balanced

@zhulipeng
zhulipeng force-pushed the bsymbolic-functions branch 2 times, most recently from 90f4040 to 0064fba Compare November 27, 2026 03:15
@zhulipeng zhulipeng changed the title [VL] Link libgluten and libvelox with -Bsymbolic-functions [VL] Avoid PLT overhead for intra-library calls in libgluten and libvelox Nov 27, 2026
Copilot AI balanced review requested due to automatic review settings November 27, 2026 03:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Broad ELF binding changes affect native ABI and UDF-plugin compatibility in both dependency configurations, while benchmarks and most native tests leave shared-library integration validation needing human confirmation.

No open issues 🎉

Review effort: Balanced

…elox

libvelox.so exports every facebook::velox::* and gluten::* symbol
(about 120K dynamic symbols) and libgluten.so exports the statically
linked dependencies such as snappy. Neither library is linked with
-Bsymbolic, so a call from one function in the library to another
exported, non-inlined function in the same library goes through a PLT
stub, for example snappy::MemCopy64@plt, snappy::DeferMemCopy@plt and
DecodedVector::isNullAt@plt. On TPC-H and TPC-DS these stubs take 2.0-2.4%
of all cycles.

Link both libraries with -Wl,-Bsymbolic-functions. It binds function
references inside the library at link time and leaves data symbols (static
locals, STB_GNU_UNIQUE objects) with their normal binding, so the
libstdc++ isolation that libgluten relies on is not affected. The JUMP_SLOT
relocations drop from 29342 to 929 in libvelox.so and from 7408 to 247 in
libgluten.so.

Co-Authored-By: hu hengrui <hengrui.hu@intel.com>
Co-Authored-By: Wangyang Guo <wangyang.guo@intel.com>
@zhulipeng

Copy link
Copy Markdown
Contributor Author

cc @jackylee-ch @philo-he @zhztheplayer @zhouyuan, could you help review? This sits next to the libstdc++ isolation from #12557, and only changes function binding (data symbols, including STB_GNU_UNIQUE statics, are unchanged).

@philo-he philo-he 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.

LGTM, thanks!

I also checked whether this affects using jemalloc via LD_PRELOAD. It doesn't: -Bsymbolic-functions only binds calls to functions defined inside the same library, and malloc/free come from libc, so they still resolve to the preloaded jemalloc.

@zhztheplayer

zhztheplayer commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

I planned to add LTO / PGO to Gluten as well but was unaware of this improvement, numbers are promising but would be nice if larger data set can be tested, e.g., SF 1000 or higher

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants