frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Slowing down programs is surprisingly useful

https://stefan-marr.de/2025/08/how-to-slow-down-a-program/
52•todsacerdoti•3h ago

Comments

weinzierl•2h ago
For the Commodore 64 there was a product called the C64 Snail which could slow it down.

Later on the early PCs we had a Turbo Button, but since everyone had it in Turbo mode all the time it essentially was a way to slow down the machine.

EDIT: Found an image of what I remember as the "C64 Snail". It is called "BREMSE 64" (which is German for brake) in the image.

https://retroport.de/wp-content/uploads/2018/10/bremse64_rex...

k__•2h ago
Interesting.

I had the impression, the turbo button was created to slow down new PCs, so they could run old software that relied heavily on CPU speed.

weinzierl•2h ago
Yes, originally it was added to slow down faster XTs to exactly the 4.77 MHz of the original IBM XT.

With the AT it usually slowed down to some arbitrary frequency and it was more like a gimmick.

layer8•23m ago
The purpose of the Turbo button on PCs was indeed to slow it down, originally to the 4.77 MHz of the original 8088, for compatibility. For marketing reasons it was designated “turbo” instead of something indicating a slow-down. Turbo mode was always the default, since that was the standard speed of the respective CPU.
gwd•2h ago
Kind of weird that NOP actually slows down the pipeline, as I'd think that would be the easiest thing to optimize out of the pipeline, unless instruction fetch is one of the main limiting factors. Is it architecturally defined that NOP will slow down execution?
IcePic•2h ago
I think so, as in "make sure all other stuff has run before calling the NOP finished". Otherwise, it would just skip past it and it would have no effect if placed in a loop, so it would be eating memory for no use at all.
bob1029•2h ago
Eating memory alone may have the desired effect. The memory bandwidth of a cpu is not infinite.
motorest•2h ago
> I think so, as in "make sure all other stuff has run before calling the NOP finished".

Is this related to speculative execution? The high level description sounds like NOP works as sync points.

Someone•2h ago
I think it would be easy, but still not worth the transistors. Think of it: what programs contain lots of NOPs? Who, desiring to write a fast program, sprinkles their code with NOPs?

It’s not worth optimizing for situations that do not occur in practice.

The transistors used to detect register clearing using XOR foo,foo, on the other hand, are worth it, as lots of code has that instruction, and removing the data dependency (the instruction technically uses the contents of the foo register, but its result is independent of its value) can speed up code a lot.

adrian_b•1h ago
On CPUs with variable instruction length, like the Intel/AMD CPUs, many programs have a lot of NOPs, which are inserted by the compiler for instruction alignment.

However those NOPs are seldom executed frequently, because most are outside of loop bodies. Nevertheless, there are cases when NOPs may be located inside big loops, in order to align some branch targets to cache line boundaries.

That is why many recent Intel/AMD CPUs have special hardware for accelerating NOP execution, which may eliminate the NOPs before reaching the execution units.

pkhuong•1h ago
Yeah, just decode. But that's nice because the effect is independent of the backend's state.
adrian_b•1h ago
It depends on the CPU. On some CPUs a NOP might take the same time as an ADD and it might have the same throughput per clock cycle as ADD.

However, there are CPUs among the Intel/AMD CPUs that can execute up to a certain number of consecutive NOPs in zero time, i.e. they are removed from the instruction stream before reaching the execution units.

In general, no instruction set architecture specifies the time needed to execute an instruction. For every specific CPU model you must search its manual to find the latency and throughput for the instruction of interest, including for NOPs.

Some CPUs, like the Intel/AMD CPUs, have multiple encodings for NOP, with different lengths in order to facilitate instruction alignment. In that case the execution time may be not the same for all kinds of NOPs.

adrian_b•1h ago
In my opinion, NOP and MOV, which are recommended in TFA for slowing down, are the worst possible choices.

The authors have tested a rather obsolete CPU, with a 10-year-old Skylake microarchitecture, but more recent Intel/AMD CPUs have special optimizations for both NOP and MOV, executing them at the renaming stage, well before the normal execution units, so they may appear to have been executed in zero time.

For slowing down, one could use something really slow, like integer division. If that would interfere with the desired register usage, other reliable choices would be add with carry or perhaps complement carry flag. If it is not desired to modify the flags, one can use a RORX instruction for multiple bit rotation (available since Haswell, but not in older Atom CPUs), or one could execute BSWAP (available since 1989, therefore it exists in all 64-bit CPUs, including any Atom).

loeg•1h ago
RDTSC(P) is pretty slow. I wonder if that would work.
adrian_b•54m ago
RDTSC or RDTSCP, like also CPUID, work certainly very well for slowing down a program.

However, like integer division, they may clobber registers that the program wants to use for other purposes.

For great slow-downs when the clobbered registers do not matter, I think that CPUID is the best, as it serializes the execution and it has a long execution time on all CPUs.

For small slow-downs I think that BSWAP is a good choice, as it modifies only 1 arbitrary register without affecting the flags, and it also is a less usual instruction so it is unlikely that it will ever receive special optimizations, like NOP and MOV.

However, multiple BSWAPs must be used, to occupy all available execution ports, otherwise if there is any execution port not occupied by the rest of the program the BSWAP may be executed concurrently, not requiring any extra time.

fanf2•26m ago
They care about exact slowdown factors, and they don’t like the instructions that use any of the CPU’s execution resources because the program’s real work interferes with the slowdown factor making it harder to control.

The NOPs in effect use up a small fraction of the instruction decode bandwidth, and if they insert enough NOPs they can reduce the number of real instructions that are issued per cycle and slow down the program with a fine degree of precision.

clausecker•18m ago
Skylake has the exact same optimisations.
api•17m ago
There's a whole niche in cryptography called verifiable delay functions (VDFs) if you want a big rabbit hole to go down.

The idea is that these are unavoidably slow and preferably non-parallelizable to compute one way, but fast or near instantaneous to verify the result. Examples include the Weslowski VDFs based on similar math to RSA, MIMC, and the use of zero knowledge proofs to provide proof of slow computations.

plandis•54m ago
Causal profiling is something I infrequently use but I have been able to apply it outside of micro benchmarks in an orchestration system.

If you have a business process that is complex and owned by many different groups then causal profiling can be a good tool for dealing with the complexity. For large workflows in particular this can be powerful as the orchestration owner can experiment without much coordination (other than making sure the groups know/agree that some processing might be delayed).

initramfs•23m ago
slowing down processors also make them low power. https://github.com/hatonthecat/Solar-Kernel/blob/main/semi-a...
avidiax•14m ago
> we can estimate whether an optimization is beneficial before implementing it. Coz simulates it by slowing down all other program parts. The part we think might be optimizable stays at the same speed it was before, but is now virtually sped up, which allows us to see whether it gives enough of a benefit to justify a perhaps lengthy optimization project.

Really interesting idea. I suppose the underlying assumption is that speeding up a function might reveal a new performance floor that is much higher than the speedup would suggest. Spending time to halve a function's time only to discover that overall processing time only decreased slightly because another function is now blocking would indeed be quite bad.

Not sure how this handles I/O, or if it is enough to simply delay the results of I/O functions to simulate decreased bandwidth or increased latency.

nvahalik•3m ago
When doing web development I will occasionally connect my local code base to a remote SQL server via SSH.

This adds enough latency to be noticeable and I’ve found pages that were “OK” in prod that were unbearable in my local environment. Most of the time it was N+1 queries. Sometimes it was a cache that wasn’t working as intended. Sometimes it simply was a feature that “looked cool” but offered no value.

I’m not sure if there is a proxy that would do this locally but I’ve found it invaluable.

Nx compromised: malware uses Claude code CLI to explore the filesystem

https://semgrep.dev/blog/2025/security-alert-nx-compromised-to-steal-wallets-and-credentials/
288•neuroo•3h ago•170 comments

Monodraw

https://monodraw.helftone.com/
337•mafro•4h ago•114 comments

Object-oriented design patterns in C and kernel development

https://oshub.org/projects/retros-32/posts/object-oriented-design-patterns-in-osdev
68•joexbayer•1d ago•25 comments

Implementing Forth in Go and C

https://eli.thegreenplace.net/2025/implementing-forth-in-go-and-c/
36•Bogdanp•2h ago•4 comments

The Therac-25 Incident (2021)

https://thedailywtf.com/articles/the-therac-25-incident
283•lemper•8h ago•157 comments

SpaceX's giant Starship Mars rocket nails critical 10th test flight

https://www.space.com/space-exploration/private-spaceflight/spacex-launches-starship-flight-10-cr...
151•mpweiher•2h ago•109 comments

ASCIIFlow

https://asciiflow.com/
46•marcodiego•3h ago•9 comments

Slowing down programs is surprisingly useful

https://stefan-marr.de/2025/08/how-to-slow-down-a-program/
52•todsacerdoti•3h ago•22 comments

What We Find in the Sewers

https://www.asimov.press/p/sewers
12•surprisetalk•1h ago•5 comments

The GitHub website is slow on Safari

https://github.com/orgs/community/discussions/170758
155•talboren•5h ago•103 comments

WebLibre: The Privacy-Focused Browser

https://docs.weblibre.eu/
78•mnmalst•6h ago•51 comments

Claude for Chrome

https://www.anthropic.com/news/claude-for-chrome
730•davidbarker•20h ago•376 comments

Ember (YC F24) Is Hiring Full Stack Engineer

https://www.ycombinator.com/companies/ember/jobs/OTB0qby-full-stack-engineering-intern-summer-2026
1•charlene-wang•3h ago

F-35 pilot held 50-minute airborne conference call with engineers before crash

https://www.cnn.com/2025/08/27/us/alaska-f-35-crash-accident-report-hnk-ml
168•Michelangelo11•3h ago•235 comments

Gemini 2.5 Flash Image

https://developers.googleblog.com/en/introducing-gemini-2-5-flash-image/
1012•meetpateltech•1d ago•452 comments

QEMU 10.1.0

https://wiki.qemu.org/ChangeLog/10.1
154•dmitrijbelikov•4h ago•25 comments

Using information theory to solve Mastermind

https://www.goranssongaspar.com/mastermind
14•SchwKatze•3d ago•2 comments

Adventures in State Space [video]

https://www.youtube.com/watch?v=YGLNyHd2w10
18•bo0tzz•3d ago•3 comments

Why Aren't People Going to Local and Regional In-Person Events Anymore?

https://www.brentozar.com/archive/2025/08/why-arent-people-going-to-local-and-regional-in-person-...
25•wintermute2dot0•1h ago•25 comments

Internet Access Providers Aren't Bound by DMCA Unmasking Subpoenas–In Re Cox

https://blog.ericgoldman.org/archives/2025/08/internet-access-providers-arent-bound-by-dmca-unmas...
41•hn_acker•2d ago•6 comments

Malleable Software

https://www.mdubakov.me/malleable-software-will-eat-the-saas-world/
61•tablet•7h ago•67 comments

Dissecting the Apple M1 GPU, the end

https://rosenzweig.io/blog/asahi-gpu-part-n.html
648•alsetmusic•13h ago•142 comments

Apple Revokes EU Distribution Rights for an App on the Alt Store

https://torrentfreak.com/apple-revokes-eu-distribution-rights-for-torrent-client-developer-left-i...
34•net01•1h ago•10 comments

Show HN: FilterQL – A tiny query language for filtering structured data

https://github.com/adamhl8/filterql
37•genshii•2d ago•14 comments

Word documents will be saved to the cloud automatically on Windows going forward

https://www.ghacks.net/2025/08/27/your-word-documents-will-be-saved-to-the-cloud-automatically-on...
169•speckx•5h ago•153 comments

First absolute superconducting switch developed in a magnetic device

https://phys.org/news/2025-08-absolute-superconducting-magnetic-device.html
8•warrenm•1d ago•0 comments

Light pollution prolongs avian activity

https://gizmodo.com/birds-across-the-world-are-singing-all-day-for-a-disturbing-reason-2000646257
102•gmays•4d ago•23 comments

The “Wow!” signal was likely from extraterrestrial source, and more powerful

https://www.iflscience.com/the-wow-signal-was-likely-from-an-extraterrestrial-source-and-more-pow...
179•toss1•17h ago•178 comments

GNU Artanis – A fast web application framework for Scheme

https://artanis.dev/index.html
244•smartmic•19h ago•65 comments

Delphi in the Age of AI

https://learndelphi.org/delphi-ai-ultimate-guide/
66•andsoitis•4d ago•44 comments