GithubHelp home page GithubHelp logo

Comments (10)

topac avatar topac commented on June 1, 2024

I've just took a look at this old code and it seems so.
As you suggest, the correct solution should be 1 connection kept-alive and per host per thread.

I'll ping you for a review of the new code soon :)

from rmega.

baconwaifu avatar baconwaifu commented on June 1, 2024

Some testing says that there's nothing that breaks if using a per-thread connection pool (technically per-fiber, using Thread.current) but there is another issue stopping that from doing anything: Pool creates a new thread for every single chunk, rather than keeping threads alive for as long as possible.

Modifying Pool so that threads live until they run out of work, only creating new threads up to the limit seems to work fine. but that reveals another issue: there's no coherent place to call 'finish' for HTTP requests. It would require quite a bit more "upwards visibility" in the network stack, or an open/close interface in Net (what I'm about to try)

from rmega.

baconwaifu avatar baconwaifu commented on June 1, 2024

tested adding an http_wrap method in Net, and wrapping the each_chunk in it. Opens a connection to the storage server even if one may not be needed, but it seems to work? it's at least re-using the HTTP objects. Another possible (albeit hacky) solution is to simply keep all userstorage.mega.co.nz connections open for the lifetime of the thread, and let the GC close them.

from rmega.

baconwaifu avatar baconwaifu commented on June 1, 2024

Just tested a dirty workaround (let the GC close the userstorage connections for us), can confirm persistent connections make a huge difference in speed. it's now capable of hitting 100Mbps on 4 threads.

from rmega.

topac avatar topac commented on June 1, 2024

checkout this new branch https://github.com/topac/rmega/tree/conn_pool

from rmega.

topac avatar topac commented on June 1, 2024

@baconwaifu have you tried using the changes from the conn_pool branch?

from rmega.

baconwaifu avatar baconwaifu commented on June 1, 2024

from rmega.

vijayanandnandam avatar vijayanandnandam commented on June 1, 2024

using Typhoeus instead of plain net/http should work. Typhoeus already handles http connection pooling

from rmega.

topac avatar topac commented on June 1, 2024

@vijayanandnandam sure but I would like to not have dependencies on other gems

from rmega.

topac avatar topac commented on June 1, 2024

this was merged

from rmega.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.