hyperledger-labs / SmartBFT

Implementation of the SmartBFT consensus library (https://arxiv.org/abs/2107.06922)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RequestPool improvement: timeout when queue full

tock-ibm opened this issue · comments

When the queue is full, the submitting thread is currently waiting with no time limit. Improve load shedding by timing out if the thread waits too long.

This can be done by adding a context.WithTimeout, or by using a channel instead of semaphore (see below).

Currently, enforcing the queue capacity is done with a semaphore. Here is an alternative:

Create a buffered channel of size QueueSize; of bool, int or interface{} (or possibly *list.Element); the elements in the channel are "tokens".
On creation, fill the channel with tokens.
On submit, the go routine waits to get a token from the channel before inserting to the pool
On removal, the go routine places a token back in the channel.
The submitting go routines wait for a token (and may implement a timeout), the removing go routine never waits.

Fixed in #474