Repository navigation
Fix: Byte-set search on big-endian Power VSX - #360
Merged
Merged
Conversation
`sz_byteset_add_u8` sets bit `c & 63` of the native-endian word `_u64s[c >> 6]`, while the VSX byte-set kernels look the same bit up byte-wise, as bit `c & 7` of `_u8s[c >> 3]`. The two views only agree on little-endian, so on big-endian Power every lookup landed in the wrong byte, and `find_first_of`, `find_last_of`, `strip` and `split` missed every match. Byte-reverse each 64-bit word of the two set halves once, outside the loop, with `vec_revb`, so the hot loop is unchanged on both byte orders.
ashvardanian
force-pushed
the
ppc64-fix
branch
from
October 24, 2026 22:39
121c73b to
53f581c
Compare
sub4biz
pushed a commit
to sub4biz/StringZilla
that referenced
this pull request
Nov 14, 2026
The 5.x line released v5.2.0 through v5.3.2 after 6.0 branched at v5.1.2, and its public main ends at d0c8dea. Its fixes now hold on 6.0's code: - Reverse searches with large limits no longer overflow (1b9b0a5, ashvardanian#347) - Empty needles match in default string views (faf71d7, ashvardanian#346) - `rpartition` puts the text last when the separator is missing (b128ed3, ashvardanian#356) - `translate` writes into a reusable `out` buffer (e1d7b8c, ashvardanian#353) - Byte argsort walks windows on a heap stack instead of recursing, so long shared prefixes no longer exhaust the call stack, and Haswell and NEON accept empty inputs (7deae1e, ashvardanian#344; 12d5f81) - 2-4 byte needles search backward with SWAR (e94052b, ashvardanian#342) - RISC-V GCM kernels dispatch only where Zvkg is present (2f78f25) - Pyodide wheels and RISC-V wheel images (96c88fd, ashvardanian#343), and Python CI runs under the debug allocator (339f47a) Already on 6.0's code: forward searches past the end (31e7c8c, ashvardanian#348) and big-endian VSX byte sets (fcf768b, ashvardanian#360), both via 8f298ac, and the test package's exclusion from wheels (fa427ac, ashvardanian#338). The CUDA wheel, StringZillas scratch and tape-length fixes target code 6.0 replaced. Unknown keyword arguments now raise `TypeError` in `split`, `splitlines`, the strips, `decode`, the `String` constructor, `shuffled` and `sample`, where `else if (PyErr_Format(...))` never returned and surfaced as `SystemError`; porting `translate(out=)` exposed it. Also folded: dead includes dropped from four tests. Co-Authored-By: Guillaume de Rouville <[email protected]> Co-Authored-By: Shai <[email protected]> Co-Authored-By: Vladimir Iglovikov <[email protected]> Co-Authored-By: Vladimir Babin <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sz_byteset_add_u8sets bitc & 63of the native-endian word_u64s[c >> 6], whilesz_find_byteset_powervsxandsz_rfind_byteset_powervsxlook the same bit up byte-wise, as bitc & 7of_u8s[c >> 3]. The two views only agree on little-endian;on big-endian the byte holding bit
cis_u8s[(c >> 3) ^ 7], so everylookup lands in the wrong byte and
find_first_of/find_last_of(andeverything built on them:
strip,split, ...) miss every match.Unlike the NEON, SVE, and RVV byte-set kernels, the VSX ones are not
excluded on big-endian:
SZ_USE_POWERVSXonly requires__VSX__, so appc64 big-endian build for a VSX-capable CPU (e.g.
-mcpu=power9)enables them.
Byte-reverse each 64-bit word of the two set halves once on big-endian,
outside the loop, with
vec_revb(xxbrd; the file already targetspower9-vector), so the hot loop is unchanged on both byte orders.Tested on FreeBSD 15.1 powerpc64 (big-endian, POWER9) with
CFLAGS=-mcpu=power9: the Python suite went from 419 failures (all infind.pybackend-differential tests, plusstrip,split, andStrsintersect/sequence) to 10507 passed, 0 failed. The ppc64le buildis unchanged by the preprocessor guard and passes the same suite.