Skip to content

perf: Jobify SendBatchedMessages in UnityTransport [MTT-4999]#2304

Merged
simon-lemay-unity merged 2 commits intodevelopfrom
perf/jobify-sends-utp
Nov 10, 2022
Merged

perf: Jobify SendBatchedMessages in UnityTransport [MTT-4999]#2304
simon-lemay-unity merged 2 commits intodevelopfrom
perf/jobify-sends-utp

Conversation

@simon-lemay-unity
Copy link
Copy Markdown
Contributor

This PR jobifies the SendBatchedMessages method in UnityTransport. The main goal of this operation is just to move the BeginSend and EndSend calls into Burst-compiled code, since otherwise they end up generating GC allocations when invoking their Burst function pointers.

To demonstrate that this results in a performance gain, I profiled a simple Boss Room play session. Here's a representative frame without the changes:

profiler1

And here's a similar frame with the changes applied:

profiler2

As can be observed, GC allocations are completely gone from SendBatchedMessages and its runtime is also reduced.

There's still much more that we could do to take advantage of jobs here. For example, we could parallelize the sends for all the targets (although we should profile that; the cost of scheduling these jobs may be more than the savings we'd get). But for now I went with the simplest change that moved us forward.

This PR also modifies the ErrorUtilities to be usable from within Burst. While modifying that, I also removed support for a bunch of error codes that simply can't be returned here (either because our APIs don't return them anymore, or because the usage patterns in UnityTransport make them impossible to encounter).

Changelog

N/A (Didn't think it worthy of a changelog entry. Let me know if you feel otherwise.)

Testing and Documentation

  • No tests have been added (but most existing tests run the new code).
  • No documentation changes or additions were necessary.

@simon-lemay-unity simon-lemay-unity requested a review from a team as a code owner November 10, 2022 06:54
@simon-lemay-unity simon-lemay-unity merged commit 3716e27 into develop Nov 10, 2022
@simon-lemay-unity simon-lemay-unity deleted the perf/jobify-sends-utp branch November 10, 2022 16:19
jakobbbb pushed a commit to GooseGirlGames/com.unity.netcode.gameobjects that referenced this pull request Feb 22, 2023
…Technologies#2304)

* Make ErrorUtilities usable from Burst

* Jobify SendBatchedMessages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants