Repository navigation
Process string functions XXXUTF8 'asciily' if input strings are all ascii chars - #61632
Conversation
|
This is an automated comment for commit dd6774e with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
|
How does this optimization influence execution time if the string contains a non-ASCII character at the end of it, to check the worst-case scenario? |
I understand your worry totally. But the time cost of |
|
@evillique the ci seems not stable. Could you review code changes first? |
|
@evillique Any comments? |
al13n321
left a comment
There was a problem hiding this comment.
Looks reasonable, thanks for the improvement!
Wouldn't it be more efficient to do this as part of the function's inner loop instead? I.e. (1) load a block of characters into a simd register, (2) check if all ascii, (3a) use fast ascii path if yes, (3b) use slow utf8 path if no. The (1)+(2) can be identical to the isAllASCII implementation. The (3a) can be reused between the utf8 and the non-utf8 versions of the function. Overall it should be faster because it iterates only once and works for mixed strings.
Some of these functions already do this, but without AVX2/AVX512. Adding AVX2 and AVX512 implementations for these functions would be strictly better than the isAllASCII trick, but is more work, right? Specifically (from cursory reading, expect ~30% to be wrong):
- LowerUpperUTF8Impl - just needs AVX2 and AVX512.
- padString:
- UTF8::countCodePoints needs AVX2 and AVX512
- skipCodePointsBackward is not even simd
- substring - skipCodePointsForward and skipCodePointsBackward need simd.
- reverse - not obvious how to do better than
isAllASCII. - substringIndex - I don't understand why this needs to be UTF8-aware at all; UTF8 is specifically designed such that regular memmem-like search works correctly (as long as needle is valid UTF8).
But the isAllASCII trick seems like a good default behavior for cases when when we don't have efficient utf8 implementation yet.
|
TSAN error looks related: https://s3.amazonaws.com/clickhouse-test-reports/61632/690a8cf24b9402eac7479b0bbc62002b1ab3b7dc/stateless_tests__tsan__s3_storage__[4_5]/stderr.log . ASAN error seems to be the same: https://s3.amazonaws.com/clickhouse-test-reports/61632/690a8cf24b9402eac7479b0bbc62002b1ab3b7dc/stateless_tests__asan__[2_4]/stderr.log I'm guessing it's the (The other 3 failed tests are flaky.) |
The 14 queries of tests/performance/ascii.xml return 10M rows to perf.py's Python client. On master CI they take 1.0-1.9 s each, and the server spends 82-96% of that time waiting on the network send, with only 75-309 ms of CPU, so the test mostly measures clickhouse-driver decoding rather than the ASCII fast paths of the UTF-8 string functions that ClickHouse#61632 added. Mark the 14 queries disabled (their text and numbers are unchanged) and append the same 14 calls with format Null as queries 14-27. The row count of each copy is picked from a 10M..1000M ladder so that its projected CI median is in 0.2-0.75 s on amd and arm (local server CPU scaled by the CIDB/local UserTime ratio of the old query). Related: ClickHouse#129258 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Process string functions XXXUTF8 'asciily' if input strings are all ascii chars. Inspired by apache/doris#29799. Overall speed up by 1.07x~1.62x. Notice that peak memory usage had been decreased in some cases.