Earlier quoted context omitted.
humans putting text into form fields will never go away probably, so you will always have to do this at some point.
This doesn't appear to implement trimming the front and back, just the entire string.
Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
31–40 of 51 posts
Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
#32The complexity almost looks like an April Fools joke.
But if it's hidden behind a standard library's 'trim' functions it's all fine to me; I don't need to know how it works under the hood, but want to rely on the maintainer's knowledge that their implementation is as fast and efficient as possible on whichever architecture. Low level string operations happen so often under the hood in any application that 10x more code and complexity in an implementation is worth it if…
Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
#33Earlier quoted context omitted.
But if it's hidden behind a standard library's 'trim' functions it's all fine to me; I don't need to know how it works under the hood, but want to rely on the maintainer's knowledge that their implementation is as fast and efficient as possible on whichever architecture. Low level string operations happen so often under the hood in any application that 10x more code and complexity in an implementation is worth it if…
It doesn’t need to be “As fast as possible” it just needs to be faster than the I/O. For sure, congrats that it is X times faster but the writer doesn’t really describe performance in terms of real world constraints.
When I was at Google there was a "rules of thumb" page that described how much of your time X performance was worth. I always looked at that before micro-optimizing, but also always came out ahead. I remember a coworker and I redesigning one of our subsystems late on some Friday evening; the rules of thumb said that the performance improvement we predicted, at our scale, was worth a month of SWE time. We did it in 2 hours. So we came out ahead, and our system worked better. (I joked that my colleague and I would be taking 2 extra weeks of vacation.)
TL;DR performance matters everywhere. The one user using an interactive tool on their workstation will appreciate their day not being wasted by random pauses. The person out and about on their phone will appreciate the additional battery life. And your company's bean counters will be quite happy to hear that your cloud bill or data center expense forecast for next year is down. Finally, it's fun! Truly a win/win. Make it fast!
Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
#34Earlier quoted context omitted.
But if it's hidden behind a standard library's 'trim' functions it's all fine to me; I don't need to know how it works under the hood, but want to rely on the maintainer's knowledge that their implementation is as fast and efficient as possible on whichever architecture. Low level string operations happen so often under the hood in any application that 10x more code and complexity in an implementation is worth it if…
It doesn’t need to be “As fast as possible” it just needs to be faster than the I/O. For sure, congrats that it is X times faster but the writer doesn’t really describe performance in terms of real world constraints.
Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
#35In order for this to matter, you'd need to expect the possibility of strings with huge numbers of leading spaces. Why then would you use this naive algorithm for comparison? An obvious and more straight forward improvement would be to compare 4 bytes at a time with 0x20202020. (or maybe 8) There would be a maximum of 3 spaces to identify individually.
Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
#36In order for this to matter, you'd need to expect the possibility of strings with huge numbers of leading spaces. Why then would you use this naive algorithm for comparison? An obvious and more straight forward improvement would be to compare 4 bytes at a time with 0x20202020. (or maybe 8) There would be a maximum of 3 spaces to identify individually.
I was confused too but the author uses “trim” to mean “remove anywhere in the string”, rather than just from the beginning and end.
Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
#37Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
#38Earlier quoted context omitted.
It doesn’t need to be “As fast as possible” it just needs to be faster than the I/O. For sure, congrats that it is X times faster but the writer doesn’t really describe performance in terms of real world constraints.
I/O is fast, and efficiency matters for every workload. The sooner your CPU is done running code, the sooner it can go into an energy saving state. Energy saving means a longer battery life on portable computers, and less cost in the server case. Remember that people are running algorithms like this "in the cloud" against millions of concurrent requests. The 40Gbps network card can keep the CPU busy, and users are wa…
Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
#39Earlier quoted context omitted.
I was confused too but the author uses “trim” to mean “remove anywhere in the string”, rather than just from the beginning and end.
What are the use cases for that, though?
Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor
#40SVE and SVE2 are similar to Intel's AVX512-etc for vector, I would use intrinsics instead of hand crafting ASM code, unless it's a performance bottleneck. And yes if you want to play with SVE, Amazon's own ARM chip is the best one available now, maybe the only one in fact, for the general public.
Just to be clear, SVE is similar to AVX512 but the “Scalable” part is that the length is not hard-coded to any set number of bits or elements. It is more like the vector computers of old, such as the Cray-1. This means there is no need for continually updating the instruction set with longer and longer versions of the same instructions. Hopefully this leads to a more stable base and wider adoption, we’ll see how that…
That's not to say scalable instructions are a bad idea. It certainly makes it easier to make small CPUs which support all the software written for vector instructions without having to emulate 256 or 512 bit wide execution units.