Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. I Vibed a Proof of Conway's Conjecture(overreacted.io ↗)
    30comments
  2. An Empirical Study of Harness Design for Coding Agents(arxiv.org ↗)
    15comments
  3. AI Protest in Montreal(montrealgazette.com ↗)
    21comments
  4. Cloudflare Quick Tunnels(cloudflare.com ↗)
    13comments
  5. North Korean nuclear test sets off years of earthquakes – Science – AAAS(science.org ↗)
    3comments
  6. C++26: Trivial infinite loops are no longer undefined behaviour(sandordargo.com ↗)
    10comments
  7. Bend 2 and the Vibe-Coding Trap(liampwll.com ↗)
    179comments
  8. OpenJev(openjev.com ↗)
    185comments
  9. BeanShell3 in Development(beanshell.github.io ↗)
    3comments
  10. The Shadows Lurking in the Equations – Underwater Islands(gods.art ↗)
    5comments
  11. I don't like passkeys(hawksley.dev ↗)
    340comments
  12. Warren Buffett Steps Down as Berkshire Chairman, Names Son to Replace Him(nytimes.com ↗)
    115comments
  13. Cekura (YC F24) Is Hiring(ycombinator.com ↗)
    discuss
  14. Jemalloc 5.4.0(github.com/jemalloc ↗)
    63comments
  15. NATS publishes preliminary report on technical incident of 8 September(nats.aero ↗)
    4comments
  16. The scourge of x86 emulation(fex-emu.com ↗)
    57comments
  17. Bonsai 2 27B: Near-Lossless Compression in a 9x Smaller Footprint(prismml.com ↗)
    170comments
  18. Microsoft exec called AI scraping 'the largest theft of labor in human history'(techcrunch.com ↗)
    498comments
  19. Astra for Law(openai.com ↗)
    647comments
  20. Mathematicians Build Long-Awaited Graph Sandwich(quantamagazine.org ↗)
    discuss
  21. ZCode, the GLM coding agent, silently uploads your Git history(tokenstead.ai ↗)
    51comments
  22. Bend – A language that blocks AI mistakes via proof, on CPU and GPU(bend-lang.com ↗)
    277comments
  23. Second Circuit Allows Government to Search Electronic Devices at the Border(knightcolumbia.org ↗)
    14comments
  24. Subnormal floating-point numbers are expensive on Intel processors(lemire.me ↗)
    40comments
  25. Replacing Pull Requests with Delta(zed.dev ↗)
    52comments
  26. Qwen 3.8 Omni Flash(qwen.ai ↗)
    102comments
  27. When the fractional part of a float fixes your shader(crocidb.com ↗)
    14comments
  28. Pre-Greek: The lost language hidden within Ancient Greek(linguisticdiscovery.com ↗)
    57comments
  29. How to Write with an LLM(sockpuppet.org ↗)
    171comments
  30. NATS Major Incident Preliminary Investigation Report [pdf](nats.aero ↗)
    1comments

The scourge of x86 emulation

223 pointsby 11h agofex-emu.com
57 comments
9h agoHN ↗

For reference , Fex is a translation framework for x86 to ARM much like Apple’s Rosetta2 and Microsoft’s Prism.

Valve sponsor development as it’s also the way the new Steam Frame supports x86 games. It’s also being used (as a fork) in Crossover Beta to replace the use of Rosetta2.

7h agoHN ↗

Why doesnt Stream require their binaries to be compiled to some bytecode and transpiled during the install ?

THen they wouldnt require any emulator for any new compiles.

7h agoHN ↗

Existing games will not be recompiled for the new bytecode target, and they want all of those games to work regardless.

7h agoHN ↗

I don't know, but assumed that Valve doesn't require studios to recompile their software or use any special tooling, it's basically just packaging of existing executables. This is also why they do Windows on Linux emulation.

4h agoHN ↗

This is also why they do Windows on Linux emulation.

They don't. They use WINE, which as the name says, Is Not an Emulator. :D

(I'll let my pedantic self out now)

3h agoHN ↗

despite the funny backronym, Wine actually IS a WINdows Emulator. Someone apparently told them that it's only called an emulator if it's emulating a CPU architecture, but that's not true.

2h agoHN ↗

I thought it was an implementation of the Win32 API as a compatibility layer.

What is it emulating exactly?

2h agoHN ↗

Does Windows NT have a Windows 9x API emulator?

2h agoHN ↗

If you squint a bit (well, a lot really), Win32S on 3.1 and Windows 95’s Win32 implementation are Windows NT emulators running on top of 16 bit Windows.

7h agoHN ↗

Why doesnt Stream require their binaries to be compiled to some bytecode and transpiled during the install ?

They still have to support the entire back-catalog. It's not reasonable to expect thousands of existing games to port to ARM

6h agoHN ↗

This is what Android does with Dalvik/Android Runtime. Apps you download from the store are compiled to bytecode that is then compiled to native code at installation time.

With the compilation making use of the native instruction set supported for your device, so it can make use of newer arm instructions on newer devices while still supporting older devices.

This is the major reason app installation is so slow in Android compared to iOS (which pre-compiles everything). But it also greatly improves app compatibility with older versions.

There is no way Valve would be able to convince all the myriad of game engine developers to support a proprietary (or even open source) bytecode format even in the future. Best they could do is make it an opt-in.

Android only pulled it off because Google provides the "engine" (Android SDK) for all apps made for the platform and it did from the start.

And even so, most Androids games actually bypass this system entirely and just hand-compile to native binaries anyway. Because, again, the game engines don't want to support this bytecode format and google doesn't offer a C++ toolchain themselves that the engine developers could integrate with.

6h agoHN ↗

Games use plenty of native code; so much in fact that when Intel tried to enter the Android tablet market with x86 they had to write an ARM emulator.

5h agoHN ↗

I mentioned this in the last paragraph of my previous message...

3h agoHN ↗

Your message seems to be arguing both points at the same time - at least that's how it reads to me; first, that it's absolutely feasible to do this because Android did, and then, that in reality game developers there casually defeated those efforts anyway.

3h agoHN ↗

Also didn't they actually do this and realize that Windows API on x86/64 was as stable as anything they could invent?

2h agoHN ↗

Apps you download from the store are compiled to bytecode that is then compiled to native code at installation time.

This is only true in Android 5 and 6.

Starting with Android 7, due to amount of time it took to compile in tiny ARM CPUs, limited optimisation levels, and Java's dynamic abilities, there was a full reboot of this process.

Which is an Assembly hand written interpreter, intended to allow for quick startup in case the JIT cache is empty, a JIT compiler, and an AOT compiler that only compiles the hot paths that the JIT already had a look into, and during idle times while charging so that it can have the CPU all for itself when doing optimisations.

Additionally several other measures were taken to optmise this process, via Play Store Services, devices can share PGO data gathered by the JIT so that each device doesn't have to start from scratch, thus the interpreter step can be skipped when metadata is available. To further improve this process, developers can do training runs, and ship the metadata themselves on the APKs.

Also during the compilation to native code, depending on code access patterns, the executable code gets remapped so that there is an optimal alignment for the instruction cache when reading from the executable code cache.

Google certainly offers clang as part of the NDK, and game development is one of the few officially supported scenarios to run native code on Android.

3h agoHN ↗

It's more than thousands, and not only it's not reasonable, it's not possible.

Plenty of games run on some critical optimizations that exploit native code quirks that may or may not hold up only because Windows papers over them by special-casing the game process at OS level. The source of such games may be stuck in IP limbo, with five different studios/companies claiming ownership (three of them dead or bankrupt), and even then, the only person who knows what and how needs to be reimplemented is on a remote tropical island, working for a competitor / happily retired / stuck collecting trash for a living, depending on how their career went.

Takes only a few such cases to turn out to be some well-known games with substantial legacy fanbase hoping to relive some childhood memories, to risk seriously damaging the "supporting everything" marketing angle.

Emulating underlying runtime is safer and more practical choice.

41m agoHN ↗

"It's not reasonable to expect thousands of existing games to port to ARM"

Realistically it is possible and not actually that difficult. The hardest part would be ensuring that specific code changes from older x86 code to modern ARM code actually translate over properly and perform as expected. The majority of work done there would have to be in the libraries that were used to build the game. For way older games, like the ones you'd run under DOS, it would be much easier, as most stuff was in ASM and C (you did have the occasional BASIC game or PASCAL game flying around which would likely need a little bit of extra work) so you'd just be doing direct translation of instructions.

7h agoHN ↗

Several games in their library are actually just game updater/launcher binaries, which manage their associated game assets and binaries externally.

7h agoHN ↗

because there's no gaming-oriented toolchain for it

6h agoHN ↗

Because even with their effective monopoly they don't have the power to bully developers into doing whatever suits Valve. And it would be disastrous for the industry if they did.

5h agoHN ↗

I mean don't modern CPUs basically just run an x86_64 emulator on a RISC machine anyway? Like there's a layer between the microcode and the actual x86 instructions already.

5h agoHN ↗

I think it's more like a (kinda) VLIW machine but yes, pretty much

4h agoHN ↗

Yes, but the “architecture-independent” bytecode for these RISC machines that run underneath your various Intel and AMD CPU models is the x86_64 instruction set.

4h agoHN ↗

No, that's a myth. It's true that the instruction decoder in a CPU core translates from ISA opcodes to micro-ops for the backend, but those micro-ops are in many cases functionally very close to the ISA instruction and decidedly not RISC-like. For example, the ADD r/m64, imm32 instruction (read from memory, add constant, write to memory) is translated to a single micro-op on several Zen architectures [1], which is far from anything you could call "RISC".

[1] https://uops.info/html-instr/ADD_M64_I32.html

2h agoHN ↗

No, they don't. x86 is a superscalar processor, and it does what all superscalar processors do--translate the instructions into µops for execution and dispatch to the various execution units, with the µops not being 1-1 with the original instructions. However, it was supposed to be impossible for a CISC architecture to be superscalar, so this is what spawns the myth that it's somehow cheating by executing a RISC architecture under the hood.

5h agoHN ↗

I hate that you're being downvoted for asking a perfectly reasonable question.

Guys, if you don't like the premise of the question, reply and say why, don't downvote.

I think it's a good question, and my guess for the answer is this - which is going to be the easier problem to solve?

"Hi guys if you want to publish on Steam you have to use this specific tooling and language that'll compile to native code on first run" and everyone just has to do it

or

"Hi guys we want to be able to publish everything so it runs on Arch Linux that we run on our Steamdeck, even if only Windows binaries are available, so given that Gaben is a billionaire what we'll do is just pay guys to make Wine not suck"

You choose.

5h agoHN ↗

That will open a can of worms. For one thing, Valve will be accused of trying to create a walled garden. Plus there's the whole problem of supporting the back-catalogue as others have said.

---

Maybe the best that they could to is to offer to distribute recompiled versions of the emulated binaries, similar to how they distribute compiled shaders. But I don't know if that would work, especially legally.

1h agoHN ↗

That dream of write-once-run-anywhere has been attempted for decades and is still a massive struggle. And Steam isn’t in a position to mandate that kind of massive change. They’re big, but they still have competition from other stores and from direct sales.

1h agoHN ↗

A few reasons:

Bytecode can't really abstract the differences in memory model between the two different processors without some kind of consequence. (IE, it would be slower.) I've personally done some high performance multithreaded programming in C# / .Net, but it only "works" because C# / .Net assumes the TSO memory model. (Described in TFA.)

In contrast, games need to squeak every cycle of performance out of their chips, and optimizations can be very CPU specific. When games target bytecode, they either won't be able to take full advantage of the hardware, or otherwise will need a lot of platform-specific fallbacks (that negate the point of bytecode anyway.)

(This is why I prefer console gaming or "simple" games that don't tax the hardware.)

1h agoHN ↗

Because nobody would publish through them anymore.

Because Valve has zero legitimacy to mandate that anyone changes their software for any reason.

Because this is such an apple-brained, anti developer, anti user move that noone else in the industry does it.

Because Valve mandating that for their own gain would bring in such a gigantic gatekeeper lawsuit.

Because you profiled your code, optimized, then you'd then rely on Valve's "transpiler" to not write back absolute dogshit code back to the users.

Because if it doesn't work well, people are going to blame the video game developer and never Valve.

The list is extremely long, and the only people it would benefit is Valve.

8h agoHN ↗

As noted in the article, Apple solved this problem six years ago by simply adding an x86-compatible memory ordering mode to their chip when x86 emulation became important. Yet another way Apple's chips lead the industry.

8h agoHN ↗

Well well well “modeless” has decided to finally see the light of modes

5h agoHN ↗

Arm was never modeless. Thumb is a separate encoding with different instruction semantics and Jazelle ran Java bytecode. Both of them need a special branch instruction to enter. What they don't have is legacy modes like real, v8086 or native 16/32 protected that have no reason to exist when a CPU in long mode can run 16 and 32 bit code (in compatibility sub mode) just fine.

4h agoHN ↗

It was a joke based on the commenter’s username.

7h agoHN ↗

And as noted in the article, while that helps a lot with most of the issues, there are some corner-cases they still don't handle.

6h agoHN ↗

The word "simply" is doing a lot of work there

3h agoHN ↗

A legitimate benefit of vertical integration. They control their own CPUs so they can just do that. Linux has to run on whatever it's given.

7h agoHN ↗

Great article ! This is the kind of content I always hope to find on HN's front page.

I really wonder how things are organized at Apple to allow for vertical integration to work so well. That feature alone must have involved so many people from so many different teams.

6h agoHN ↗

The actual product people understood it to be paramount to the success of the product and so I feel like from up high there was actual commitment.

6h agoHN ↗

The intro of this article repeats the common assertion that

ARM is the most relaxed, allowing significant hardware optimizations; and x86 is the most strict, enforcing a very strong coherency model that doesn’t allow a lot of room for optimization

but I've seen some compelling arguments that a relaxed model doesn't necessarily have much of a benefit, https://fgiesen.wordpress.com/2026/08/25/memory-ordering-in-...

2h agoHN ↗

Is this just a question of what one considers to be “significant”? I’d consider 3% to be significant but the authors apparently don’t.

1h agoHN ↗

It’s a question of how much resources to allocate to the hardware team, and how much resources to be distributed diffusely to the software engineers but especially to the compiler team.

Even your linked paper contends that the actual observed slowdown is as much as 22% in the Geekbench example, but the thesis is that the slowdown is not inherent to TSO, but merely to the specific hardware implementation. Is it worthwhile for a company to optimize its TSO to chase the final gains, or is it better not to have this feature in the first place and just change the compiler?

Indeed my instinct is that it is better to do this in software, where the programmer clearly communicates which stores are ordered, and which may happen in arbitrary order.

1h agoHN ↗

[Disclaimer: I wrote Rosetta 2 and determined the spec for Apple's TSO mode, so I am obviously biased.]

Giesen's article comes off as well-meaning cope from an x86 fan. A relaxed memory model really does give you some performance. Another memory model flaw here in x86 is more architectural, which is that every instruction with the LOCK prefix is essentially a full barrier (of course, x86 could have provided different instructions while still being under TSO). In programs that make heavy usage of atomic reference counting, this actually helps quite a bit.

I would probably put that performance benefit in the single digit percentage range like my sibling comment, which may not seem like much to a SW engineer but is actually pretty serious in CPU microarchitecture. It also helps to be stacked with other architectural advantages over x86, e.g. fixed-length instructions, 32 GPRs (which Intel copied in APX), LDP/STP (which Intel also copied in APX), etc.

One of the old arguments from TSO enjoyers was that TSO helps avoid concurrency bugs that people would accidentally introduce, but this was before the C++ memory model propagated throughout the programming world. Nowadays, I think people generally conceptualize memory consistency in terms of acquire/release anyways, so why not use a CPU architecture that uses the same model?

1h agoHN ↗

Do you think there would be any worthwhile gains from relaxing address-dependent load ordering, like on Alpha/AXP? Or was that just a lot of extra pain for little reward?

6h agoHN ↗

Slightly related but this project (FEX) is amazing. I've been running Armada OS on multiple ARM handhelds and they're viable little linux machines now except with amazing battery life.

Most problems I run into are anti cheat related (EAC, etc.) but those can be circumvented for now. Feels kind of insane how far x86 emulation has come.

3h agoHN ↗

This honestly sounds like holy grail tech at this point; what kind of battery life are you looking at?

2h agoHN ↗

Wild! I don't actually do a lot of gaming, but the idea of having a small android device running desktop linux is what I've wanted for a long time!

1h agoHN ↗

I’ve got a port of FEX for MacOS to natively run Wine on M series.

Unfortunately, FEX is anti-AI, so I will have to fork.

1h agoHN ↗

The sooner RISC-V gets mass adoption and x86 becomes a historical/preservation/retro ISA the better.