| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Although the idea seemed simple, I've found that the function is performing poorly in benchmarks. On my machine Apple Mac M1 Pro (ARM), the benchmarks are as follows - > ./build/benchmarks/benchmark -P utf8_length_from_utf16le utf8_length_from_utf16le_with_replacement -F ~/emoji.txt -I 100000 We define the number of bytes to be the number of *input* bytes. We define a 'char' to be a code point (between 1 and 4 bytes). Using ICU version 78.1 Using iconv version 267 Compiler: Clang 16.0.0 SIMDUTF version: 7.7.1 System: arm64 =========================== testcases: 1 input detected as UTF8 =========================== utf8_length_from_utf16le+arm64, input size: 3150, iterations: 100000, dataset: ~/emoji.txt 16.573 GB/s (5.1 %) 16.573 Gc/s 1.00 byte/char 95.0 ns utf8_length_from_utf16le_with_replacement+arm64, input size: 3150, iterations: 100000, dataset: ~/emoji.txt 12.472 GB/s (3.0 %) 12.472 Gc/s 1.00 byte/char 126.3 ns I see a 25% performance decrease. Whereas the rvv is performing in the following way - $ qemu-riscv64-static -L /lib/riscv64-linux-gnu -E LD_LIBRARY_PATH=/opt/icu-riscv64/lib:/lib/riscv64-linux-gnu ./build/benchmarks/benchmark -P utf8_length_from_utf16le utf8_length_from_utf16le_with_replacement -F ~/emoji.txt -I 100000 We define the number of bytes to be the number of *input* bytes. We define a 'char' to be a code point (between 1 and 4 bytes). Using ICU version 74.2 Compiler: Clang 18.1.3 SIMDUTF version: 7.7.1 System: rvv =========================== testcases: 1 input detected as UTF8 =========================== utf8_length_from_utf16le+rvv, input size: 3150, iterations: 100000, dataset: ~/emoji.txt 0.043 GB/s (9.7 %) 0.043 Gc/s 1.00 byte/char 36709.0 ns utf8_length_from_utf16le_with_replacement+rvv, input size: 3150, iterations: 100000, dataset: ~/emoji.txt 0.010 GB/s (1.8 %) 0.010 Gc/s 1.00 byte/char 150793.0 ns Here, I've found a 75% decrease. Please suggest ways to improve the performance of this procedure. |
Sorry, something went wrong.
|
The scalar code is performing way better - $ qemu-riscv64-static -L /lib/riscv64-linux-gnu -E LD_LIBRARY_PATH=/opt/icu-riscv64/lib:/lib/riscv64-linux-gnu ./build/benchmarks/benchmark -P utf8_length_from_utf16le utf8_length_from_utf16le_with_replacement -F ~/emoji.txt -I 100000 We define the number of bytes to be the number of *input* bytes. We define a 'char' to be a code point (between 1 and 4 bytes). Using ICU version 74.2 Compiler: Clang 18.1.3 SIMDUTF version: 7.7.1 System: rvv =========================== testcases: 1 input detected as UTF8 =========================== utf8_length_from_utf16le+rvv, input size: 3150, iterations: 100000, dataset: ~/emoji.txt 0.042 GB/s (1.6 %) 0.042 Gc/s 1.00 byte/char 37250.0 ns utf8_length_from_utf16le_with_replacement+rvv, input size: 3150, iterations: 100000, dataset: ~/emoji.txt 0.450 GB/s (4.6 %) 0.450 Gc/s 1.00 byte/char 3500.0 ns Is this regression due to inefficient emulation? |
Sorry, something went wrong.
|
@sleepingeight I assume you are running this through an emulator ? If so, we can't really tell much about your benchmark results. I would be happy to merge this in any case... we can always revise the implementation given actual hardware we care about. |
Sorry, something went wrong.
|
Hi @lemire, could you please suggest next steps to take this PR forward. |
Sorry, something went wrong.
|
@sleepingeight I am game to merge your PR if you recommend it. In any case, the whole RVV thing is experimental as far as performance goes. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Short title (summary):
Implement UTF16 to UTF8 length with replacement for rvv architecture
Description
Related to #853.
The function is implemented in the following manner, invalid surrogates are found by right shifting and left shifting the data vector and checking whether high surrogate is followed by low surrogate, this count is added to the original count from utf8_to_utf16_length to get the total length.
Type of change
Checklist before submitting