Skip to content

Commit

Permalink
PeerMessageQueue: actually use the 10% bulk fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBab committed Nov 13, 2024
1 parent e71bd03 commit 44bfc61
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/freenet/node/PeerMessageQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -876,22 +876,20 @@ public synchronized MessageItem grabQueuedMessageItem(int minPriority) {
if(ret != null) return ret;
}

// Include bulk or realtime, whichever is more urgent.

boolean tryRealtimeFirst = this.fastWeakRandom.nextInt(10) > 0;

// If one is empty, try the other.
// Otherwise try whichever is more urgent, favouring realtime if there is a draw.
// Realtime is supposed to be bursty.


// Include bulk or realtime, whichever is more urgent.
boolean tryRealtimeFirst;
if(queuesByPriority[DMT.PRIORITY_REALTIME_DATA].isEmpty()) {
tryRealtimeFirst = false;
} else if(queuesByPriority[DMT.PRIORITY_BULK_DATA].isEmpty()) {
tryRealtimeFirst = true;
} else if(queuesByPriority[DMT.PRIORITY_BULK_DATA].getNextUrgentTime(Long.MAX_VALUE, 0) >= queuesByPriority[DMT.PRIORITY_REALTIME_DATA].getNextUrgentTime(Long.MAX_VALUE, 0)) {
} else if(queuesByPriority[DMT.PRIORITY_BULK_DATA].getNextUrgentTime(Long.MAX_VALUE, 0)
>= queuesByPriority[DMT.PRIORITY_REALTIME_DATA].getNextUrgentTime(Long.MAX_VALUE, 0)) {
tryRealtimeFirst = true;
} else {
tryRealtimeFirst = false;
// 10% chance to use bulk in case of a draw to avoid starving the bulk queue.
tryRealtimeFirst = this.fastWeakRandom.nextInt(10) > 0;
}


Expand Down

0 comments on commit 44bfc61

Please sign in to comment.