C++ Logo


Advanced search

Re: [std-proposals] C++ never had a compiler without a stack

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 15 Aug 2023 12:48:57 -0700
On Tuesday, 15 August 2023 08:30:09 PDT David Brown via Std-Proposals wrote:
> That is one difference, yes. The other key difference is that that run
> time is absolutely minimal - typical "alloca()" calls simply add (or
> subtract) a value to a stack pointer register, which is vastly faster
> than a call to malloc() could ever be.

In a recent benchmark, we were seeing a malloc() overhead of about 15 cycles.
It was a micro-benchmark on an unfragmented heap, so very close to ideal
conditions. It surprised me because I never thought it could get that low.

Of course, a stack pointer subtraction should be 0.25 cycle.

> (For real-time systems,
> "deterministic" is more important than "fast". But it's nice to be fast
> too!)

As a colleague used to say, "real time is not real fast". :)

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-08-15 19:48:59