Maker, designer, developer • he/him • Engineer @Arm

Joined March 2013
53 Photos and videos
Eddie retweeted
circles were never the real danger
which one are you
49
3,890
69,047
971,388
Eddie retweeted
4 Jul 2024
13
367
4,147
231,620
Eddie retweeted
20 Jun 2024
The fast JavaScript runtime Bun is much faster than Node.js 22 at decoding Base64 inputs. By much faster, I mean *several times* faster. But they both rely on the same underlying library (simdutf) for the actual decoding. So what gives? The problem is that Node.js needs to interact with v8, the underlying JavaScript engine (from Google)... and doing so is not trivial. Before we can start decoding the string, we need to grab the string... so, in this instance, we call String::Value... In turns, this allocates an array inside Node.js and asks v8 to copy the content to it... In an ideal world, we would avoid the trouble entirely and just ask v8 to give us direct access to how it stores the string... and we try to do that if we can... but let me come back to it... How bad can this be, right? Just a copy. Well. Let us do some profiling... So you see, the base64 decoding itself is about about 1/5 of the running time, but the copy takes half of it. What is up with this CopyChars function? Well, it is mostly just a wrapper around the standard high level C function std::copy_n as far as I can tell. (see v8/src/utils/memcopy.h) But we are copying for an 8-bit input to a 16-bit output... why is that? Base64 is pure ASCII... and v8 can store ASCII using 8-bit per character. We get there before both IsExternalOneByte() and IsOneByte() are false (see node/src/node_buffer.cc)... We have fast paths for these cases. If IsExternalOneByte() is true, we just get the bytes and everything is great. Unfortunately, it does not always work. So we have a v8 string that is really pure ASCII, but, seemingly, we can't tell that it is the case from Node.js, and so we have to convert it to UTF-16 needlessly, using a function that is maybe not very well optimized... and then we do the base64 decoding of an ASCII string from the UTF-16 input. It is not great. To be fair, this is just one string, created as 'Buffer.alloc(size, "latin1").toString("base64")', basically the base64 encoded version of the string "latin1latin1latin1...". In actual applications, we might have better luck. Yet. Yet. I am telling this complicated story for a reason. The story illustrates why our software is slower than it should be. We have layers of abstractions to fight against. Sometimes you win, sometimes you lose. These layers are there for a reason, but they are not free. To make matters worse... these abstraction layers often thicken over time... and the friction goes up. To be clear, I do not claim that the Node.js code is optimal. In fact, I know it can be better. But it is not trivial to make it go fast. I sometimes hear people say... "well, it is C and C is hard". No. The C part is easy relatively speaking. The difficulty is at a higher level. It is not a matter of syntax. It is a matter of architecture.
In the next version of Bun `Buffer.from(str, "base64")` gets 6x - 30x faster on large input, thanks to @lemire's simdutf
33
234
1,643
556,712
Eddie retweeted
1. I'm legit shocked by the design of @Meta's new notification informing us they want to use the content we post to train their AI models. It's intentionally designed to be highly awkward in order to minimise the number of users who will object to it. Let me break it down.
362
3,039
11,784
2,774,514
26 Apr 2024
the boy... he is here
1
252
24 Apr 2024
I added this feature!! 🤗 popopop in plushie mode 👏👏
220
Eddie retweeted
16
482
5,942
238,663
22 Apr 2024
y'all best be glad my mspaint skills never made the cut for @popcatclick
147
19 Apr 2024
We've been working with @youtooz to bring out this popcat.click plushie It'll be available very soon, for a limited time⏳

1
235
Eddie retweeted
"The customer has nuclear weapons" gcc.gnu.org/bugzilla/show_bu…
39
432
4,737
646,347
Eddie retweeted
15 Jan 2024
surely this is the three day weekend that will replenish my will to live
6
435
4,925
241,883
Eddie retweeted
24 Dec 2023
he’s making a list,
he’s checking it twice,
he’s gonna find out who's naughty or nice,
santa claus is in contravention of article 4 of the General Data Protection Regulation (EU) 2016/679.
13
617
3,397
215,161
Eddie retweeted
72
287
2,871
143,248
Eddie retweeted
you know those services I refactored without filling a jira ticket?
80
550
5,460
951,312
Eddie retweeted
✨🆕 SHOP.POPCAT.CLICK 🆕✨ 🛍️🙀 POP! POP! POP! POP! 🙀🛍️
33
13
31
19,398
Eddie retweeted
kind of a bummer to have been born at the very end of the Fuck Around century just to live the rest of my life in the Find Out century
264
41,413
248,384
Eddie retweeted
12 Oct 2023
This is missing the coolest one: the actual first Photoshop icon which is a literal… photo shop
Photoshop logo evolution 1990–2023 #WebDesignHistory
23
279
3,456
361,886
Eddie retweeted
I really think this is terribly disruptive & inconsiderate to block a road like this. Don’t the people responsible for causing this know that people have to get to work, get to daycare to pick up kids? Someone needs to be held responsible! We must not tolerate this.
244
3,338
15,601
1,255,285