don't mix negative performing chains with their parent, add some comments
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
f35555964d
commit
7bbf1c7db2
@ -177,6 +177,7 @@ func (mp *MessagePool) selectMessagesOptimal(curTs, ts *types.TipSet, tq float64
|
|||||||
for i := len(chainDeps) - 1; i >= 0; i-- {
|
for i := len(chainDeps) - 1; i >= 0; i-- {
|
||||||
curChain := chainDeps[i]
|
curChain := chainDeps[i]
|
||||||
curChain.merged = true
|
curChain.merged = true
|
||||||
|
// adjust the next chain for the parent, which is being merged
|
||||||
if next := curChain.next; next != nil {
|
if next := curChain.next; next != nil {
|
||||||
next.effPerf += next.parentOffset
|
next.effPerf += next.parentOffset
|
||||||
}
|
}
|
||||||
@ -190,6 +191,7 @@ func (mp *MessagePool) selectMessagesOptimal(curTs, ts *types.TipSet, tq float64
|
|||||||
result = append(result, chain.msgs...)
|
result = append(result, chain.msgs...)
|
||||||
gasLimit -= chainGasLimit
|
gasLimit -= chainGasLimit
|
||||||
|
|
||||||
|
// resort to account for already merged chains and effective performance adjustments
|
||||||
sort.Slice(chains[i+1:], func(i, j int) bool {
|
sort.Slice(chains[i+1:], func(i, j int) bool {
|
||||||
return chains[i].BeforeEffective(chains[j])
|
return chains[i].BeforeEffective(chains[j])
|
||||||
})
|
})
|
||||||
@ -862,7 +864,7 @@ func (mc *msgChain) SetEffectivePerf(bp float64) {
|
|||||||
|
|
||||||
func (mc *msgChain) setEffPerf() {
|
func (mc *msgChain) setEffPerf() {
|
||||||
effPerf := mc.gasPerf * mc.bp
|
effPerf := mc.gasPerf * mc.bp
|
||||||
if mc.prev != nil {
|
if effPerf > 0 && mc.prev != nil {
|
||||||
effPerfWithParent := (effPerf*float64(mc.gasLimit) + mc.prev.effPerf*float64(mc.prev.gasLimit)) / float64(mc.gasLimit+mc.prev.gasLimit)
|
effPerfWithParent := (effPerf*float64(mc.gasLimit) + mc.prev.effPerf*float64(mc.prev.gasLimit)) / float64(mc.gasLimit+mc.prev.gasLimit)
|
||||||
mc.parentOffset = effPerf - effPerfWithParent
|
mc.parentOffset = effPerf - effPerfWithParent
|
||||||
effPerf = effPerfWithParent
|
effPerf = effPerfWithParent
|
||||||
@ -880,7 +882,7 @@ func (mc *msgChain) SetNullEffectivePerf() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mc *msgChain) BeforeEffective(other *msgChain) bool {
|
func (mc *msgChain) BeforeEffective(other *msgChain) bool {
|
||||||
// moved merged chains to the front so we can discard them earlier
|
// move merged chains to the front so we can discard them earlier
|
||||||
return (mc.merged && !other.merged) || mc.effPerf > other.effPerf ||
|
return (mc.merged && !other.merged) || mc.effPerf > other.effPerf ||
|
||||||
(mc.effPerf == other.effPerf && mc.gasPerf > other.gasPerf) ||
|
(mc.effPerf == other.effPerf && mc.gasPerf > other.gasPerf) ||
|
||||||
(mc.effPerf == other.effPerf && mc.gasPerf == other.gasPerf && mc.gasReward.Cmp(other.gasReward) > 0)
|
(mc.effPerf == other.effPerf && mc.gasPerf == other.gasPerf && mc.gasReward.Cmp(other.gasReward) > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user