hypercloud icon indicating copy to clipboard operation
hypercloud copied to clipboard

Need to close() and possibly pool hypercore instances

Open pfrazee opened this issue 9 years ago • 3 comments

AFAICT, via random-access-file, hypercore opens a file-descriptor for every instance, and doesn't close the FD until .close() is called. We definitely don't want to leak those.

Any time hypercore-archiver's get() method is called (eg in archiver-api's archiveProgress() method) a hypercore instance is created. Thus, another FD is created, and not cleaned up.

Two thoughts on that:

  1. We need to be sure to clean up all hypercores by .close()ing them
  2. Should we be pooling hypercore instances instead of creating them with .get() every time?

pfrazee avatar Dec 30 '16 02:12 pfrazee

Alternatively, we could pool random-access-file instances, but in either case we'll still need to .close the hypercores

pfrazee avatar Dec 30 '16 02:12 pfrazee

Archiver-server has a solution we can consider: an LRU cache.

pfrazee avatar Jan 04 '17 02:01 pfrazee

Should we be pooling hypercore instances instead of creating them with .get() every time?

Ya, we could definitely optimize the get to not create them every time. Seems like a LRU cache would be the most straightforward way to implement that.

joehand avatar Jan 04 '17 03:01 joehand