On 02/12/2026 22:22, Pádraig Brady wrote:
On 02/12/2026 22:04, Pádraig Brady wrote:
On 02/12/2026 21:09, Paul Eggert wrote:
On 2026-12-02 12:24, Pádraig Brady wrote:
This avoids issues on misconfigured systems like with GLIBC:
https://sourceware.org/PR35092
The changes to lib/mcel.h and to modules/mcel would surely cause a
significant slowdown in applications using mcel, as every call to
mcel_scan would have to call __ctype_get_mb_cur_max on glibc, and do
something similarly slow in non-glibc. I don't see this as being a
realistic solution. Part of the point of mcel is that it's fast.
I did already do a quick perf test with cut as a proxy.
Oh that inadvertently bypassed mcel_scan in the hot path.
Let me try something better...
$ yes $(yes éééááé | head -n9 | paste -s -d,) | head -n1M > mb.in
$ hyperfine src/cut{,.orig}" -s -d $'\x80' -f2 mb.in >/dev/null"
That shows a normal build is 10% slower,
while a fully optimized build is 40% slower.
So yes that's not appropriate by default.
How about if we omit the changes to lib/mcel.h and to modules/mcel, and
keep the other changes, i.e., the changes to the test cases? That will
warn builders that their glibc is busted.
A compromise would be to add a configure check and
add the extra check only broken systems.
Especially as Bruno already has sent a patch to glibc,
so builds on newer glibc would get the faster path?
Actually a configure check wouldn't be ideal as
it would only check the particular locales we know about.
I could of course restrict the fixes to numfmt and paste,
though it's such an insidious issue, it would be nice
to do it centrally.
I'll think a bit more on how this might be speed up.
Oh I remembered we already had single locale optimization, so
#if GNULIB_WCHAR_SINGLE_LOCALE && GNULIB_MBRTOWC_SINGLE_THREAD
cache in this case
#endif
With that in place performance is restored.
Given it's about 10 lines total, to avoid this insidious issue,
with now no performance degradation (when configured as above)
I'd still be inclined to include the protection.
cheers,
Padraig.