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

Optimize Option to Error conversion #3036

Merged
merged 1 commit into from Sep 10, 2019

Conversation

hashmap
Copy link
Contributor

@hashmap hashmap commented Sep 10, 2019

To convert option to error we generate an error message. In some places
it contains header or block hash code or other data which is costly to
produce. So during the initial header sync we spend 12% of all time on
generating those messages (in 99% cases we don't use it). This PR
introduces a lazy generation of error messages which completely
eliminates CPU load during the header sync.

Before:
Screenshot 2019-09-10 at 12 33 59

after:
Screenshot 2019-09-10 at 11 54 24

To convert option to error we generate an error message. In some places
it contains header or block hash code or other data which is costly to
produce. So during the initial header sync we spend 12% of all time on
generating those messages (in 99% cases we don't use it). This PR
introduces a lazy generation of error messages which completely
eliminates CPU load during the header sync.
Copy link
Member

@antiochp antiochp left a comment

Choose a reason for hiding this comment

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

wat 😂

match res {
Ok(None) => Err(Error::NotFoundErr(field_name.to_owned())),
Ok(None) => Err(Error::NotFoundErr(field_name())),
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@hashmap hashmap merged commit 80a8f76 into mimblewimble:master Sep 10, 2019
@quentinlesceller
Copy link
Member

Nice find!

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.

None yet

4 participants