News for hackers. Stuff that matters.
Re:Transcoding Unicode strings at crazy speeds with AVX-512 by amluto on Wednesday September 13, 2023 @02:51PM (#37500204)
> Simutf is designed for performance.

I know. When I was less experienced, I believed more in this kind of isolated performance. But...

> You can call utf8_length_from_latin1 to find the required buffer length

For smallish input (that fits in L1 cache, for example), performance might be dominated by the cost of filling the cache, in which case two passes might not be that bad. For large inputs, especially at the kinds of speeds that simdutf8 achieves, memory bandwidth is likely to dominate or come close, and two passes is not so great. In either case, I bet that a high quality length-checked implementation of a function like convert_latin1_to_utf8 could be considerably faster than calling utf8_length_from_latin1 and then convert_latin1_to_utf8.

> or provide a buffer that is twice as large as the input buffer, which will always suffice.

and will always be fast as long as wasting up to half the memory is not a big deal. But in many cases, that factor of 2 of memory usage is a big deal.

So I hate to say it, but I tend to think that simdutf's transcoding design is based on benchmarking the wrong thing. (The validation benchmark design is fine.)

Re:Transcoding Unicode strings at crazy speeds with AVX-512 by RaisingSpear on Wednesday September 13, 2023 @09:07PM (#37503655)
> wasting up to half the memory

OSes generally implement overcommit - allocating a bunch of memory doesn't mean it's actually being used.

Re:Transcoding Unicode strings at crazy speeds with AVX-512 by amluto on Thursday September 14, 2023 @10:27AM (#37509505)
Sorry, but allocating approximately 2x the needed size for each string is not going to get covered up well by overcommit unless you are directly mmapping and munmapping (or DONTNEEDing or similar) each allocation and each allocation is more than 8kB. (Probably well over 8kB, and for actual good efficiency in the presence of huge pages, over 4MB so there’s a chance that half of it is unused.)

I doubt this workload exists. Overcommit is kind of nifty but not at all magical.

Re:Transcoding Unicode strings at crazy speeds with AVX-512 by RaisingSpear on Thursday September 14, 2023 @11:30PM (#37517981)
> unless you are directly mmapping and munmapping (or DONTNEEDing or similar) each allocation

You don't free up the memory you're not using? Sounds like you're doing it wrong then.

> I bet a really good AVX-512 transcoder with output size checking could be almost as fast as the OP.

Submit your pull request and we can evaluate your bet.