HNHacker News
TopNewBestAskShowJobs

Leszek

1,569 karma · joined May 2, 2012

[ my public key: https://keybase.io/leszek; my proof: https://keybase.io/leszek/sigs/3_mY6iFecdFZc6Ow5JJY9sZoaasKcTYHSNihcVgQptw ]
submissionscomments
Leszek··on Float Self-Tagging
Agreed, NuN tagging is an awesome use of the NaN space, and it has the same benefits of being a no-op for pointers. I would only consider this for cases where NuN tagging is impossible, e.g. some system that needs more pointer bits than NuN tagging allows.

I'd add that the claim that this could be implemented in V8 doesn't take into account pointer compression, where on-heap V8 tagged pointers are 32-bit, not 64-bit.

Leszek··on The WTF-8 Encoding
Because Unicode 1.0 had already defined characters both at the start and end of the 16-bit range (https://www.unicode.org/versions/Unicode1.0.0/CodeCharts1.pd...), and UCS-2/UTF-16 had to be compatible with that.
Leszek··on Show HN: Nova JavaScript Engine
To be fair, pointer compression is morally and memory-wise similar to indexing a vector.
Leszek··on Generating Simpson's Paradox with Z3
I've always been partial to this visual: https://analyticsindiamag.com/wp-content/uploads/2018/12/sim...
Leszek··on SAM 2: Segment Anything in Images and Videos
Hi also from Germany - works fine here
Leszek··on AI significantly reduces lumbar spine MRI interpretation times
Ah metrics, always a great thing to optimise for.

The article does mention that there was a "high degree of agreement with the expert physicians in their grading", but it's nevertheless sad how much the report focuses on time spent on the task, and not on the correctness of the results, especially when it concerns a medical diagnosis. Very much inline with my expectations for a report on "AI for X".

Leszek··on Melting ice is slowing Earth's spin, shifting its axis and influencing its core
Yes: https://www.weforum.org/agenda/2024/07/rising-sea-levels-glo...
Leszek··on I kind of like rebasing
Use `git log --first-parent` and if you merge, write useful merge commit messages. There, I've resolved the difference between merge and rebase forever.
Leszek··on The Rabbit R1 is probably running Android and is powered by an Android app
No one is surprised. People are saying that this _could_ be an Android app, and _should_ be an Android app -- and now it's been shown that it _already is_ an Android app.
Leszek··on Don't fuck with paste
You should have read a few more lines of that source - it also sends an "active" message to the tab, which is what adds and removes the copy/cut/paste event handlers.
Leszek··on Epitaph – Fermi Paradox Simulator
13th-century Chinese rockets weren't landing on the moon either so both are simplifications.
Leszek··on Out of bounds memory access in V8 in Google Chrome prior to 120.0.6099.224
I'm pretty sure it isn't, the write up only uses 517 to get an arbitrary write primitive and then did a pretty standard chain into a sandbox escape via wasm (disclaimer - I work on V8).
Leszek··on Due to blade damage, Mars Helicopter Ingenuity will not fly again
I've always preferred this alternative rewrite: https://imgs.xkcd.com/blag/spirit_rewrite_unknown_author.png
Leszek··on Out of bounds memory access in V8 in Google Chrome prior to 120.0.6099.224
That's a different bug (CVE-2024-0517 vs CVE-2024-0519)
Leszek··on Hashmaps in Factor are faster than in Zig
If you do any kind of probing other than linear probing (e.g. quadratic probing) this approach doesn't work anymore, because your collisions are no longer densely grouped together.
Leszek··on Driverless Cruise car collides with SF fire truck, injuring passenger
A system that tells you the location of (actively flashing) police cars sounds somewhat abusable.
Leszek··on Ask HN: Why do functional programmers hate loops (for, while, etc.)?
It's a very clear infinite recursion at best, and a buggy definition for odd `n` if that's fixed. I wouldn't imagine making either error if just looping...
Leszek··on CPU Utilization Is Wrong (2017)
With out of order execution, speculation, and SMT, it's hard to say if an instruction stalling means that the CPU can't process something else; CPUs are complex parallel streams of processing and trying to think of them in linear terms necessarily misses some complexity.
Leszek··on Ongoing Incident in Google Cloud
I like the mental image of this being a very precise matching -- as the sun traces across the sky, the responsibility of on-call passes from desk to desk, town to town, country to country; two engineers on a boat in the Atlantic race to keep up with their rotation...
Leszek··on Fun with Magnets
Same place any other distance-based potential energy (like gravity) comes from: being far away from the magnets -- and on repeated firings of a ball, from pulling it away from the magnets.
Leszek··on Minimize Heap Allocations in Node.js
It's a bit confusing, I agree -- Oilpan is part of the V8 sources for shipping-the-org-chart reasons, but it isn't actually the GC used by V8 itself for JavaScript objects and the JS heap, it's the GC used by Blink for DOM objects etc.

The biggest difference between the two is that JS objects are fully managed by the GC and V8 has full control over their layout and access (e.g. they are accessed via explicit pointer + field offset in the runtime), while Oilpan works on C++ objects; there's a billion consequences of this, in particular that JS objects are movable (because we can safely update pointers) and Oilpan objects aren't (because C++ can do pretty much whatever it wants).

Leszek··on Minimize Heap Allocations in Node.js
To be clear, maybe I was a bit negative, but I was just talking about the technical intro. The rest of the article on not accidentally leaking references through globals and timers, and what tools to use to catch them, is pretty solid.
Leszek··on Minimize Heap Allocations in Node.js
You're talking about semantics and you're totally right, there's plenty of cases in the implementation where things are not copied when they should be (string slices) or copied when they shouldn't be (boxed double writes into mutable double boxes). As you say though, the semantics are kind of irrelevant when you're talking about actual memory behaviour of allocations.

There's actually lots of really interesting consequences of the current implementation, and the various tricks it does around what's observable and what's fast, it's just not what's described here.

Leszek··on Minimize Heap Allocations in Node.js
From the article, "Data types stored in the stack include: [...] string"
Leszek··on Minimize Heap Allocations in Node.js
V8 dev here.

Yes, please avoid leaking memory -- but the intro to this article is incorrect in almost all major points:

> In JavaScript, primitives are assigned/passed by value and not by reference. If you assign a primitive type's value to another variable, the value is copied.

No, primitives are immutable but still passed by reference (that reference is passed by value, which is why assigning to the reference won't change them -- the same is true for objects). Can you imagine if we'd copied strings every time they were passed into a function?

> This also determines how they are stored in memory — primitive values are stored on the stack while objects are stored on the heap, with a reference to their location stored on the stack.

Also no, all primitives except small integers ("Smis") are stored in the heap.

> One important thing to note about variables stored in the stack is that their sizes must be known at compile time. This allows a program to allocate the right amount of memory in the stack. Because the JavaScript engine allocates a fixed amount of memory for primitive values, there is a limit to how large they can be.

Again, no, with strings as the obvious counter example. There's a limit to how large values in general can be, but it's around indexable size and pointer width, not a fixed amount of memory for primitives.

> Memory stored in the heap will live on unless it is explicitly deleted or deallocated.

Is the author confusing the malloc heap with the (garbage collected) JS heap? Sure, V8 has to manage the pages it allocates, but JS authors certainly don't

> To allocate memory in the heap, a program must first scan the heap to find a contiguous memory block large enough to hold the data.

As a sibling comment points out, there are optimisations here with linear allocation buffers that permit bump allocation. Also, don't forget the semi space for young objects, since the GC is generational.

Leszek··on Minimize Heap Allocations in Node.js
You're looking at Oilpan, which is the C++ GC for Blink, not the one for V8.

But, the V8 one is very similar in many respects (the same team works on both), including linear allocation buffers.

Leszek··on Is WebAssembly magic performance pixie dust? (2021)
Browsers do a fast partial parse to figure out things like scoping and variable names, but skip actually building an AST so it's still a lot quicker than full parsing (e.g. https://v8.dev/blog/preparser)
Leszek··on Ask HN: How can this happen without the phone covertly listening?
Oh weird, I was just reading about that.
Leszek··on HTML comments work in JavaScript too
It's because `f = new Number(0)` is a boxed number (therefore it's an object), and `!f` calls ToBoolean on this object which unconditionally returns true (https://tc39.es/ecma262/#table-toboolean-conversions). `!-f` first applies unary minus, which first performs a ToNumber on the f object (which returns unboxed 0), that's negated to -0, and then ToBoolean of -0 is false.
Leszek··on HTML comments work in JavaScript too
Having it in there optionally would be even more awkward, and getting rid of it entirely isn't possible without changing the JavaScript spec /shrug
← PreviousPage 2 of 11Next →