Hacker News
points by arjie 2 days ago | 0 comments
Haha this is true but I have rewritten many things now. I use so much of a custom software stack. You can go down to primitives you like.

Most of the software I use is custom now but not in like a deep way. E.g. it turns out that browser engines are blazing fast. So what’s slow? The chrome around it, the extensions. These things I just rewrite.

It turns out that MacOS GUI primitives are also really fast. It’s just that most software poorly uses it. I rewrote text viewer applications, and a terminal emulator chrome that uses libghostty. I don’t claim originality or skill. I only claim annoyance.

Now that I’ve reached the point where the thing in the way is my OS which I have trouble modifying I suddenly understand why Omarchy is compelling to so many people. And I get why DHH is so excited about it.

You can have a bespoke system on a fast, reliable base. Why wouldn’t you do it? Why suffer?

[–] chowells 2 days ago
There are limits. USB keyboards are just always going to be slower than PS/2 keyboards. You can close the gap, but USB is just fundamentally adding wrapping layers that introduce latency over the direct polling PS/2 used. And there's a lot of this at the hardware level, where standardized connections with complex protocols replace weird custom connectors. USB is most definitely easier to plug something in to than PS/2 ports, where you had different ports for mouse and keyboard and they weren't interchangeable. (Ok, some very late motherboards supported using either in a single port, but it wasn't the way most PCs worked.)

You can do a lot at the high levels, but everything needs to be reworked from the hardware level up to match the latency of older systems.

[–] kbolino 2 days ago
> USB is just fundamentally adding wrapping layers that introduce latency over the direct polling PS/2 used

PS/2 did not use polling, it was entirely event-driven. On keypress, the keyboard sent a serial message to the 8042 controller [1], which then raised the appropriate interrupt line on the CPU, which caused the keyboard ISR [2] to be executed. The serial clock was a bit flexible, but usually sat around 10-16 kHz [3], and so the 11-bit serial message took at most 1 ms to send.

It is USB that uses polling. The keyboard describes itself using endpoint descriptors, and after obtaining these, the host controller periodically polls it with an IN token, to which the keyboard responds with its state changes since the last poll [4]. The earliest USB keyboards preferred fairly slow polling rates, but modern keyboards can be polled every 1 ms [5]. If directly connected to a motherboard USB port, a modern USB keyboard will have pre-software input latency on par with a PS/2 keyboard.

[1]: https://wiki.osdev.org/I8042_PS/2_Controller

[2]: https://wiki.osdev.org/Interrupt_Service_Routines

[3]: https://retrocomputing.stackexchange.com/q/15607/25565

[4]: https://threeboard.dev/documentation/threeboard/how_usb_keyb...

[5]: https://www.usb.org/sites/default/files/hid1_11.pdf pp. 68-69

[–] chowells 2 days ago
Agh. Crossed wires with PS2 as in the playstation 2. Its controllers used polling. I did this to myself...
[–] kbolino 2 days ago
Yeah, I'd say the bigger point is that the latency gap isn't really there anymore. Old keyboards, cheap keyboards, expansion ports, and external hubs can still cause problems, though.