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

[blockdao] Optimize derialization when retrieving receipts #4221

Merged
merged 4 commits into from
Apr 9, 2024

Conversation

Liuhaai
Copy link
Member

@Liuhaai Liuhaai commented Apr 4, 2024

Description

getTransactionReceipt is monitored to consume lots of cpu resources when serving for web3 requests.

image

Block and Receipt are deserialized and cached separtedly to reduce duplicate computing

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@Liuhaai Liuhaai marked this pull request as ready for review April 4, 2024 00:52
Copy link

codecov bot commented Apr 4, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 76.73%. Comparing base (e1f0636) to head (8fcd84e).
Report is 223 commits behind head on master.

❗ Current head 8fcd84e differs from pull request most recent head f664e2f. Consider uploading reports for the commit f664e2f to get more accurate results

Files Patch % Lines
blockchain/block/block_deserializer.go 22.22% 14 Missing ⚠️
blockchain/filedao/filedao_v2_util.go 88.23% 2 Missing and 2 partials ⚠️
api/coreservice.go 62.50% 3 Missing ⚠️
api/web3server.go 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4221      +/-   ##
==========================================
+ Coverage   75.38%   76.73%   +1.35%     
==========================================
  Files         303      340      +37     
  Lines       25923    29293    +3370     
==========================================
+ Hits        19541    22478    +2937     
- Misses       5360     5710     +350     
- Partials     1022     1105      +83     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

// // verify merkle root can match after deserialize
// if err := blk.VerifyTxRoot(); err != nil {
// return nil, err
// }
Copy link
Member

@dustinxie dustinxie Apr 4, 2024

Choose a reason for hiding this comment

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

uncomment this?
this is not the bottleneck for now, also it how has a cache for blocks now

@@ -172,21 +171,71 @@ func (fd *fileDAOv2) highestBlockOfStoreTip() uint64 {
return fd.header.Start + fd.blkStore.Size()*fd.header.BlockStoreSize - 1
}

func (fd *fileDAOv2) getBlockStore(height uint64) (*block.Store, error) {
func (fd *fileDAOv2) getBlock(height uint64) (*block.Block, error) {
Copy link
Member

@dustinxie dustinxie Apr 5, 2024

Choose a reason for hiding this comment

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

adding block/receipt cache is good idea to improve read performance
can keep getBlockStore() to get even better performance
can you incorporate the changes under /filedao in f1bc955 into this PR?

Copy link
Member

Choose a reason for hiding this comment

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

check the top commit of origin/v2dao branch

Copy link

sonarcloud bot commented Apr 8, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
7.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@dustinxie dustinxie merged commit 036fcb8 into master Apr 9, 2024
2 of 3 checks passed
@dustinxie dustinxie deleted the opt_api_receipt branch April 9, 2024 05:50
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