-
Notifications
You must be signed in to change notification settings - Fork 324
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
Process batch serialise concurrently #3877
Conversation
* upstream/master: (24 commits) account type with zero init nonce (iotexproject#3387) [api] Separate Server and Server Handler (iotexproject#3485) [ioctl] Build hdwallet derive command line into new ioctl (iotexproject#3418) [ioctl] Build hdwallet create command line into new ioctl (iotexproject#3470) [makefile] add go mod tidy (iotexproject#3471) [api] update chain metrics (iotexproject#3484) remove config.EVMNetworkID() (iotexproject#3460) [filedao] remove checkMasterChainDBFile() (iotexproject#3463) [api] add crashlog (iotexproject#3456) [api] Move generateBlockMeta to grpcserver.go (iotexproject#3303) [ioctl] Build action hash command line into new ioctl (iotexproject#3425) [ioctl] Build hdwallet export command line into new ioctl (iotexproject#3423) [ioctl] Refactor nodereward command in new ioctl (iotexproject#3416) [ioctl] Cleanup TestNewNodeDelegateCmd (iotexproject#3421) [blockchain] Remove BoltDBDaoOption (iotexproject#3465) remove InMemDaoOption (iotexproject#3464) [action] add evm london test (iotexproject#3402) [ioctl] create main for ioctl/newcmd (iotexproject#3296) [ioctl] Build block bucket command line into new ioctl (iotexproject#3386) [ioctl] Build hdwallet import command line into new ioctl (iotexproject#3419) ...
* upstream/master: (45 commits) Task: Get config cmd (iotexproject#3552) [ioctl] fix Errors unhandled (iotexproject#3567) fix dir permission and file inclusion (iotexproject#3566) [test] Disable workingset cache in the benchmark test (iotexproject#3558) [pkg] fix deferring unsafe method "Close" on type "*os.File" (iotexproject#3548) [action] Refactor handleTransfer() (iotexproject#3557) Add MinVersion in tls.Config (iotexproject#3562) [ioctl] Modify file permission as 0600 (iotexproject#3563) [httputil] add ReadHeaderTimeout (iotexproject#3550) [staking] unexport namespace (iotexproject#3551) move chanid metrics to chainservice (iotexproject#3544) [ioctl] fix log entries created from user input (iotexproject#3546) add log in rolldposctx (iotexproject#3553) fix uncontrolled data used in path expression (iotexproject#3547) [api] impl. TestGrpcServer_GetServerMeta (iotexproject#3559) [ioctl] Build action command line into new ioctl (iotexproject#3472) fix potential file inclusion via variable (iotexproject#3549) [ioctl] Incorrect conversion between integer types (iotexproject#3522) [action] fix incorrect conversion between integer types (iotexproject#3545) [test] fix TestLoadBlockchainfromDB (iotexproject#3521) ...
bytes := make([]byte, 0) | ||
for itemBytes := range bytesChan { | ||
bytes = append(bytes, itemBytes...) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general this is fine, but probably won't work for our case. Because the total bytes will be hashed to serve as a digest of the batch's content, which is used later in validation. So the bytes has to be in fixed order, and working parallel breaks this order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, does this mean the PR is no longer needed? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should ensure that the order of writing bytes matches the order in the writeQueue
. As for the order of concurrent serialization in between does not matter .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@envestcc modified it so the writing of the bytes matches the order 👍
using a pre-allocated array could enable the processing in parallel (e.g. |
Codecov Report
@@ Coverage Diff @@
## master #3877 +/- ##
==========================================
+ Coverage 75.38% 75.56% +0.18%
==========================================
Files 303 328 +25
Lines 25923 27805 +1882
==========================================
+ Hits 19541 21012 +1471
- Misses 5360 5717 +357
- Partials 1022 1076 +54
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
} else { | ||
bytes = append(bytes, wi.Serialize()...) | ||
} | ||
// 1. Digest could be replaced by merkle root if we need proof |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b.mutex.Lock()
defer b.mutex.Unlock()
should the mtx be kept?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could write an unit test to verify the concurrency problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mtx is for b.writeQueue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the mtx back @Liuhaai
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the Unlock
can be called earlier? It seems like that it can be placed just before wg.Wait()
.
but it seems that this is unrelated to the current issue. It may not improve the serialization process. Perhaps it can be discussed in a new issue.
Kudos, SonarCloud Quality Gate passed! |
lgtm |
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.
process serialization in parallel
Fixes #3760
Type of change
Please delete options that are not relevant.
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
Test Configuration:
Checklist: