llvm-mos / llvm-mos-sdk

SDK for developing with the llvm-mos compiler

Home Page:https://www.llvm-mos.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Benchmarks of programs compared to 80s compilers?

d5364t54ytfr4 opened this issue · comments

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!

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

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:

  • Back in the day, a lot of code was not well-optimized. People wrote this stuff as their day job, and not everyone was a performance fanatic willing to spend extra hours squeezing every last bit of performance - not to mention, often software was rushed out the door.
  • Speaking of rushing out the door, programming always leads to code with bugs - and there are many pitfalls of lower-level languages which higher-level ones can avoid. In short: it's easier to avoid certain bugs when writing C instead of hand assembly.
  • Speaking of avoiding bugs, a hypothetical time-travelling programmer would have the benefit of hindsight. Assuming he managed to bring a copy of, say, StackOverflow with him, he'd have a significant edge over developers who couldn't check a crowdsourced optimal answer to most routine problems they might run into.

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.

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.