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

Perf/NatsKVStore: Investigate Splitting Large Method GetEntryAsync #691

Open
to11mtm opened this issue Dec 6, 2024 · 1 comment
Open
Assignees

Comments

@to11mtm
Copy link
Collaborator

to11mtm commented Dec 6, 2024

TBH stuffing this synchronous validation that fetches a value or two, probably should get moved into static method. (AFAIK this can be moved to static although the return may change due to the sequence parsing).

That will improve overall state machine quality and likely improve performance as a result. I peeked at the IL for something close to current main and there's lots of locals and large state machines involved. Sometimes moving certain parts of logic to a static or even separate method can help with that.

Additionally, it's probably worth at least filing an issue to see whether splitting these 'if/else' branches into sub-calls gives a performance or memory boost due to likelyhood State machine will allocate for things only in one path...

Originally posted by @to11mtm in #688 (comment)

@to11mtm to11mtm self-assigned this Dec 6, 2024
@mtmk mtmk mentioned this issue Dec 7, 2024
@to11mtm
Copy link
Collaborator Author

to11mtm commented Dec 11, 2024

TBH initial investigations are showing it's not worth chasing at this time... [AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))] seems to really help things overall for common cases...

That said, It may be worth digging into JetStream internals itself for further opportunities to use [AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))] attribute on methods in that part of the code.

I'm keeping this open for now, until I can do some checks against Jetstream. If I find something will update issue accordingly, otherwise I will close unless we'd rather I roll in a different way. :)

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

No branches or pull requests

1 participant