News for hackers. Stuff that matters.
Re:Why is Rosetta 2 fast? by mark_undoio on Wednesday November 09, 2022 @01:50PM (#33536158)
Something that fascinates me about this kind of A -> A translation (which I associate with the original HP Dynamo project on HPPA CPUs) is that it was able to effectively yield the performance effect of one or two increased levels of -O optimization flag.

Right now it's fairly common in software development to have a debug build and a release build with potentially different optimisation levels. So that's two builds to manage - if we could build with lower optimisation and still effectively run at higher levels then that's a whole load of build/test simplification.

Moreover, debugging optimised binaries is fiddly due to information that's discarded. Having the original, unoptimised, version available at all times would give back the fidelity when required (e.g. debugging problems in the field).

Java effectively lives in this world already as it can use high optimisation and then fall back to interpreted mode when debugging is needed. I wish we could have this for C/C++ and other native languages.

Re:Why is Rosetta 2 fast? by saagarjha on Wednesday November 09, 2022 @02:11PM (#33536417)
It depends greatly on which optimization levels you’re going through. —O0 to -O1 can easily be a 2-3x performance improvement, which is going to be hard to get otherwise. -O2 to -O3 might be 15% if you’re lucky, in which case -O+LTO+PGO can absolutely get you wins that beat that.
Re:Why is Rosetta 2 fast? by bluGill on Wednesday November 09, 2022 @03:11PM (#33537177)
-O2 to -O3 has in some benchmarks made things worse. In others it is a massive win, but in generally going above -O2 should not be done without bench marking code. There are some optimizations that can make things worse or better for reasons that compiler cannot know.
Re:Why is Rosetta 2 fast? by astrange on Wednesday November 09, 2022 @04:09PM (#33537871)
Over-optimizing your "cold" code can also make things worse for the "hot" code, eg by growing code size so much that briefly entering the cold space kicks everything out of caches.
Re:Why is Rosetta 2 fast? by hinkley on Wednesday November 09, 2022 @04:43PM (#33538323)
I have often lamented not being able to hint to the JIT when I’ve transitioned from startup code to normal operation. I don’t need my Config file parsing optimized. But the code for interrogating the Config at runtime better be.

Everything before listen() is probably run once. Except not ever program calls listen().

Re:Why is Rosetta 2 fast? by hinkley on Wednesday November 09, 2022 @04:41PM (#33538298)
And then there’s always the outlier where optimizing for size makes the working memory fit into cache and thus the whole thing substantially faster.
Re:Why is Rosetta 2 fast? by foobiekr on Wednesday November 09, 2022 @05:08PM (#33538662)
One of the engineers I was working with on a project was from Transitive (the company that made QuickTransit which became Rosetta) found that their JIT based translator could not deliver significant performance increases for A->A outside of pathological cases, and it was very mature technology at the time.

I think it's a hypothetical. The Mill Computing lectures talk about a variant of this, which is sort of equivalent to an install-time specializer for intermediate code which might work, but that has many problems (for one thing, it breaks upgrades and is very, very problematic for VMs being run on different underlying hosts).

Re:Why is Rosetta 2 fast? by bogomipz on Thursday November 10, 2022 @12:45AM (#33542744)
>"The Mill Computing lectures talk about a variant of this ..." Might you or someone else have a link those Mill Computing lectures?
Re:Why is Rosetta 2 fast? by foobiekr on Thursday November 10, 2022 @12:20PM (#33549881)
Sure thing. I’m on mobile but the 2nd one was easy to find and is here -

https://youtu.be/QGw-cy0ylCc