Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
dizzywhip
Dec 23, 2005

Are there any good resources out there for learning how to do low-level profiling and optimization of Swift code?

I've done plenty of basic profiling of apps with Instruments but haven't really gone beyond using the time profiler to diagnose relatively simple performance issues. But now I'm looking to optimize some code which isn't particularly slow but is going to be part of a game loop, and I'd like to get it running as fast as I reasonably can. Time profiler isn't giving me anything that seems actionable, and I'm kind of at a loss on how to dig deeper.

I see people talk about things like being bottlenecked by reference counting or dynamic dispatch overhead, or optimizing by messing with inlining, which I understand in a general sense, but I don't know how I would go about determining whether any of those are actually issues in a specific area of code without just guessing blindly. Are there other instruments or tools that help to diagnose these sorts of things?

Adbot
ADBOT LOVES YOU

dizzywhip
Dec 23, 2005

That's a fair suggestion, and I'm not totally against dropping down to C for performance (I've done it for some audio signal processing as part of the same project), but I'd prefer to avoid it if I can. I'm hoping to get a better grasp of low-level Swift optimization so that I don't have to use C unless it's really necessary.

In this particular case it wouldn't really be an option anyways because the code in question is a result builder interface for constructing skeletal animations programmatically. There's no real point to that system if I can't use result builders and other Swift features. Worst case, if it's too slow to run the result builder to construct animations on the fly, then I can just run it ahead of time and cache the results. Which is fine, but doing it on the fly would be nice because I'd be able to do a lot more parameterization and make the animations more dynamic.

I'm interested in the subject outside of just this project though. I also do app development for my job and as a hobby, so it would be pretty useful to understand this stuff better in general.

As for why I'm doing this at all, that's a good question! This is a game engine project I'm building for my own use as a hobby. It's obviously not a practical or efficient approach to building a game compared to using an existing engine, but it's more fun and has been a great learning experience for me. I like Swift a lot, and it has a lot of cool unique features that I think have potential for creating novel game development workflows, so I'm exploring that and seeing where it goes.

dizzywhip
Dec 23, 2005

That does seem like a good starting point. Thanks for the idea!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply