-
Notifications
You must be signed in to change notification settings - Fork 1.2k
node.get(hash) and its async iterator hang when data is over 1.5MB #2814
Description
Hey,
I'm working on a web app for a user to challenge the performances of IPFS (only js-ipfs for now).
On start the app spawns two local nodes (nodeA and nodeB).
The user selects a buffer size and then triggers an operation that will in Node create and start a sync queue of the following steps:
- fill the buffer with n times the current date (to get content that is unique on the network)
- nodeA writes the buffer (
nodeA.add(buffer)
) and return the operation time - nodeB reads the buffer (
nodeB.get(cid)
) and return the operation time - a third remote node is reached through a custom HTTP API, reads the buffer and return the operation time
I have noticed that any buffer over about 1.5MB is blocking the queue on the nodeB.get step.
Expanding the get
code (meaning not using of it-all
and it-concat
), I get this:
public async get(hash: string) {
for await (const file of this._node.get(hash)) {
const content = []
for await (const chunk of file.content) {
console.log('chunk:\n', chunk.length)
content.push(chunk.length)
}
}
}
With this console.log
I can see the second for...await loop always stops after 5 iterations.
In short, here's my tests results:
Buffer Size (in MB) | Working? | Number of chunks | Size of last chunk (in bytes) |
---|---|---|---|
1 | Yes | 4 | 213568 |
1.5 | Yes | 5 | 189280 |
1.57 | Yes | 5 | 259280 |
1.58 (and above) | No | 5 | 262144 |
262144B is the maximum size of the chunk (the size of all the chunks received before the last one) so I find it intriguing that the get
request is blocked after 5 full streamed chunks.
I did a parallel test consisting of manually triggering the reads on the remote node (meaning nodeA writes, nodeB tries to read and hangs, and in the meantime I reach the remote node and read from there):
The first request hangs. Stopping it and requesting again works fine.
Unfortunately I cannot measure the read performance in this situation as the content has been partially (if not mostly) downloaded on the node during the broken first request (I assume that since the read time is way shorter than other non-breaking tests results I have).
Any idea why the node.get
hangs there? Any advice for further investigation?
(FYI go-ipfs
has no issue downloading my >1.5MB data, even on the first try)
Edit: here is a light early version of the project