Skip to content

branch-4.1: [fix](function) avoid ICU default-locale contention #66440 - #67071

Merged
yiguolei merged 1 commit into
branch-4.1from
auto-pick-66440-branch-4.1
Aug 25, 2026
Merged

branch-4.1: [fix](function) avoid ICU default-locale contention #66440#67071
yiguolei merged 1 commit into
branch-4.1from
auto-pick-66440-branch-4.1

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Cherry-picked from #66440

### What problem does this PR solve?
Issue Number: close#66439
Problem Summary: ICU's `UnicodeString::toLower()` / `toUpper()` with no
explicit
Locale argument internally calls `locale_get_default_69()`, which
acquires a global
mutex. Under concurrent multi-threaded LOWER/UPPER/INITCAP evaluation on
UTF-8 data
(e.g. a 20 TB Hudi scan with `lower(event_id) LIKE '%pattern%'`
predicates), this
mutex becomes a severe CPU bottleneck — flame graphs show 82% of CPU
samples in
`native_queued_spin_lock_slowpath` below `locale_get_default_69`.
Passing `icu::Locale::getRoot()` explicitly bypasses the default-locale
lookup
entirely, eliminating the lock contention. This also makes case
conversion
deterministic across BE hosts regardless of process environment locale.
### Release note
Yes: LOWER/UPPER/INITCAP now use the ICU root locale for case
conversion, making
results independent of the process default locale. This is a behavior
change for
deployments where the BE process runs under a non-root locale (e.g.
Turkish
locale would have mapped 'I' to 'ı' (dotless i) instead of 'i').
### Check List (For Author)
- Test: BE unit tests (function_string_lower_test,
function_string_upper_test, function_initcap,
function_string_case_root_locale_test)
- Behavior changed: Yes — case conversion now uses root locale instead
of process default locale
- Does this need documentation: No
### PS
flame graph before this commit:
<img width="1456" height="908" alt="image"
src="https://github.com/user-attachments/assets/6326988e-9005-4a11-9bd3-fc9e4db3e0fd"
/>
flame graph after this commit:
<img width="1444" height="906" alt="image"
src="https://github.com/user-attachments/assets/1879b713-a134-49fc-9822-6f04c0ad54d9"
/>
which gains a 17-times speedup in our case.
@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?

@hello-stephen

Copy link
Copy Markdown
Contributor

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (3/3) 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage74.18% (31181/42035)
Line Coverage58.40% (345801/592128)
Region Coverage55.12% (287722/521982)
Branch Coverage56.09% (129712/231271)

@github-actions

Copy link
Copy Markdown
ContributorAuthor

PR approved by anyone and no changes requested.

@github-actionsgithub-actionsBot added reviewed approved Indicates a PR has been approved by one committer. labels Aug 25, 2026
@github-actions

Copy link
Copy Markdown
ContributorAuthor

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

@yiguolei
yiguolei merged commit daa7c62 into branch-4.1Aug 25, 2026
30 of 33 checks passed
@morrySnow
morrySnow deleted the auto-pick-66440-branch-4.1 branch August 31, 2026 07:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@hello-stephen@yiguolei@Baymine