Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Follow-up to read stream lag #1863

Closed
Closed
@lifeBCE

Description

@lifeBCE
  • Version:
    0.34.2

  • Platform:
    Darwin MacBook-Pro.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

  • Subsystem:
    Potential Bitswap but not sure

Type:

Bug

Severity:

Medium

Description:

This is a follow up to #1706

I am still seeing an average 8 second delay when streaming blocks before the stream will emit its data event only if the length argument is omitted or large.

Steps to reproduce the error:

const IPFS = require('ipfs');
const pull = require('pull-stream')
const type = process.argv[2];

console.log('Instantiating IPFS node');
const node = new IPFS();
const hash = 'QmRm5YAWoudjGj926YKc2PuBFX7vTp2YzqbWFdmqyqWRQS';
const streamFunc = type === 'readable' ? node.catReadableStream : node.catPullStream;
let dataEvent = false;

node.on('ready', () => {
  console.log('IPFS node is ready');
  const readyTime = Math.floor(Date.now() / 1000);

  // This length value produces the 2 second delay from original issue
  // const stream = streamFunc(hash, { offset: 0, length: 5000000 });

  // This will produce the average 8 second delay but so will any large value of length
  const stream = streamFunc(hash);
  console.log('Stream has been created, waiting for data....');

  const pullable = () => {
    pull(
      stream,
      pull.concat((err, data) => {
        if (!dataEvent) {
          dataEvent = true;
          const dataTime = Math.floor(Date.now() / 1000);
          console.log('Stream is receiving data: ' + Math.floor(dataTime - readyTime) + ' seconds');
        }
      })
    )
  }

  const readable = () => {
    stream.on('data', (block) => {
      if (!dataEvent) {
        dataEvent = true;
        const dataTime = Math.floor(Date.now() / 1000);
        console.log('Stream is receiving data: ' + Math.floor(dataTime - readyTime) + ' seconds');
      }
    })

    stream.on('end', () => node.stop());
  }

  type === 'readable' ? readable() : pullable();
})

node.on('error', error => {
  console.error(error.message);
})

Note: May want to change the hash value to something in your test env.

Being a stream function, my expectation is that the size of the file or bytes being requested should not have an impact on the time to initial data event trigger. Worth mentioning that I am using go-ipfs as the websocket bootstrap server behind nginx.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions