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

Too many garbages that can be collected. #294

Open
pcfulife opened this issue Jun 3, 2022 · 5 comments
Open

Too many garbages that can be collected. #294

pcfulife opened this issue Jun 3, 2022 · 5 comments
Assignees
Projects
Milestone

Comments

@pcfulife
Copy link

pcfulife commented Jun 3, 2022

Detailed Description

All IChroma APIs are async which creates Task objects. On profiling my app, allocating objects are too many when I turn on Razer Chroma function.

Context

These allocated objects make app stuttering. (Chroma operates at 60 fps)

Possible Implementation

Provide not async but sync version API. Or, making a blocking collection that is used by one thread and enqueue to this.

Thanks.

@pcfulife pcfulife changed the title Too high garbages that can be collected. Too many garbages that can be collected. Jun 3, 2022
@Sharparam
Copy link
Member

Providing synchronous APIs (again) is something I've been wanting to add as well. Currently the question is how to implement it nicely due to HttpClient (used for the REST API) does not have a sync version of the Send method available in .NET Standard 2.1 (it was added for .NET 5.0).

Possibly we can multi-target Colore and call and use a dirty version of SendAsync().GetAwaiter().GetResult() on standard, and use the proper one in .NET 6.0.

The native SDK would be possible to use properly sync under both targets of course.

Have you or are you able to run tests with the native SDK switched to using ValueTask instead of Task? Does it make any noticeable difference?

@Sharparam Sharparam self-assigned this Jun 5, 2022
@Sharparam Sharparam added this to Backlog in v7.0 via automation Jun 5, 2022
@Sharparam Sharparam added this to the v7.0 milestone Jun 5, 2022
@Sharparam
Copy link
Member

@pcfulife There's a new branch (feature/sync-apis) with sync versions of the APIs added. You could try it out and see if it solves some of the issues (note that sync APIs will not work for the REST API unless you're on .NET 6.0 since HttpClient doesn't have very good support for sync APIs currently).

You can also get a NuGet package from the GitHub feed: https://github.com/chroma-sdk/Colore/packages/274021?version=7.0.0-sync-apis0223

@Sharparam Sharparam moved this from Backlog to In progress in v7.0 Jun 7, 2022
@pcfulife
Copy link
Author

@Sharparam Oh, Thanks a lot. I will try it.

@pcfulife
Copy link
Author

pcfulife commented Jun 10, 2022

@Sharparam It works perfectly even I use .NET Core 3.1

@Sharparam
Copy link
Member

Good to hear! The synchronous API should work on all platforms. It's only the synchronous HTTP that would be an issue to get working since there is no good support for that in .NET (when using the new HttpClient).

But I reckon people who are using the HTTP API would not be as likely to want a synchronous API anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v7.0
  
In progress
Development

No branches or pull requests

2 participants