Job Profiler Improvements – BB – Update 10
Posted: February 1, 2025
Last Updated: February 1, 2025
Job Profiler Improvements – BB – Update 10
Timeframe: January 14, 2025 – January 19, 2025
!!! No New Things This Time, But Here Are Some Cool Patterns !!!
This is update 1 of 2 that should be coming out in quick succession because I just got carried away. I decided to split up the updates because the topics I covered just felt different.
Anyways, this one is about something that I promised myself I would never come back to after I finished it: source generation. Specifically, I added some support for new job types with different parameters.
HIGHLIGHTS:
When I finished the initial profiler source generation update, I decided to leave that hell behind me, but then I immediately decided to profile the collision system, which I could not do for reasons unbeknownst to me. This took me down another rabbit hole that was mercifully easier to deal with.
The job used for collisions implements the ITriggerEventsJob interface, which is unfortunate because when I was making profiler stuff, it turns out that it only worked for IJobEntity jobs, which I didn’t even think about at the time because most of my jobs use IJobEntity.
Additionally, I forgot that scheduling an IJobEntity job also allows for input EntityQueries rather than the default query generated for the job. This drags in the question of adding other parameters to the generated code.
General Improvements:
- ProfilerOptions: Added new ProfilerOptions that can be input for specific calls to generated profiling methods. The only current option is to return the job handle for the logic job or the job handle for the profiling-ending job. Helpful for Profiler_Complete.
- BeginProfilingJob Option: Added new input option for BeginProfilingJob, resume. If true, the job does not restart the corresponding StopwatchRecorder, it just starts it instead, effectively resuming the profiling time.
- EndProfilingJob Option: Added new input option for EndProfilingJob,updateValue. If true, the prior value for the corresponding StopwatchRecorder is overwritten upon completion, effectively updating the last logged time to a newly logged time.
- Profiler_Complete: Added new helper method Profiler_Complete. This resumes a StopwatchRecorder with BeingProfilingJob, calls JobHandle.Complete on the input job, and then calls EndProfilingJob, updating the profiling time for the StopwatchRecorder with the new total time. This is useful if you want to complete a job you are already profiling. You can call Profiler_Schedule or Profiler_ScheduleParallel on a JobHandle, get the EndProfilingJob handle as output, and then call Profiler_Complete on the handle to add the completion time to the total measured time.
New Job Types:
- IJobEntity
- Support added for optional EntityQuery argument. If not provided, it uses the same DefaultQuery from the __TypeHandleCustom type defined before in the deep dive.
- IJob
- Similar to IJobEntity, except there is less I needed to do for it (only Run and Schedule).
- IJobChunk
- Almost the same as IJobEntity (Run, Schedule, and ScheduleParallel with EntityQuery arguments). I also think Unity generates an IJobChunk from IJobEntity in its own source generation.
- ITriggerEventsJob
- Pretty different from other job types. Its only relevant extension was Schedule, which also takes in a special SimulationSingleton along with required JobHandle dependencies.
All that to let me profile a few more job types (including in my bullet collision system).
Video Demos

A trippy little guy. You can’t dodge the bullets, but it’s cool to look at.

One of my favorites. This is dodge-able, and it’s really fun once you get into the flow. You’ve gotta navigate to safe spots and know when to be patient and when to rush through.