So of the 6
2022-12-03 00:10:02.682513+01 by
Dan Lyke
4 comments
So of the 6.67 seconds of the profile where I'm trying to figure out WTF an operation is so slow, at least 2.8 seconds are being spent apparently zeroing out memory deep in MacOS. I mean, I'm sure I'm trying to do too much of something, but there's nothing in that call stack that is directly me...
[ related topics:
Macintosh
]
comments in ascending chronological order (reverse):
#Comment Re: So of the 6 made: 2022-12-03 17:08:18.572354+01 by:
markd
using Instruments™? Doing the "charge libraries to callers" data mining? If not, that'll make a nice aggregate
of just user code. (and "invert call tree" is my first click whenever doing time profiling)
I think the bulk zeroing was added as a security measure - so might not be a way around it. (so if allocating
and freeing buffers repeatedly, might have to make your own reuse mechanism).
I haven't gotten into memory system profiling (e.g. cache misses) yet - but might have a bad memory access
pattern that's not consuming CPU cycles, but are eating wall time.
#Comment Re: So of the 6 made: 2022-12-04 18:15:02.037467+01 by:
Dan Lyke
Yeah, this code was written by a teenager, so there's a lot of "Objective-C lets us do these abstractions so I'm gonna use them". One of those things is a small structure used as a return object that should probably be returned as a struct {...}
on the stack rather than a full ObjC thing with accessor methods and everything.
It's really amazing how easy it is to make Objective-C do the wrong things, especially in this world of JavaScript JIT compilers that do an amazing job of sussing out what you intended to do and replacing your code with the faster idiom.
#Comment Re: So of the 6 made: 2022-12-04 20:29:24.66512+01 by:
markd
That's what Swift is for! (only half joking). So much of objc's power (all the shenanigans that only happen at
runtime) comes at the cost were there's not much visibility into what's actually going on.
Small PODs could be structs (although thanks to ARC you can't have pointer to objc objects inside of structs
for reasons), so if the tiny things have embedded NSString*s, you're kind of hosed. (there are per-thread
pools for cheaper object recycling to reduce some of the malloc churn)
#Comment Re: So of the 6 made: 2022-12-04 20:30:05.478582+01 by:
markd
[edit history]
(and for Advent of Code, I'm learning Modern C++. [[nodiscard]] constexpr const bool contains(const
Range &otherRange) noexcept
oof.)