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

createHistoryStream is slow over net #281

Open
arj03 opened this issue Jan 31, 2020 · 3 comments
Open

createHistoryStream is slow over net #281

arj03 opened this issue Jan 31, 2020 · 3 comments
Assignees

Comments

@arj03
Copy link
Member

arj03 commented Jan 31, 2020

There is something wrong with createHistoryStream over a network connection. Locally it takes around 600ms, using net protocol the same call takes 6.500ms and using ws the exact same call takes 20.000ms?

var pull = require('pull-stream')

var remote = 'ws:between-two-worlds.dk:8989~shs:lbocEWqF2Fg6WMYLgmfYvqJlMfL7hiqVAV6ANjHWNw8=.ed25519'
//remote = 'net:between-two-worlds.dk:8008~shs:lbocEWqF2Fg6WMYLgmfYvqJlMfL7hiqVAV6ANjHWNw8=.ed25519'

require('ssb-client')({ remote }, (err, sbot) => {
  if (err) throw err
  console.time("downloading messages")
  pull(
    sbot.createHistoryStream({id: '@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519', seq: 27000, keys: false}),
    pull.drain((msg) => {
      console.log(msg)
    }, (err) => {
      if (err) throw err

      console.timeEnd("downloading messages")
      sbot.close()
    })
  )
})

The problem seems to be buried in the legacy protocol for ssb-replication somewhere.

I havn't had time to properly debug this. But to confirm I made a plugin to help debug.

CC @staltz @cryptix as you are talking about initial sync

@dominictarr
Copy link
Contributor

Oh something that might be related but not sure, this might be interacting badly with nagle (buffering on tcp). Especially since pull-box-stream writes the packet header then the packet... disabling nagle would be easy to confirm. I havn't had time to test it yet.

@arj03
Copy link
Member Author

arj03 commented Feb 3, 2020

That sounds wierd. The plugin I linked just exposes the method and this is fast, so I don't think nagle is the problem we are seing here unless there is some wierd interaction between the legacy protocol and that.

@stale
Copy link

stale bot commented May 3, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

@stale stale bot added the stale label May 3, 2020
@arj03 arj03 self-assigned this May 3, 2020
@stale stale bot removed the stale label May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants