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 allocations during bass device sync polling operation #6124

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

peppy
Copy link
Sponsor Member

@peppy peppy commented Jan 11, 2024

Minor gains because this is just a one second poll, but is what it is.

Before After
CleanShot 2024-01-11 at 05 48 29 CleanShot 2024-01-11 at 05 47 48

Also fixed a couple of incorrect calls on array building. Check underlying implementation for reasoning (one allocates, other doesn't).

Comment on lines +648 to +649
// Can't use `MoveToImmutable` here as we don't provide accurate capacity.
return new KeyCombination(keys.ToImmutableList());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure what this change is doing in here...

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Also fixed a couple of incorrect calls on array building. Check underlying implementation for reasoning (one allocates, other doesn't).

See 7ce8d47.

I can move to another PR if you want, but it was one line change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

1705049523
1705049533
1705049546

In this particular case it looks to me that the difference should be zero and both will allocate, but /shrug. (The .MoveToImmutable() stuff seems valid.)

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Oh yeah, I meant to revert this case. As per the comment, we can't use MoveTo due to capacity not being set (a hidden gotcha).

This will still allocate as the call I incorrectly "reverted" to is synonymous with the original.

@@ -341,7 +341,7 @@ private static IEnumerable<Display> getSDLDisplays()
Logger.Log($"Failed to retrieve SDL display at index ({i})", level: LogLevel.Error);
}

return builder.ToImmutable();
return builder.MoveToImmutable();
Copy link
Collaborator

Choose a reason for hiding this comment

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

...or this one either, for that matter...

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

See above.

@bdach bdach self-requested a review January 12, 2024 10:29
@bdach bdach enabled auto-merge January 12, 2024 10:38
@bdach bdach merged commit 70fc208 into ppy:master Jan 12, 2024
20 of 21 checks passed
@peppy peppy deleted the bass-sync-device-allocs branch January 17, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants