Summary
TRON nodes currently determine whether they are in a busy state based only on the size of the transaction processing thread pool queues, without considering the number of transactions already cached in the mempool.
By incorporating both the thread pool queues and the mempool transaction count into the evaluation, the node can more accurately reflect its current load. This enables better control over transaction intake and improves the stability of resource management.
In addition, it is recommended that MAX_TRX_SIZE be configurable, allowing flexible adjustment based on the node's deployment environment.
Root Cause
The current isBusy() logic is as follows:
public boolean isBusy() {
return queue.size() + smartContractQueue.size() > MAX_TRX_SIZE;
}
This logic only accounts for:
- The standard transaction processing queue (queue)
- The smart contract processing queue (smartContractQueue)
It does not include transactions already stored in the mempool.
In the actual processing flow, once a transaction is executed successfully, it enters the mempool and waits to be packed into a block. Therefore, the overall node load is reflected not only by processing queues but also by the size of cached transactions.
The following mempool-related queues are currently not included in the load calculation:
- pendingTransactions
- rePushTransactions
- pushTransactionQueue
As a result, the load assessment is incomplete.
Reproduction
- Start a node and connect it to the P2P network
- Continuously send transactions to the node so they accumulate in the mempool
- Control the thread pool processing speed to keep queue and smartContractQueue at relatively low levels
- Observe that
isBusy() still reports the node as not busy
- The node continues accepting new transactions while the total cached transaction volume keeps increasing
Impact
- Incomplete load evaluation: mempool transactions are not considered
- Inaccurate resource estimation: the total transaction load on the node is underestimated
- Suboptimal intake control: the node may continue accepting new transactions even when the mempool is already large
Suggested Fix
Include mempool-related transaction counts in the isBusy() calculation and make MAX_TRX_SIZE configurable.
Example:
public boolean isBusy() {
return queue.size()
+ smartContractQueue.size()
+ manager.getPendingSize()
+ manager.getRePushTransactions().size()
+ manager.getPushTransactionQueue().size()
> MAX_TRX_SIZE; // configurable
}
By introducing these additional metrics and making MAX_TRX_SIZE configurable, the node can achieve a more comprehensive understanding of its load. This enables more accurate transaction intake control and allows operators to tune thresholds based on their deployment environment.
Summary
TRON nodes currently determine whether they are in a busy state based only on the size of the transaction processing thread pool queues, without considering the number of transactions already cached in the mempool.
By incorporating both the thread pool queues and the mempool transaction count into the evaluation, the node can more accurately reflect its current load. This enables better control over transaction intake and improves the stability of resource management.
In addition, it is recommended that
MAX_TRX_SIZEbe configurable, allowing flexible adjustment based on the node's deployment environment.Root Cause
The current
isBusy()logic is as follows:This logic only accounts for:
It does not include transactions already stored in the mempool.
In the actual processing flow, once a transaction is executed successfully, it enters the mempool and waits to be packed into a block. Therefore, the overall node load is reflected not only by processing queues but also by the size of cached transactions.
The following mempool-related queues are currently not included in the load calculation:
As a result, the load assessment is incomplete.
Reproduction
isBusy()still reports the node as not busyImpact
Suggested Fix
Include mempool-related transaction counts in the
isBusy()calculation and makeMAX_TRX_SIZEconfigurable.Example:
By introducing these additional metrics and making
MAX_TRX_SIZEconfigurable, the node can achieve a more comprehensive understanding of its load. This enables more accurate transaction intake control and allows operators to tune thresholds based on their deployment environment.