Skip to content

[fix](build) prevent math regression from global lance-c linkage - #67237

Open
linrrzqqq wants to merge 1 commit into
apache:masterfrom
linrrzqqq:opt-math-regression
Open

[fix](build) prevent math regression from global lance-c linkage#67237
linrrzqqq wants to merge 1 commit into
apache:masterfrom
linrrzqqq:opt-math-regression

Conversation

@linrrzqqq

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #65304

Problem Summary:

PR #65304 added the following libraries to COMMON_THIRDPARTY:

list(APPEND COMMON_THIRDPARTY m lance_c)

This unconditionally added an early -lm to the BE link command, before Doris's own glibc-compatibility library.
In the current toolchain, libm.so is a GNU ld script:GROUP ( ./libglibc-compatibility.a ../../lib/libm.so.6 )

As a result, the early -lm resolves exp, log, and log2 from the toolchain's compatibility archive before Doris's optimized compatibility implementations are considered. This causes significant performance regressions in arithmetic benchmarks:

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

In this pr, remove the unconditional addition of m and lance_c to COMMON_THIRDPARTY, and the imported lance_c target is retained, so future Lance consumers can link it explicitly through target_link_libraries() when the corresponding feature is enabled.

This keeps the existing glibc-compatibility link ordering unchanged and avoids
affecting unrelated BE targets.

performance

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)

@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?

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.

2 participants