Re: The Case for Rust (in any system)
- Reply: David Chisnall : "Re: The Case for Rust (in any system)"
- In reply to: David Chisnall : "Re: The Case for Rust (in any system)"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Sep 2024 07:59:08 UTC
That‘s because you are a dork. The point isn’t that calloc calls are faster than vector allocations. The point is that by changing the way you deal with arrays (as objects that manage their own size, versus managing the sizes using up front preallocations and dealing with their growth yourself), we can exchange function calls for pointer dereferences. An order of magnitude improvement just by reorganizing the way array element access is performed. On Fri, Sep 13, 2024 at 2:17 AM David Chisnall <theraven@freebsd.org> wrote: > On 13 Sep 2024, at 02:34, Joe Schaefer <joesuf4@gmail.com> wrote: > > > > I just completed a month long project to port a C++ codebase that used > vectors for array allocations back to using C‘s calloc. For a 15% increase > in memory footprint, batch jobs that took three days to complete now finish > in 10-12 hours. > > This sounds highly dubious given that std::vector is a very thin wrapper > around malloc. From your description, I would expect the same speedup with > some judicial use of .reserve(). > > David