mmustafasenoglu opened a new pull request, #66662: URL: https://github.com/apache/doris/pull/66662
## Problem 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, this mutex becomes a severe CPU bottleneck. Production flame graph evidence shows **82% of CPU wasted on a spinlock** inside ICU's default-locale lookup — not on actual case conversion or string matching. ## Root Cause `TransferImpl::to_upper_utf8`, `TransferImpl::to_lower_utf8`, and `InitcapImpl::to_initcap_utf8` in `be/src/exprs/function/function_string.cpp` all call `unicode_str.toUpper()` / `unicode_str.toLower()` without an explicit `Locale` parameter. ICU internally resolves the default locale via `locale_get_default_69()`, which takes a global mutex. ## Fix Pass `icu::Locale::getRoot()` explicitly to all three call sites: ```cpp // Before: unicode_str.toUpper(); // → locale_get_default_9() → global mutex unicode_str.toLower(); // → locale_get_default_9() → global mutex // After: unicode_str.toUpper(icu::Locale::getRoot()); // direct, no mutex unicode_str.toLower(icu::Locale::getRoot()); // direct, no mutex ``` **Changes:** 1 file, +4/-3 lines ## Benefits 1. **Eliminates lock contention** — bypasses `locale_get_default_69()` entirely 2. **Deterministic results** — case conversion now uses ICU root locale regardless of process environment 3. **Fixes Turkish locale correctness bug** — under `tr_TR` default locale, `I` maps to `ı` (dotless i) instead of `i`, producing incorrect results ## References - Fixes #66439 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
