Skip to content

Optimize Option to Error conversion#3036

Merged
hashmap merged 1 commit into
mimblewimble:masterfrom
cyclefortytwo:lazy-option-to-error
Sep 10, 2019
Merged

Optimize Option to Error conversion#3036
hashmap merged 1 commit into
mimblewimble:masterfrom
cyclefortytwo:lazy-option-to-error

Conversation

@hashmap
Copy link
Copy Markdown
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
Copy Markdown
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 😂

Comment thread store/src/lmdb.rs
{
match res {
Ok(None) => Err(Error::NotFoundErr(field_name.to_owned())),
Ok(None) => Err(Error::NotFoundErr(field_name())),
Copy link
Copy Markdown
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
Copy Markdown
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.

4 participants