HNHacker News
TopNewBestAskShowJobs

ivankra

294 karma · joined October 16, 2023

https://github.com/ivankra
submissionscomments
ivankra··on Boa: A standard-conforming embeddable JavaScript engine written in Rust
> Not seeing V8, SpiderMonkey JavaScriptCore is very strange...

They do compare with JIT-less V8 and SpiderMonkey there, just JSC is missing.

I recently did my own benchmarking with a lot more engines, including other Rust engines: https://ivankra.github.io/javascript-zoo/?v8=true

Personally, I'm more impressed with https://github.com/Hans-Halverson/brimstone - it is faster, nearly just as full featured (almost full ES2025) and last but not least, a single person project.

ivankra··on Yt-dlp: External JavaScript runtime now required for full YouTube support
Tidied up benchmark and results: https://gist.github.com/ivankra/a950b2c37db48c66fe5dceb0acd8...

Looks like quickjs is the next best option after the big three engines (V8/JSC/SM).

ivankra··on Yt-dlp: External JavaScript runtime now required for full YouTube support
My page is about generic JS benchmarks. Just did a quick run with a sample javascript challenge I got via yt-dlp (https://raw.githubusercontent.com/ivankra/javascript-zoo/ref...):

  $ time ./v8 /bench/yt-dlp.js | md5sum -
  a730e32029941bf1f60f9587a6d9554f  -
  real 0m0.252s
  user 0m0.386s
  sys 0m0.074s

  $ time ./quickjs /bench/yt-dlp.js | md5sum -
  a730e32029941bf1f60f9587a6d9554f  -
  real 0m2.280s
  user 0m2.507s
  sys 0m0.031s
So about 10x slower for the current flavor of YouTube challenges: 0.2s -> 2.2s.

A few more results on same input:

  spidermonkey 0.334s
  v8_jitless 1.096s => about the limit for JIT-less interpreters like quickjs
  graaljs 2.396s
  escargot 3.344s
  libjs 4.501s
  brimstone 6.328s
  modernc-quickjs 12.767s (pure Go port of quickjs)
  fastschema-qjs 1m22.801s (Wasm port of quickjs)
  boa 1m28.070s
  quickjs-ng 2m49.202s
ivankra··on Yt-dlp: External JavaScript runtime now required for full YouTube support
> Although it will be a lot slower, I’m not clear just how slow.

Around 30-50x slower than V8 (node/deno).

I've been recently benchmarking a lot of different engines: https://ivankra.github.io/javascript-zoo/

ivankra··on NPM flooded with malicious packages downloaded more than 86k times
It works incredibly well with Linux VMs, my daily driver. I plug in a USB keyboard, external monitor and Can't Believe It's Not Linux. Only occasionally when I need to use the laptop screen/keyboard does macOS bother me and remind of it real self.

There's around 10-15% performance penalty for VMs (assuming you use arm64 guests), but the whole system is just so much faster and well built than anything Intel-based to day, that it more than compensates.

For Windows, it's lacking accelerated video drivers, but VMWare Fusion is an ok free alternative - I can totally play AAA games from last decade. Enjoy it until broadcom kills it.

ivankra··on M5 MacBook Pro
Funny you say that, as a long term Linux user who was in the exact same boat as you, I actually find Mac M4 my best Linux laptop purchase ever so far. I think what you're missing is its virtualization story. Put UTM on it, and you're back to a familiar environment, just on much nicer hardware. The first time I booted into my Linux desktop on it, I was blown away by how much snappier it felt compared to my ~5 year old top-of-the-line PC build.

I'm as much of a fan of Mac OS as the next Linux user here, but it's a very decent hypervisor and Stuff Just Works out of the box, for the most time. No more screwing around with half-baked qemu wrappers for me, vfio, virgl and what not. And running stuff without virtualization is a non-starter for me, I've been concerned about supply chain attacks before it became fashionable. Of course it would be even nicer if new Macs could run Linux natively, and I hope Asahi project will succeed with that, but until then I'm pretty happy running Linux desktop virtualized on it.

arm64 support is very decent across all the different OS now, I hardly miss Intel. I can even reasonably play most AAA games up to maybe mid-2010s on a Windows VM that's just a three finger swipe away from my main Linux desktop.

ivankra··on JIT: So you want to be faster than an interpreter on modern CPUs
They allow, but Apple's policy is to lock down that ability pretty much just to Safari/WKWebView. If you could transpile/compile your program to JS or WASM and run it through one of these blessed options, it should get JIT'ted.
ivankra··on Ask HN: What are you working on? (October 2025)
Cataloging and benchmarking JavaScript engines: https://github.com/ivankra/javascript-zoo
ivankra··on Building a JavaScript Runtime using C
Not anymore, https://github.com/bellard/quickjs
ivankra··on JIT-ing a stack machine (with SLJIT)
Well, runtime/warmup costs seems like one obvious downside to me - weval would add some non-trivial compilation overhead to your interpreter (unrolling of interpreter loop, dead code elimination, optimizing across opcodes boundaries - probably a major source of speedup). Great if you have the time to precompile your script - only have to pay those costs once. It also helps if your host language's runtime ships with an optimizing compiler/JIT you can piggyback on (WASM runtime in weval's paper, JVM in Graal's case) - these things take space. But sometimes you might just have a huge pile of code that's not hot enough to be worth optimizing and you would be better off with a basic interpreter (that can benefit from computed gotos or tail-call dispatch with zero runtime overhead). Octane's CodeLoad or TypeScript benchmarks are such examples - GraalJS does pretty poorly there.
ivankra··on JIT-ing a stack machine (with SLJIT)
> The initial naive application didn’t even yield much gains. Only after a bunch of optimizations that it really shines: a 30-46% speedup compared to the computed goto interpreter.

Looks like quite a lot of complexity for such gain. 30-40% is roughly what context-threading would buy you [1]. It takes relatively little code to implement - only do honest assembly for jumps and conditional branches, for other opcodes just emit a call to interpreter's handler. Reportedly, it took Apple just 4k LOC to ship first JIT like that in JavaScriptCore [2].

Also, if you haven't seen it, musttail + preserve_none is a cool new dispatch technique to get more mileage out of plain C/C++ before turning to hand-coded assembly/JIT [3]. A step up from computed goto.

[1] https://webdocs.cs.ualberta.ca/~amaral/cascon/CDP05/slides/C...

[2] https://webkit.org/blog/214/introducing-squirrelfish-extreme...

[3] https://godbolt.org/z/TPozdErM5

ivankra··on Myths About Floating-Point Numbers (2021)
You can put stuff into the sign bit too, that makes 53. Yeah, the lower 52 bits can't all be zero - that'd be ±INF, but the other 2^53-2 values are all yours to use.
ivankra··on Myths About Floating-Point Numbers (2021)
My favorite trick: NaN boxing. NaN's aren't just for errors, but also for smuggling other data inside. For a double, you have whopping 53 bits of payload, enough to cram in a pointer and maybe a type tag, and many javascript engines do (since JS numbers are double's after all)

https://wingolog.org/archives/2011/05/18/value-representatio...

https://piotrduperas.com/posts/nan-boxing

ivankra··on Exit Tax: Leave Germany before your business gets big
Welcome to americans' reality! It's actually more humane than the way US treats its overseas citizens - no onerous PFIC/FATCA, and you have an option to divorce the tax system while still keeping your passport.

Double taxation should be taken care of by tax treaties. Usually you'd pay the maximum of the two tax rates in total, with your current residence country getting first dibs.

ivankra··on Exit Tax: Leave Germany before your business gets big
> You can not keep any assets like company or house there!

Alternatively, simply keep both the house and company in Germany. No exit tax since, thanks to that house, you haven't technically exited, right?

ivankra··on Exit Tax: Leave Germany before your business gets big
US totally does: https://www.irs.gov/individuals/international-taxpayers/expa... - long-term (8y+) green card holders may need to pay up.

One big difference is that the clock only start ticking after you get green card, whereas with Germany any residence year counts. Oh, and citizens of course aren't affected - since US continues to tax them wherever, but Germany like almost all other countries practices residence-based taxation.

ivankra··on Exit Tax: Leave Germany before your business gets big
Or, alternatively, the bureaucrats in charge would argue that all EU countries need to implement similar exit taxation laws - that's where it seems to be heading lately.
ivankra··on Fedora 42 Beta
I was pretty much in the same boat recently. Pulled the trigger and got M4 MBP - no regrets, great machine! Blows Intel-based competition by far away, double the speed of my beefy desktop build from 5y ago. Yea, I wish it could run Linux, but Mac OS works very well as a hypervisor and I still do all my day-to-day work in a familiar environment in Linux VMs. With all the supply chain attacks lately, I don't usually dare to develop on baremetal host anymore anyway. Related discussion: https://news.ycombinator.com/item?id=42541508

In fact, it's even better than Linux as a VM desktop host - finally a reliable suspend on lid close, smooth graphics in VMs, easy context switching between VMs, no silly fiddling with virgl and GPU passthrough etc. It Just Works. I can even play almost all the Windows games I care about - and at totally acceptable frame rates despite x86/ARM translation layers and lack of discrete GPU.

ivankra··on Magnesium Self-Experiments
Underresearched topic for sure. They do cite studies that show some effects, just not convincing enough. Perhaps the weak effects are because they seem to overindex on serum magnesium levels, which is just not a good marker of magnesium status (unless very deficient). It's largely an intracellular/skeletal element and serum levels are quickly maintained by kidneys within a narrow range. Magnesium RBC is a much better biomarker but it's hard to find any studies that focus on it. Here's one but in a non-mainstream journal: https://ijlbpr.com/uploadfiles/462vol12issue2pp2557-2563.202...

Anectodally, while on B6, I had a period of magnesium intolerance - it was a reliable trigger for my dysautonomia flares. I did have reactions to magnesium chloride spray - tachycardia, blood pressure spike, sometimes headache within ~15 minutes of applying it.

ivankra··on Magnesium Self-Experiments
You can apply it topically - look for magnesium oil sprays, these are usually just concentrated magnesium chloride. Works well too, gets absorbed systemically totally bypassing digestion, only side effect is oily skin.

Reportedly, excess amounts over what the body can handle wouldn't get topically absorbed (unlike orally) and leave a white residue and that's how you'd know you've had enough - but I never had that happen to me personally.

ivankra··on Magnesium Self-Experiments
Vitamin B6 accumulates in the blood - it has an exceptionally long half-life on the order of several weeks. It's not an occasional overdose you have to worry about the most, but also chronic accumulation at low doses (even not much above RDA levels, single digit milligrams) and your blood levels - apparently there's a large individual variation in its metabolism (https://doi.org/10.1016/j.phanu.2020.100188)

UK/EU upper safety limits are at 10-12mg per day. US UL of 200mg is way past due for an overhaul.

I personally got sick from a B complex with 40mg pyridoxine after just 4 months. Developed dysautonomia (not a canonical example, but still a kind of neuropathy - damage to autonomic nervous system). Had random tachycardia and high blood pressure flares from various triggers every week, took a while to figure out what was really causing it. Your typical non-neurologist GP wouldn't know anything because "it's water soluble" and the textbooks say neuropathy develops at 200mg+. All symptoms mostly resolved after a month once I threw away everything with pyridoxine. Wouldn't touch it again, always on a lookout for B6 in my multis and supplements now. P5P form is thought to be safer, but also got people sick - look around on facebook B6 groups for more anecdata.

No problem with B12 as far as I know. It's not a neurotoxin unlike B6.

← PreviousPage 3 of 3