Skip to content

Commit 46490f5

Browse files
authored
perf: decrease wantlist send debounce time (#224)
* perf: decrease wantlist send debounce time We wait 200ms before sending wantlists to remote peers which is an eternity. I'm not sure how this figure was arrived at but I've reduced it to 10ms which has increased the js->js transfer times in the interop tests to: | Data | 200ms | 10ms | Speedup | |---------|----------|---------|---------| | 1.02 kB | 486ms | 142ms | 342% | | 63.5 kB | 449ms | 119ms | 377% | | 65.5 kB | 436ms | 105ms | 415% | | 524 kB | 1287ms | 210ms | 613% | | 786 kB | 1676ms | 282ms | 594% | | 1.05 MB | 2066ms | 326ms | 634% | | 1.05 MB | 2123ms | 330ms | 643% | | 4.19 MB | 7091ms | 1045ms | 679% | | 8.39 MB | 13711ms | 1927ms | 712% | | 67.1 MB | 107704ms | 13462ms | 800% | | 134 MB | 214988ms | 26038ms | 826% | * chore: PR comments * chore: decrease debounce to 1ms
1 parent 313ae3b commit 46490f5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ module.exports = {
88
hasBlockTimeout: 15 * SECOND,
99
provideTimeout: 15 * SECOND,
1010
kMaxPriority: Math.pow(2, 31) - 1,
11-
maxListeners: 1000
11+
maxListeners: 1000,
12+
wantlistSendDebounceMs: 1
1213
}

src/want-manager/msg-queue.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const debounce = require('just-debounce-it')
44

55
const Message = require('../types/message')
66
const logger = require('../utils').logger
7+
const { wantlistSendDebounceMs } = require('../constants')
78

89
module.exports = class MsgQueue {
910
constructor (selfPeerId, otherPeerId, network) {
@@ -13,7 +14,7 @@ module.exports = class MsgQueue {
1314

1415
this._entries = []
1516
this._log = logger(selfPeerId, 'msgqueue', otherPeerId.toB58String().slice(0, 8))
16-
this.sendEntries = debounce(this._sendEntries.bind(this), 200)
17+
this.sendEntries = debounce(this._sendEntries.bind(this), wantlistSendDebounceMs)
1718
}
1819

1920
addMessage (msg) {

0 commit comments

Comments
 (0)