Skip to content

Conversation

@HagarMeir
Copy link
Contributor

@HagarMeir HagarMeir commented Sep 15, 2025

@HagarMeir HagarMeir force-pushed the configure-mem-pool-buckets-rotation branch 4 times, most recently from 18c714e to 16d302f Compare September 17, 2025 08:23
request/pool.go Outdated
rp.semaphore.Release(1)
},
Epoch: time.Second,
Epoch: time.Duration(rand.Intn(50))*time.Millisecond + rp.options.FirstStrikeThreshold/10,
Copy link
Contributor

@tock-ibm tock-ibm Sep 17, 2025

Choose a reason for hiding this comment

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

Now the mean of the epoch is longer than FirstStrikeThreshold / 10; in fact it is FirstStrikeThreshold / 10 +25ms. I don't think this is the right approach.

Draw a random number d whose range is [-D,D]. Then add the "dither" d when you compute if a first strike had happened, e.g. in here:

func (ps *PendingStore) checkFirstStrike(now time.Time)

if now.Sub(bucket.lastTimestamp) <= ps.FirstStrikeThreshold {    <<<
			continue
		}

by adding d to the ps.FirstStrikeThreshold.

In any event, this is not expected to help much if d is much smaller than the batching interval. If the first TXs forwarded to the primary (by the secondary who strikes first) don't return in a batch by the time the next secondary batcher strikes, they will be forwarded anyway....

It seems to me a good choice for D would be around 2*BatchInterval or 3*BatchInterval.... what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@HagarMeir HagarMeir force-pushed the configure-mem-pool-buckets-rotation branch 4 times, most recently from 0928df9 to 4c92ff7 Compare September 27, 2025 18:34
Logger: rp.logger,
SecondStrikeThreshold: rp.options.SecondStrikeThreshold,
FirstStrikeThreshold: rp.options.FirstStrikeThreshold,
FirstStrikeThreshold: rp.options.FirstStrikeThreshold + rp.addRandomnessToFirstStrike(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is adding randomness only once, when the pool is created. Wouldn't it make more sense to do it per bucket, or would that be too much? what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it will be too much

rp.pending.Start()
}

func (rp *Pool) addRandomnessToFirstStrike() time.Duration {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets make sure that in the worse case the first strike is still > BatchTimeout. IE compare the BatchTimeout with the FirstStrikeThreshold. It seems to me the FirstStrikeThreshold should be at least 5*BatchTimeout or so...

Even without randomization, if FirstStrikeThreshold < BatchTimeout + network-delay we'll get constant forwarding. So some sanity checks are required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add checks
Currently the batch timeout is 500ms and we are running tests with first strike of 2s

Signed-off-by: Hagar Meir <[email protected]>
Signed-off-by: Hagar Meir <[email protected]>
Signed-off-by: Hagar Meir <[email protected]>
@HagarMeir HagarMeir force-pushed the configure-mem-pool-buckets-rotation branch from 4c92ff7 to f00a6a5 Compare October 8, 2025 08:27
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.

2 participants