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

Add support for wrapping message in Option #657

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

overvenus
Copy link
Contributor

MessageField has a noticeable overhead where there are lots of small nested messages being created and dropped frequently, because it wraps messages in Box.

This PR add an option option_for_message to rustproto that allows to wrap a message in an Option in generated code.

Also adding a simple benchmark shows the improvement.

# Results in Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz
test clone_and_drop_message_field             ... bench:  148 ns/iter (+/- 24)
test clone_and_drop_message_field_with_option ... bench:   36 ns/iter (+/- 5)

I would appreciate feedback!

Signed-off-by: Neil Shen <overvenus@gmail.com>
Results in Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz

```
test clone_and_drop_message_field             ... bench:  148 ns/iter (+/- 24)
test clone_and_drop_message_field_with_option ... bench:   36 ns/iter (+/- 5)
```

Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Copy link

@MzChynaBlackInc MzChynaBlackInc left a comment

Choose a reason for hiding this comment

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

f10fe57a3a1b4cedafbae84b408e4177d343fa3f

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

Successfully merging this pull request may close these issues.

2 participants