Skip to content

[chore](thirdparty) introduce thridparty about lance-c - #65304

Merged
zhangstar333 merged 2 commits into
apache:masterfrom
zhangstar333:rust_thridpaty
Jul 17, 2026
Merged

[chore](thirdparty) introduce thridparty about lance-c#65304
zhangstar333 merged 2 commits into
apache:masterfrom
zhangstar333:rust_thridpaty

Conversation

@zhangstar333

@zhangstar333 zhangstar333 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

introduce thridparty about lance-c https://github.com/lance-format/lance-c

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

Gabriel39
Gabriel39 previously approved these changes Jul 7, 2026
@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@zhangstar333

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot 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.

I found several blocking build/distribution issues in this third-party integration.

Checkpoint conclusions:

  • Goal: add lance-c as a Doris third-party dependency. The source-build path installs the expected lib/header when the right toolchain and network are available, but the PR does not fully satisfy Doris' third-party reproducibility and distribution requirements.
  • Scope/focus: the code changes are narrow, but some parallel build-image and prebuilt-thirdparty paths were not updated.
  • Concurrency/lifecycle/config/storage/transaction/FE-BE protocol: not applicable; this PR only changes third-party build and license metadata.
  • Compatibility/parallel paths: issues were found in offline/mirrored source builds, stale prebuilt third-party acceptance, and ARM/legacy GCC Docker image paths.
  • Testing/validation: no builds/tests were run in this review-only runner. Static review found missing coverage that CI may not catch until the affected source-build/image paths run.
  • User focus: no additional user-provided review focus was present.

After three review rounds, all subagents converged with no additional valuable findings beyond the inline comments below.

Comment thread dist/licenses/LICENSE-lance-c-rust-crates.txt
Comment thread thirdparty/build-thirdparty.sh
Comment thread be/cmake/thirdparty.cmake Outdated
Comment thread thirdparty/build-thirdparty.sh
@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions github-actions Bot removed the approved Indicates a PR has been approved by one committer. label Jul 15, 2026
@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@zhangstar333

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot 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.

Request changes: the Lance-C integration still has three blocking build/distribution issues.

Blocking findings:

  • The new global -lm ordering bypasses Doris's default Linux glibc-compatibility interposition.
  • The non-Darwin -std=gnu17 CFLAGS breaks the intended GCC 7.3 third-party path even after Cargo is provisioned.
  • Required Apache DataFusion and Apache Arrow Object Store NOTICE attributions are absent from the packaged NOTICE material.

Checkpoint conclusions:

  • Goal and proof: the patch downloads, source-builds, installs, links, and inventories Lance-C 0.1.2. The source checksum matched, both changed shell files parsed, and the hosted Linux, macOS, and macOS-arm64 third-party source-build checks passed. There is still no Doris consumer-link test, post-Cargo GCC 7 coverage, or target-complete license/NOTICE validation.
  • Scope and minimality: the six changed files are the expected build/link/license surfaces, but the unconditional global m is not a safe focused integration. Existing discussions already cover target-specific license closure/texts, offline Cargo dependencies, stale prebuilts, and missing Cargo in ARM/legacy builders; those issues were not duplicated here.
  • Compatibility and parallel paths: default and explicit builds, prebuilts, Linux/macOS, x86/ARM, legacy/current GCC, cleanup, stripping, product packaging, and license/NOTICE paths were checked. The concrete additional failures are the Linux old-glibc link ordering and GCC 7 native-C flag issues described inline. No storage, protocol, or function-format compatibility change applies.
  • Concurrency, lifecycle, runtime configuration, transactions, persistence, data writes, and FE/BE variable propagation: not applicable to these CMake/shell/license-only changes.
  • Error handling and observability: Cargo/protoc/version checks fail loudly and build command output is sufficient for this build-time path; no runtime logging or metrics surface is introduced.
  • Performance: making Lance-C a default dependency adds substantial source-build time and archive size, but the available jobs completed and no separate correctness threshold was demonstrated.
  • Validation limits: no local build or unit test was run because the review contract prohibits builds and this checkout lacks thirdparty/installed and its protoc. The macOS BE UT check failed during unrelated JDK 25 versus required JDK 17 setup; TeamCity COMPILE and BE UT were still pending at submission.
  • User focus: no additional user-provided review focus was present.

After the final maximum-round review, all three subagents returned NO_NEW_VALUABLE_FINDINGS for this exact three-comment set.

Comment thread be/cmake/thirdparty.cmake
# liblance_c.a contains compiler_builtins cbrt symbols. Place libm before it
# so the final linker resolves C math symbols from the system library first.
add_thirdparty(lance_c LIB64 NOTADD)
list(APPEND COMMON_THIRDPARTY m lance_c)

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.

COMMON_THIRDPARTY is linked before glibc-compatibility, so adding bare m here puts system -lm ahead of the compatibility archive on every default Linux link. That contradicts the explicit ordering invariant in be/CMakeLists.txt requiring glibc-compatibility before -lc -lm: existing Doris pow/log/exp references can now be satisfied by the build host's libm before the corresponding compatibility objects are extracted, reintroducing newer libm symbol versions into binaries intended for older glibc. Please keep every -lm after the compatibility targets and solve Lance's compiler-builtins collision without changing the global system-library order.

fi

if [[ "${KERNEL}" != 'Darwin' ]]; then
cargo_env+=("CFLAGS=${CFLAGS:-} -std=gnu17")

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.

This CFLAGS value is consumed by cc-rs native dependencies; the locked lz4-sys crate, for example, compiles four C sources through cc::Build. The GCC 7 builder installs GCC 7.3 and now default-builds Lance-C, but GCC documents -std=gnu17 as a new option in GCC 8, so that path still fails after Rust/Cargo is provisioned (the separate issue already raised in discussion r3578107999). Please gate this flag by compiler support, use a compatible C mode, or select a newer C compiler for Lance-C, and cover the intended legacy-toolchain build.

Comment thread dist/LICENSE-dist.txt
* opentelemetry-proto: 0.18.0
* opentelemetry-cpp: 1.4.0
* clucene: 2.4.6
* lance-c: 0.1.2

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.

The new static archive includes Apache DataFusion 52.4.0 and Apache Arrow Object Store 0.12.5 (both are present in the locked inventory), and each published crate carries a NOTICE.txt attribution. Apache-2.0 section 4(d) requires those relevant attributions to accompany redistributed derivatives, but neither NOTICE.txt nor dist/NOTICE-dist.txt mentions either project; build.sh packages the former with Doris binaries. Please add these NOTICE entries and audit the remaining locked crates for any additional NOTICE files before distributing liblance_c.a.

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.52% (29885/40650)
Line Coverage 57.27% (325384/568154)
Region Coverage 53.71% (270983/504487)
Branch Coverage 54.62% (119442/218695)

@zhangstar333
zhangstar333 merged commit 4df43e9 into apache:master Jul 17, 2026
32 of 33 checks passed
@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jul 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

github-actions Bot pushed a commit that referenced this pull request Jul 30, 2026
yiguolei pushed a commit that referenced this pull request Jul 31, 2026
…5304 (#66304)

Cherry-picked from #65304

Co-authored-by: zhangstar333 <zhangsida@selectdb.com>
wyxxxcat pushed a commit to wyxxxcat/doris that referenced this pull request Aug 17, 2026
HappenLee pushed a commit that referenced this pull request Sep 2, 2026
)

Problem Summary:

PR #65304 added the following libraries to `COMMON_THIRDPARTY`:

```cmake
list(APPEND COMMON_THIRDPARTY m lance_c)
```

As a result, some math symbols are resolved by the system `libm` before
the linker scans Doris' optimized compatibility implementations, causing
a noticeable performance regression for functions such as `exp`, `log`,
and `pow`:

- exp: approximately 220%
- ln: approximately 167%
- log: approximately 197%
- log2: approximately 165%

Simply moving `-lm` and `lance_c` after `glibc-compatibility` exposes
another issue. Once Lance is actually referenced, `liblance_c.a` pulls
in Rust std objects containing late unresolved references to:

- `posix_spawnp`
- `posix_spawn_file_actions_init`
- `posix_spawn_file_actions_destroy`
- `posix_spawn_file_actions_adddup2`
- `preadv`
- `splice`

The LDB toolchain resolves these references by extracting its monolithic
`glibc-compatibility.c.o`, which also defines `getrandom`. This
conflicts with Doris' explicitly linked `getrandom.c.o` and causes a
duplicate-symbol error.

#### Solution

1. Restore the required link order
For `GLIBC_COMPATIBILITY=ON`, use the following order:
```text
glibc-compatibility-explicit
→ glibc-compatibility
→ -lm
→ lance_c
```
This ordering ensures that:
- Doris' optimized math implementations are scanned before `-lm`.
- `-lm` is scanned before `lance_c`, preventing Rust compiler_builtins
symbols such as cbrt from being selected.
- `lance_c` remains available to its consumers.

2. Resolve the late Lance/Rust libc references
Add a small set of hidden symbol-version adapters for the six strong
libc references introduced by the Rust std object.
Each adapter has two parts. For example, the `splice` adapter is
conceptually:
```c
extern __typeof__(splice) __doris_old_splice;

__asm__(
    ".symver __doris_old_splice,"
    "splice@GLIBC_2.5"
);

__attribute__((visibility("hidden")))
ssize_t splice(...) {
    return __doris_old_splice(...);
}
```
The hidden `splice` wrapper is included in the
`glibc-compatibility-explicit` OBJECT target, so its symbol is visible
to the linker before `liblance_c.a` is processed.


#### performance
```text
Doris> select count(exp(db)) from double_ranges;
+----------------+
| count(exp(db)) |
+----------------+
|       50000000 |
+----------------+
1 row in set (0.980 sec)

Doris> select count(exp(db)) from double_ranges;
+----------------+
| count(exp(db)) |
+----------------+
|       50000000 |
+----------------+
1 row in set (0.347 sec)


Doris> select count(ln(db)), count(ln(in_one)) from double_ranges;
+---------------+-------------------+
| count(ln(db)) | count(ln(in_one)) |
+---------------+-------------------+
|      50000000 |          50000000 |
+---------------+-------------------+
1 row in set (1.486 sec)

Doris> select count(ln(db)), count(ln(in_one)) from double_ranges;
+---------------+-------------------+
| count(ln(db)) | count(ln(in_one)) |
+---------------+-------------------+
|      50000000 |          50000000 |
+---------------+-------------------+
1 row in set (0.607 sec)


Doris> select count(log(db, db)), count(log(in_one, db)), count(log(db, in_one)), count(log(db, in_ten)) from double_ranges;
+--------------------+------------------------+------------------------+------------------------+
| count(log(db, db)) | count(log(in_one, db)) | count(log(db, in_one)) | count(log(db, in_ten)) |
+--------------------+------------------------+------------------------+------------------------+
|           50000000 |               49999990 |               50000000 |               50000000 |
+--------------------+------------------------+------------------------+------------------------+
1 row in set (5.944 sec)

Doris> select count(log(db, db)), count(log(in_one, db)), count(log(db, in_one)), count(log(db, in_ten)) from double_ranges;
+--------------------+------------------------+------------------------+------------------------+
| count(log(db, db)) | count(log(in_one, db)) | count(log(db, in_one)) | count(log(db, in_ten)) |
+--------------------+------------------------+------------------------+------------------------+
|           50000000 |               49999990 |               50000000 |               50000000 |
+--------------------+------------------------+------------------------+------------------------+
1 row in set (2.356 sec)


Doris> select count(log2(db)), count(log2(in_one)) from double_ranges;
+-----------------+---------------------+
| count(log2(db)) | count(log2(in_one)) |
+-----------------+---------------------+
|        50000000 |            50000000 |
+-----------------+---------------------+
1 row in set (1.616 sec)

Doris> select count(log2(db)), count(log2(in_one)) from double_ranges;
+-----------------+---------------------+
| count(log2(db)) | count(log2(in_one)) |
+-----------------+---------------------+
|        50000000 |            50000000 |
+-----------------+---------------------+
1 row in set (0.655 sec)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.1.4-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants