A small nitpick: not sure whether those macros bought anything, I guess the optimizer could inline function calls to intrinsic wrappers just fine as well?
A small nitpick: not sure whether those macros bought anything, I guess the optimizer could inline function calls to intrinsic wrappers just fine as well?
That'd sure be neat! I really have no idea, though.
> A small nitpick: not sure whether those macros bought anything, I guess the optimizer could inline function calls to intrinsic wrappers just fine as well?
Yeah, that's a bit weird. It's my hacky generics-in-C method, that allows both AVX2 and SSE4 implementations to be compiled in one codebase, while keeping the base algorithm clean. The idea is that you can compile both versions by including multiple times, like so:
#define AVX2
#include "z_validate.c"
#undef AVX2
#define SSE4
#include "z_validate.c"
#undef SSE4
...which would allow a later runtime dispatch based on CPUID, etc.It looks like the main naive validator there (validate_utf8) clocks in at 1.25 cycles/byte for ASCII and 11 cycles/byte for UTF-8, which is respectively a 15.8x and 41.5x slowdown from my code.
Since when saved megawatts bothered programmers? If that was the case we would see far smaller usage of scripting languages and electron apps.
Why do you believe this? I don't think it is quite that ubiquitous.
To switch existing code to use some particular UTF-8 decoding library should be as simple as changing some imports, and perhaps some other (search/replace) code tweaks or implementing a quick shim/adapter. If it doesn't work out, rollback or abandon the branch. On most codebases, even larger ones, this whole process is probably an easier thing to do, requiring less effort than finding a decent (and more power efficient) alternative to Electron — seems to be the GP's gist. And personally I'd agree.
Yup that's right. Any sign of inconvenience and efficiency be damned. Why do we even bother trying to fix environment. This cost money and inconveniences so many people.
Also it depends on your background. I have no problem doing without Electron. I would have to apply your exact logic to even look at it.
> Any sign of inconvenience and efficiency be damned.
Nope, not any signs... just that if you can build more with less time, in exchange of a bit of CPU efficiency, it's not so bad.
> Why do we even bother trying to fix environment.
For the future. You see, my program using a bit more RAM or CPU won't change much. Not eating that meat, that will change quite a bit, thus that's one of the things I do.
A software can allow people to be many orders in magnitudes more efficient, if I can build more of them, it allows even more people to be a few orders of magnitude more efficient. The power usage afterward, fit in the error margin quite well.
Obviously, a more efficient language with a better algorithm and good caching is best, but often we don't have the resources (whether it be time or money or whatever) to engineer the best solution, so we need to choose where to focus carefully. Sometimes that means faster prototyping in a language that may not be quite as efficient, and then using the extra time to iterate on algorithmic changes that may yield major benefits or put a caching layer in place.