Hi @BobFai ! Thanks following up!
RealityTrace is indeed the tool to use to profile your app and identify bottlenecks and inefficiencies. We use this tool extensively while optimizing Petite Asteroids and Canyon Crosser. You can find it in Xcode in the Instruments window via Xcode > Open Developer Tool > Instruments. Inside the Instruments window, select the RealityTrace icon. You can then use the UI to configure RealityTrace to start a trace when Xcode starts your app on device.
The "key metric" is going to be how much green you see in the "RealityKit Frames" at the top of a trace:
- A green frame ran comfortably within its allotted time.
- An orange frame is "problematic/can be improved".
- A red frame took too long to render, resulting in a frame drop.
See Meet RealityKit Trace for more information on how to use this tool (this video is likely the best source of info at the moment).
I also recommend reviewing these articles:
Note: in that last link we do provide some specific metrics to target, but I would take these numbers with a heavy pinch of salt, because different apps have different requirements and I think most developers, game developers especially, will go beyond these values. Still, fewer entities, vertices, etc. will always mean a more performant app, and you should be thinking about these optimizations when and where they make sense.
For CPU usage (which likely includes any custom code you've written) you can expand the Time Profiler section start getting an idea of where your most expensive code exists. For example, I'm looking at an older trace for Petite Asteroids now, and I see that our most expensive operation by far was how we were passing data from the CPU to the GPU via setParameter(name: value:)
. As an aside, we improved this by using unique shader handle instances per material instance. Tip: Hold option to automatically expand the stack trace - the symbol you recognize will likely be very deep.
Some general performance tips:
- Use RCP to organize your assets, since there are additional compression optimizations RCP applies to assets like textures that will improve your app.
- Use baked lighting over real time lights whenever possible.
- Reduce the number of vertices in your scene, especially when geometry is used for physics.
Thanks for your question! Let me know if there's anything else I could help you with. I'm happy answer any more questions you may have!