Flutterby™! : So of the 6

Next unread comment / Catchup all unread comments User Account Info | Logout | XML/Pilot/etc versions | Long version (with comments) | Weblog archives | Site Map | | Browse Topics

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.)

Add your own comment:

(If anyone ever actually uses Webmention/indie-action to post here, please email me)




Format with:

(You should probably use "Text" mode: URLs will be mostly recognized and linked, _underscore quoted_ text is looked up in a glossary, _underscore quoted_ (http://xyz.pdq) becomes a link, without the link in the parenthesis it becomes a <cite> tag. All <cite>ed text will point to the Flutterby knowledge base. Two enters (ie: a blank line) gets you a new paragraph, special treatment for paragraphs that are manually indented or start with "#" (as in "#include" or "#!/usr/bin/perl"), "/* " or ">" (as in a quoted message) or look like lists, or within a paragraph you can use a number of HTML tags:

p, img, br, hr, a, sub, sup, tt, i, b, h1, h2, h3, h4, h5, h6, cite, em, strong, code, samp, kbd, pre, blockquote, address, ol, dl, ul, dt, dd, li, dir, menu, table, tr, td, th

Comment policy

We will not edit your comments. However, we may delete your comments, or cause them to be hidden behind another link, if we feel they detract from the conversation. Commercial plugs are fine, if they are relevant to the conversation, and if you don't try to pretend to be a consumer. Annoying endorsements will be deleted if you're lucky, if you're not a whole bunch of people smarter and more articulate than you will ridicule you, and we will leave such ridicule in place.


Flutterby™ is a trademark claimed by

Dan Lyke
for the web publications at www.flutterby.com and www.flutterby.net.