Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unnecessary allocs in SideChannelMananger #4886

Merged
merged 4 commits into from
Jan 27, 2021

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Jan 27, 2021

Proposed change(s)

How it started
image

How it's going
image

This early-outs from GetSideChannelMessage if there are no messages to process. This should be the case the vast majority of the time, especially during inference (unless the user is actively doing something like calling StatsRecorder.Add()).

Thanks @szantner for reporting!

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

#4883

Types of change(s)

  • Bug fix

Checklist

Other comments

{
// Early out so that we don't create the MemoryStream or BinaryWriter.
// This is the most common case.
return Array.Empty<byte>();
Copy link
Contributor Author

@chriselion chriselion Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't try this with null instead of Empty(), but I'm 99% sure the protobuf code will choke on null.

@@ -30,6 +30,9 @@ removed when training with a player. The Editor still requires it to be clamped
#### com.unity.ml-agents (C#)
- Fix a compile warning about using an obsolete enum in `GrpcExtensions.cs`. (#4812)
- CameraSensor now logs an error if the GraphicsDevice is null. (#4880)
- Removed unnecessary memory allocations in `ActuatorManager.UpdateActionArray()` (#4877)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@surfnerd I added our other PRs here. If this gets repetitive, we can group these into a nested list later.

@chriselion chriselion merged commit 0e573a1 into master Jan 27, 2021
@delete-merged-branch delete-merged-branch bot deleted the MLA-1720-sidechannel-gc branch January 27, 2021 23:59
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants