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: skip molecule checking in release build #2579

Closed
wants to merge 1 commit into from

Conversation

quake
Copy link
Member

@quake quake commented Feb 21, 2021

we should view the the slice as infallible, trusted entity in release build, skip length and bounds check.

@quake quake requested review from a team and doitian February 21, 2021 02:12
@quake
Copy link
Member Author

quake commented Feb 21, 2021

benchmark, sync-test

@nervos-bot-user
Copy link
Collaborator

Benchmark Result

  • TPS: 471
  • CKB Version: 621579f
  • Instance Type: c5.xlarge
  • Instances Count: 3
  • Bench Type: In2Out2
  • CKB Logger Filter: info,ckb=debug

@nervos-bot-user
Copy link
Collaborator

Sync Test Result

  • CKB Version: 621579f
  • Instance Region: eu-west-2
  • Sync Start: 2021-02-21 02:34:07
  • Sync End: 2021-02-21 04:45:18
  • Sync Height: 3845008
  • Sync Speed: 488 blocks/s

@quake
Copy link
Member Author

quake commented Feb 21, 2021

benchmark, sync-test

@nervos-bot-user
Copy link
Collaborator

Benchmark Result

  • TPS: 484
  • CKB Version: 621579f
  • Instance Type: c5.xlarge
  • Instances Count: 3
  • Bench Type: In2Out2
  • CKB Logger Filter: info,ckb=debug

@ybian19
Copy link
Contributor

ybian19 commented Feb 22, 2021

sync-test

@nervos-bot-user
Copy link
Collaborator

Sync Test Result

  • CKB Version: 621579f
  • Instance Region: ap-southeast-1
  • Sync Start: 2021-02-22 01:32:55
  • Sync End: 2021-02-22 03:21:06
  • Sync Height: 3849505
  • Sync Speed: 593 blocks/s

Copy link
Member

@doitian doitian left a comment

Choose a reason for hiding this comment

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

I'm against this PR. The function name suggests that it will panic on invalid data, it is surprising that it does not. It is very easy to be abused.

If we really want to skip the verification only in release mode, we should add a new function to do that.

@quake
Copy link
Member Author

quake commented Feb 23, 2021

I'm against this PR. The function name suggests that it will panic on invalid data, it is surprising that it does not. It is very easy to be abused.

If we really want to skip the verification only in release mode, we should add a new function to do that.

how about change the name to from_verified_slice_should_be_ok and move it to store crate as a private trait?

@quake
Copy link
Member Author

quake commented Feb 26, 2021

sync-test

@nervos-bot-user
Copy link
Collaborator

Sync Test Result

  • CKB Version: 621579f
  • Instance Region: eu-west-2
  • Sync Start: 2021-02-26 07:32:03
  • Sync End: 2021-02-26 09:47:53
  • Sync Height: 3872051
  • Sync Speed: 475 blocks/s

@doitian
Copy link
Member

doitian commented Mar 3, 2021

how about change the name to from_verified_slice_should_be_ok and move it to store crate as a private trait?

What's the reason that we cannot use new_unchecked in the places that we are sure the slice is valid but need to change the behavior of this function?

@yangby-cryptape
Copy link
Collaborator

yangby-cryptape commented Mar 3, 2021

First, just an additional explanation:
Before the mainnet launched and the first month after mainnet launched, there are several panics in our sentry were caused because the format of data from storage were malformed, some of those panics were sent by this function from_slice_should_be_ok(..).

Do no checks means we can make sure that:

  • We would never make mistakes again when update data structures.
  • The RocksDB will be always work well.

The worst situation I imagined is: no panics caused at beginning, but only malformed data, then we found the bug several days later.

Speaking of this, I remembered that in Matt Damon's film "The Martian", their rocket exploded because the NASA skip few checks which only have very very very small probability to find bugs.

Second, there no strong evidences could approve that those checks cost too many resource, so that we have to remove them.

p.s. I'm not opposed to this optimization, but also I don't want to approve it. And, the changes are right, no issue for codes.

@nervos-bot-user
Copy link
Collaborator

Can one of the admins verify this patch?

@stale
Copy link

stale bot commented Jun 9, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the s:wontfix Status: Wont fix label Jun 9, 2021
@quake quake removed the s:wontfix Status: Wont fix label Jun 10, 2021
@doitian
Copy link
Member

doitian commented Jun 16, 2021

Close since it does not gains enough approvals.

@doitian doitian closed this Jun 16, 2021
@doitian doitian deleted the quake/from_slice_should_be_ok branch August 11, 2021 00:16
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.

5 participants