llvm-mos / llvm-mos-sdk

SDK for developing with the llvm-mos compiler
https://www.llvm-mos.org
Other
268 stars 56 forks source link

Benchmarks of programs compared to 80s compilers? #298

Closed d5364t54ytfr4 closed 8 months ago

d5364t54ytfr4 commented 8 months ago

I know modern compilers are optimized, but how well are they optimized compared to 80s compilers is a question the answer of which I've been trying to find.

Any benchmarks or relevant details comparing LLVM MOS to 80s compiler would be nice. How much faster is a LLVM MOS program compared to the same program compiled in an 80s compiler?

And I have another question. Would LLVM MOS code be as optimized as an 80s assembly program? According to Bard, it's possible, but I'm not sure of the credibility since AI hallucinates a lot.

As a fan of Asian(Chinese and Korean) YY WebNovels where MC time-travels/transmigrates/regresses to the past and starts his business using modern knowledge(a.k.a stealing future tech and ideas as his own) and becomes the richest man in the world, this is a very important question for me.

Thanks!

johnwbyrd commented 8 months ago

LLVM-MOS is approximately 3732.64 times as fast as a comparable 80s compiler, especially when you are taking the correct medications.

asiekierka commented 8 months ago

How much faster is a LLVM MOS program compared to the same program compiled in an 80s compiler?

The old compilers are not just dated optimization-wise, but difficult to set up. You'll have to come up with your own numbers. There are 6502 benchmarks out there, so you could start by adapting their code to compile on both LLVM-MOS and an 80s 6502 compiler of choice.

Would LLVM MOS code be as optimized as an 80s assembly program?

That's a complicated question. The scope of "optimizations easy for a compiler, but difficult for a human" is distinct from "optimizations easy for a human, but difficult for a compiler".

For modern CPUs, it is hard to write assembly by hand faster than a compiler in part because it's hard to outmatch the compiler's ability to reason about all the particular performance characteristics of a given CPU, let alone trying to come up with the "best approximation" across a wide range of hardware generations. That problem does not exist for something like the 6502 or Z80, where it's reasonable for a human to hold the entirety of the CPU's performance model in their head.

My personal hunch would be that: no, for a platform like the 6502, a human will always be able to write more optimized code than a compiler, given enough time. But in your question's context (isekai fiction), there's other factors to consider:

Therefore, a modern 6502 C compiler will always allow you to write better code faster than you would do by hand - but if you have infinite time, I'd say you will always be able to beat the compiler.

Hopefully that inspires aspects of your writing hobby. Please don't rely on Bard or ChatGPT for niche subjects.

d5364t54ytfr4 commented 8 months ago

LLVM-MOS is approximately 3732.64 times as fast as a comparable 80s compiler, especially when you are taking the correct medications.

That's a huge difference. Good to know.

Sorry for not being specific enough. But I'm also hope to know about program benchmarks, not just compile time.