-
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
[actpool] Improve actqueue efficiency #3377
Conversation
89a4d39
to
a912350
Compare
a912350
to
6f5eb24
Compare
Codecov Report
@@ Coverage Diff @@
## master #3377 +/- ##
==========================================
+ Coverage 74.47% 75.15% +0.68%
==========================================
Files 269 298 +29
Lines 23925 25110 +1185
==========================================
+ Hits 17818 18872 +1054
- Misses 5174 5262 +88
- Partials 933 976 +43
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
d9bc77b
to
b8a515b
Compare
actpool/actqueue.go
Outdated
} | ||
|
||
// PendingNonce returns the current pending nonce of the queue | ||
func (q *actQueue) PendingNonce() uint64 { | ||
return q.pendingNonce | ||
} | ||
|
||
// ConfirmedNonce returns the current confirmed nonce of the queue | ||
func (q *actQueue) ConfirmedNonce() uint64 { |
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.
seems this is never used, can remove?
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.
this change will be used in #3343
actpool/actqueue.go
Outdated
q.pendingNonce = nonce | ||
func (q *actQueue) SetConfirmedNonce(nonce uint64) { | ||
q.confirmedNonce = nonce | ||
q.pendingNonce = nonce + 1 | ||
} | ||
|
||
// PendingNonce returns the current pending nonce of the queue | ||
func (q *actQueue) PendingNonce() uint64 { |
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.
this seems also never used with the change
state/factory/workingset.go
Outdated
@@ -465,7 +465,7 @@ func (ws *workingSet) pickAndRunActions( | |||
// do nothing | |||
case action.ErrChainID, errUnsupportWeb3Staking: | |||
continue | |||
case action.ErrGasLimit: | |||
case action.ErrGasLimit, action.ErrInsufficientFunds, state.ErrNotEnoughBalance: |
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.
we should not change this? this changes block generation logic
actpool/actqueue.go
Outdated
UpdateQueue(uint64) []action.SealedEnvelope | ||
SetPendingNonce(uint64) | ||
UpdateQueue() []action.SealedEnvelope | ||
ConfirmedNonce() uint64 |
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.
don't introduce this concept, especially for "Read"
35b657b
to
aba78c6
Compare
aba78c6
to
f6be2f5
Compare
actpool/actqueue.go
Outdated
// SetPendingBalance sets pending balance for the queue | ||
func (q *actQueue) SetPendingBalance(balance *big.Int) { | ||
q.pendingBalance = balance | ||
func (q *actQueue) SetAccountBalance(balance *big.Int) { |
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.
function name is inconsistent
actpool/actqueue.go
Outdated
} | ||
|
||
// PendingBalance returns the current pending balance of the queue | ||
func (q *actQueue) PendingBalance() *big.Int { | ||
return q.pendingBalance | ||
func (q *actQueue) AccountBalance() *big.Int { |
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.
not consistent
actpool/queueworker.go
Outdated
} | ||
} | ||
|
||
func (worker *queueWorker) Start() { |
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.
Start(context.Contex) error
with a goroutine inside
also add a Stop(context.Context) error
function
actpool/queueworker.go
Outdated
|
||
func (worker *queueWorker) Start() { | ||
if worker.queue == nil || worker.ap == nil { | ||
panic("worker is invalid") |
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.
return error
actpool/queueworker.go
Outdated
} | ||
} | ||
|
||
func (worker *queueWorker) Handle(job workerJob) { |
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.
Handle(job) error
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.
it is fixed in prev pr, and is not included in f6be2f5
e022a51
to
6b0a5f3
Compare
queue := worker.accountActs[sender] | ||
worker.mu.RUnlock() | ||
|
||
if queue == nil { |
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.
is it possible that two actions from the same user are put into queue at the same time when the queue is nil, as a result, one of the action is actually abandoned?
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.
Acts in the queue will be handled by the same thread sequentially at https://github.com/iotexproject/iotex-core/pull/3377/files/6b0a5f3041a99eef69eed90d32726bf22f9e0d97#diff-b09c50140126cf69760c5606ef46e97741ab1eadf95ca82d8c021c35c5efede2R60 ?
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
actpool/actpool.go
Outdated
defer des.mu.Unlock() | ||
destn, _ := act.Destination() | ||
actHash, _ := act.Hash() | ||
if desMap := des.acts[destn]; desMap == nil { |
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.
if _, ok := ...; !ok {
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.
good suggestion
actpool/actpool.go
Outdated
|
||
// func (ap *actPool) Stop() { | ||
// } | ||
|
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.
remove if not needed
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.
or should put L156 ap.worker[i].Start()
in Start() here?
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.
add as a todo task
pendingActs := ap.accountActs[caller.String()].AllActs() | ||
ap.removeInvalidActs(pendingActs) | ||
delete(ap.accountActs, caller.String()) | ||
worker := ap.worker[ap.allocatedWorker(caller)] |
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.
worker
is guaranteed != nil
?
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.
ap.worker
is a slice, and func allocatedWorker
assures the worker is always available.
return action.ErrAddress | ||
for _, ev := range ap.actionEnvelopeValidators { | ||
span.AddEvent("ev.Validate") | ||
if err := ev.Validate(ctx, *selp); err != nil { |
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.
is it possible to become Validate(ctx, selp)
? maybe can be something to improve in future
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.
you could add an todo for it.
88f8216
to
840ebe8
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
* move IsValidCandidateName to action package (#3706) * move IsValidCandidateName to action package * move IsValidCandidateName to action package * delete validations.go * update tests * delete ErrInvalidAmount in staking * Remove stale comment "This is an alpha release and is not ...." in all files (#3713) * remove stale comment * remove stale comment * remove nonce field (#3714) Co-authored-by: dustinxie <dahuaxie@gmail.com> * [evm] proper handle refundSnapshot and upgrade go-ethereum release (#3715) * [ioctl] modify did command parameters (#3668) * modify action.Read default parameters * use constant * use config.GasStation instead of config.API #3718 (#3721) Co-authored-by: dustinxie <dahuaxie@gmail.com> * [genesis] set Okhotsk to activate at 01-11-2023 12am UTC (#3720) * [tests] add more cases for gas refund (#3707) * add more cases for gas refund * remove debug flag Co-authored-by: dustinxie <dahuaxie@gmail.com> * [api] web3 rewarding action (#3691) * add rewarding execute action * add rewarding execute test * add commmet for public type * add builder test * complete web3 rewarding read * complete web3 rewarding read test * remove read api and receive create rewarding action enterance * add test to rlp tx test * change name * revert fix amount bug for deposit cost bug * change check error style * add entrance for web3 rewarding Co-authored-by: dustinxie <dahuaxie@gmail.com> * update mockgen (#3733) * [ioctl] use candidate.OperatorAddress to show probated delegates (#3727) Co-authored-by: dustinxie <dahuaxie@gmail.com> * [config] move config.Consensus to consensus package (#3735) * [action] validate candidate name (#3705) * Update release.yaml * [config] move config.Blocksync to blocksync package (#3736) * move config.BlockSync to blocksync package * remove def of BlockSync in config * rename newBlockSyncer to newBlockSyncerForTest * [ioctl] Build contract deploy command line into new ioctl (#3708) * [ioctl] build contract deploy command line into new ioctl * build unittest to cover the modification1~ * group iotex-core packages * remove stale comments Co-authored-by: huofei <68298506@qq.com> * [ioctl] Build contract invoke command line into new ioctl (#3709) * [ioctl] build contract invoke command line into new ioctl * build unittest to cover the modification1~ * remove stale comments Co-authored-by: huofei <68298506@qq.com> * [github] Update codeowner (#3742) * [ioctl] Build contract compile command line into new ioctl (#3676) * [ioctl] build contract compile command line into new ioctl Co-authored-by: huof6890 <68298506@qq.com> * [config] move config.API to api package (#3739) * move config.GasStation to gasstation package * move config.API to api package * make fields of testConfig to be private Co-authored-by: CoderZhi <thecoderzhi@gmail.com> * complete web3 intergrity test (#3743) * complete tests * complete requires * format * init monitor message framework * [ioctl/newcmd] fix node delegate run failed (#3729) * fix grpc error and show right datas * check chainMeta.Epoch * modify as currEpochNum * init broadcast framework * update broadcast framework * update broadcast framework * [ioctl] Build contract test bytecode command line into new ioctl (#3738) * [ioctl] build contract test bytecode command line into new ioctl * build unittest to cover the modification * format Co-authored-by: huofei <68298506@qq.com> * [ioctl] Build contract prepare command line into new ioctl (#3737) * [ioctl] build contract prepare command line into new ioctl * build unittest to cover the modification * fix commit * update assert message * update solc version * update solc message version * format * brew install solidity Co-authored-by: huofei <68298506@qq.com> * add node package to handle node info manager * update * Update release.yaml * Revert "adding .dockerignore file to fix git submodule builds (#3689)" (#3750) This reverts commit c14dcca. Co-authored-by: Jeremi [IoTeX] Rynkiewicz JRPC <63042547+jrynkiew@users.noreply.github.com> * update docker build command (#3751) * [actpool] Improve actqueue efficiency (#3377) * opt actpool.Add() * improve actqueue efficiency * add node info request and response message * remove delegate manager dependency * add message sign * add sign for node info message * fix unittest error * Update CODEOWNERS (#3754) * [rewarding] add active web3 rewarding settings (#3740) * add active web3 rewarding settings * check active when encoding is web3 * check active with deposit action * remove check logic to workingset * add check in API module * fix check validte web3 rewarding bug Co-authored-by: Haaai <55118568+Liuhaai@users.noreply.github.com> * add unittest for node * add pubkey in nodeinfo message * fix compile error * update go.mod Co-authored-by: millken <millken@gmail.com> Co-authored-by: huofei <68298506@qq.com> Co-authored-by: dustinxie <dahuaxie@gmail.com> Co-authored-by: Xueping Yang <xueping.yang@gmail.com> Co-authored-by: xianhuawei <258022429@qq.com> Co-authored-by: Jeremy Chou <lucky90322@gmail.com> Co-authored-by: Haaai <55118568+Liuhaai@users.noreply.github.com> Co-authored-by: CoderZhi <thecoderzhi@gmail.com> Co-authored-by: Jeremi [IoTeX] Rynkiewicz JRPC <63042547+jrynkiew@users.noreply.github.com>
* opt actpool.Add() * improve actqueue efficiency
Description
To enhance the throughput of the actpool module, multiple
queueworkers
are introduced to handle actions parallelly.fix #3474
Type of change
How Has This Been Tested?
make test
Checklist: