News for hackers. Stuff that matters.
Re:C64 OS: make a Commodore 64 feel fast and useful by kazinator on Friday December 10, 2021 @08:46PM (#29517622)
It's closer to something like the other 99.9999999%.

What we've done with it is things like: when you type text into what looks like a simple edit field, each keystroke launches a cascade of javascript.

Layers and layers of API's cause latency. To get this to happen, you have to talk to this broker, which calls this proxy, which delegates to this manager, which queries this store, ...

You will probably almost never see call stacks 27 frames deep when debugging anything in C64.

Re:C64 OS: make a Commodore 64 feel fast and useful by kragen on Friday December 10, 2021 @10:03PM (#29518014)
"the other 99.9999999%" would imply that computers now are a billion times faster than a C64. For some tasks, that's true; a GeForce RTX 3090 is claimed to be 36 teraflops, which is a billion times 36000 flops, and the C64 is more like 10000 flops if we figure we need 100 clock cycles per floating-point operation.

But, for other tasks, it's not a billion times faster; single-threaded 16-bit integer code might get 0.125 operations per clock cycle on the C64 and 3 operations per clock cycle on a modern CPU with a 4000 times faster clock, making the modern computer only about 96000 times faster. The way I look at things, 96000 is closer to being 100 than it is to being a billion.

In cases like that, it's only making you wonder what we're doing with the other 99.999%.

Once your program is using more data than will fit on a 1541, though, everything totally changes.

Re:C64 OS: make a Commodore 64 feel fast and useful by boomlinde on Saturday December 11, 2021 @08:58AM (#29520872)
> single-threaded 16-bit integer code might get 0.125 operations per clock cycle on the C64

Merely adding two 16-bit integers on the 6510 takes 14 cycles on fixed zero page locations for operands and destination. You'll easily spend 150 cycles on a general 16x16 multiplication using look-up tables. Not even measuring the juggling of values into and out of these fixed zero page locations via three 8-bit registers or the stack, we're talking about something like a tenth of your estimated op/s for an even mix of additions and multiplications. So I'd say much closer to a million times faster for a use case like this than 96000.

There may be special cases where the 6510 achieves 0.125 16-bit operations per second, for example multiplying by constant two and adding constant one (10 and 6 cycles, respectively)

16-bit singe threaded integer code seems like a rather contrived example as well. We're after all typically not running 16-bit applications over MS-DOS on our monster machines. Just booting into my OS will result in all cores being used to execute a bunch of 32/64 bit operations.

It would be interesting to see something like a modern cryptographic hashing algorithm implemented on a 6502 and compare performance both on long messages and on many smaller messages. This should give us an idea of how much slower a 6502 is at integer operations.

Re:C64 OS: make a Commodore 64 feel fast and useful by kragen on Saturday December 11, 2021 @12:49PM (#29522783)
I very much appreciate the corrections, particularly from someone who knows the architecture so much better than I do. Most days I regret commenting on HN, but today is not one of those days.

To clarify, by "16-bit integer code" I meant code that doesn't use floating-point, in which most of the arithmetic is done on 16-bit values, not code for a 16-bit integer machine like the 8086 or code consisting entirely of 16-bit arithmetic operations. My reason for picking 16-bit was that most of my integers fit into 16 bits, but often not 8 bits. Usually arithmetic that needs more than 16 bits of precision is address arithmetic, and on the 6502 (or 6510) that's often handled by the 8-bit X and Y registers. Even multiplies are much less common than addition, which in turn is less common than MOV. And of course jumps, calls, returns, and 8-bit-index loops (inx; bne :-) suffer comparatively less slowdown than the actual 16-bit operations in the 16-bit integer code, and they usually constitute the majority of it.

I agree that cryptographic algorithms routinely do very wide arithmetic. They want as many ALU bits as they can get their little anarchist hands on. But I think they are atypical in this.

When I look at the applications running on the computers sitting around me, most of the things they're doing seem like they would fit well into the 16-bit integer arithmetic bucket, so I don't think it's contrived. The way they're doing those things (in JS, with JIT compilers, using floating point, dynamic typing, and garbage collection) is tailored to the bigger machines we usually use, but the applications (text editing, spreadsheets, networking, arguing with strangers who know more than I do, text layout, font rendering, previously futures trading) are not. The big exceptions here are 3-D graphics and video codecs, which want ALUs as wide as possible, just like crypto algorithms.

Re:C64 OS: make a Commodore 64 feel fast and useful by hedora on Saturday December 11, 2021 @11:56AM (#29522295)
Also, modern xeons can do 32 dual precision floating point ops per cycle, per core. Since they have dozens of cores, that’s another factor of 1000, with your 10x overhead estimate for the C64, that brings the speedup to ~ a billion. (96,000 * (10 to 150x) * 1000 ~= 1-10 billion)
Re:C64 OS: make a Commodore 64 feel fast and useful by kragen on Saturday December 11, 2021 @12:50PM (#29522786)
Yes, SIMD operations on CPUs are in many ways similar to GPU computation.
Re:C64 OS: make a Commodore 64 feel fast and useful by pjmlp on Saturday December 11, 2021 @02:40AM (#29519265)
My phone is better than a SGI Indigo, a Lisp Machine or Connection Machine, yet it gets used as a container for web apps disguised as native.
Re:C64 OS: make a Commodore 64 feel fast and useful by kragen on Thursday December 23, 2021 @12:59PM (#29664455)
Burn it all down.
Re:C64 OS: make a Commodore 64 feel fast and useful by melony on Saturday December 11, 2021 @01:44AM (#29519021)
Look ma, no pipelines.