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

Avoid Arc::clone in descriptor API for performance #7

Open
andrewhickman opened this issue Jan 27, 2022 · 0 comments
Open

Avoid Arc::clone in descriptor API for performance #7

andrewhickman opened this issue Jan 27, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@andrewhickman
Copy link
Owner

Currently the descriptor API is internally represented by an Arc<FileDescriptorInner> and indexes into that structure. This makes for a very convenient API and is reasonably efficient. However it could potentially be a bottleneck if we are cloning it in a loop on multiple threads, as seen in https://pkolaczk.github.io/server-slower-than-a-laptop/

APIs like MessageDescriptor::fields will clone the Arc once for each field they iterate over. We could do better with some kind of FieldDescriptorRef type which uses a &FileDescriptorInner internally. This might be worth benchmarking internally first since it is used in DynamicMessage::encode.

@andrewhickman andrewhickman added the enhancement New feature or request label Jan 27, 2022
@andrewhickman andrewhickman changed the title Avoid Arc::clone in descriptor API Avoid Arc::clone in descriptor API for performance Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant