Skip to content
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

RED-235: add queueLengthAll and tx age buckets to report #232

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/p2p/Sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ export function digestCycle(cycle: P2P.CycleCreatorTypes.CycleRecord, source: st
cycle.archiverListHash = Archivers.computeNewArchiverListHash()

// for join v2, also get the standby node list hash
if (config.p2p.useJoinProtocolV2) {
// [TODO] We can remove `source !== 'syncV2'` once we shut down ITN2
if (config.p2p.useJoinProtocolV2 && source !== 'syncV2') {
cycle.standbyNodeListHash = JoinV2.computeNewStandbyListHash()
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/reporter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,10 @@ class Reporter {
// Server load
const currentNetworkLoad = this.loadDetection.getCurrentLoad()
const currentNodeLoad = this.loadDetection.getCurrentNodeLoad()
let queueLength = this.statistics.getPreviousElement('queueLength')
const queueLengthAll = this.statistics.getPreviousElement('queueLength')
const executeQueueLength = this.statistics.getPreviousElement('executeQueueLength')
queueLength = executeQueueLength //debug hack until the monitor client can show this
const queueLength = executeQueueLength
const queueLengthBuckets = this.stateManager.transactionQueue.getQueueLengthBuckets()
const txTimeInQueue = this.statistics.getPreviousElement('txTimeInQueue') / 1000 // ms to sec
const maxTxTimeInQueue = this.statistics.getMax('txTimeInQueue') / 1000
const isNodeLost = this.checkIsNodeLost(Self.id)
Expand Down Expand Up @@ -365,8 +366,10 @@ class Reporter {
networkLoad: currentNetworkLoad,
nodeLoad: currentNodeLoad,
},
queueLengthAll,
queueLength,
executeQueueLength,
queueLengthBuckets,
txTimeInQueue,
maxTxTimeInQueue,
rareCounters,
Expand Down
43 changes: 36 additions & 7 deletions src/state-manager/TransactionQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8482,6 +8482,7 @@ getDebugStuckTxs(opts): unknown {
getDebugQueueInfo(queueEntry: QueueEntry): any {
return {
txId: queueEntry.acceptedTx.txId,
tx: queueEntry.acceptedTx,
logID: queueEntry.logID,
nodeId: Self.id,
state: queueEntry.state,
Expand All @@ -8500,18 +8501,18 @@ getDebugStuckTxs(opts): unknown {
dataSharedTimestamp: queueEntry.dataSharedTimestamp,
firstVoteTimestamp: queueEntry.firstVoteReceivedTimestamp,
lastVoteTimestamp: queueEntry.lastVoteReceivedTimestamp,
firstConfirmationsTimestamp: queueEntry.firstConfirmOrChallengeTimestamp,
robustBestConfirmation: queueEntry.receivedBestConfirmation,
robustBestVote: queueEntry.receivedBestVote,
robustBestChallenge: queueEntry.receivedBestChallenge,
completedRobustVote: queueEntry.robustQueryVoteCompleted,
completedRobustChallenge: queueEntry.robustQueryConfirmOrChallengeCompleted,
// firstConfirmationsTimestamp: queueEntry.firstConfirmOrChallengeTimestamp,
// robustBestConfirmation: queueEntry.receivedBestConfirmation,
// robustBestVote: queueEntry.receivedBestVote,
// robustBestChallenge: queueEntry.receivedBestChallenge,
// completedRobustVote: queueEntry.robustQueryVoteCompleted,
// completedRobustChallenge: queueEntry.robustQueryConfirmOrChallengeCompleted,
txDebug: queueEntry.txDebug,
executionDebug: queueEntry.executionDebug,
waitForReceiptOnly: queueEntry.waitForReceiptOnly,
ourVote: queueEntry.ourVote || null,
receipt2: this.stateManager.getReceipt2(queueEntry) || null,
uniqueChallenges: queueEntry.uniqueChallengesCount,
// uniqueChallenges: queueEntry.uniqueChallengesCount,
collectedVoteCount: queueEntry.collectedVoteHashes.length,
simpleDebugStr: this.app.getSimpleTxDebugValue ? this.app.getSimpleTxDebugValue(queueEntry.acceptedTx?.data) : "",
}
Expand Down Expand Up @@ -8565,6 +8566,34 @@ getDebugStuckTxs(opts): unknown {
this.debugLastAwaitedCallInnerStack = {}
this.debugLastAwaitedAppCallStack = {}
}

getQueueLengthBuckets(): any {
const buckets = { c15: 0, c60: 0, c120: 0, c600: 0 };

if (!this._transactionQueue || this._transactionQueue.length === 0) {
return buckets;
}

const currentTime = shardusGetTime();

this._transactionQueue.forEach((queueEntry) => {
if (queueEntry && queueEntry.acceptedTx && queueEntry.acceptedTx.timestamp) {
const txAgeInSeconds = (currentTime - queueEntry.acceptedTx.timestamp) / 1000

if (txAgeInSeconds >= 15 && txAgeInSeconds < 60) {
buckets.c15++
} else if (txAgeInSeconds >= 60 && txAgeInSeconds < 120) {
buckets.c60++
} else if (txAgeInSeconds >= 120 && txAgeInSeconds < 600) {
buckets.c120++
} else if (txAgeInSeconds >= 600) {
buckets.c600++
}
}
})

return buckets;
}
}

export default TransactionQueue
Loading