Post by Steven SilotiAs a first step towards implementing the new memory mapped I/O[1] design
I'm going to start working on a scaleable thread pool. It'll be a
separate class from disk_io_thread which will also hold the job queue
and related synchronization primitives so that we can easily create
multiple pools. For now there will be two pools, one for hash jobs and
one for everything else. If anyone (ok, Arvid) has conflicting plans let
me know.
What about separating reading and writing into separate threads?
Post by Steven Siloti[1] https://github.com/arvidn/libtorrent/wiki/memory-mapped-I-O
The only concern I would have starting at the thread pool-end would be that
it would likely (at least as far as I can tell) take a long time to get to
a state that can replace the current thread pool.
My idea (I wouldn't really call it a plan yet) was to mutate the current
disk_io_thread into the new architecture. The idea being that it's easier
to remove and replace code gradually than to start from scratch. Granted,
there can be benefits with starting from scratch and I think some aspects
should probably be done from scratch. However, having something that works
while working on it is really useful. It allows for incremental testing and
possibly merging interim versions to master.
I would be especially concerned that there may be some subtle problems
that's currently solved, that would need some thought (but haven't been
discovered yet) to fit into the new system. For instance:
1. the job fence mechanism right now, for locking torrents during certain
operations.
2. the block_cache (or something similar to it, and probably a lot simpler)
would be used for the job queue itself. It's possible this could be put of
as an optimization though.
I was going to list the mechanism for posting back job completion handlers
to the main thread too (which you recently touched). But I suppose this
would be significantly simpler now too, since jobs would never be deferred
(as they are now, hanging on pieces in the cache).
I imagine the disk_io_thread interface could remain more or less intact, at
least for a long time, while gutting and replacing the implementation. I
believe that would help contain the changes and break it down into smaller
and more manageable patches. I do expect the current storage_interface
would have to go entirely. I think it would still make sense to have some
customization point for storage, but I think the disk_io_thread interface
may be more appropriate for that going forward.
1. scrap storage_interface (but probably preserve the fundamental piece <->
file mapping in default_storage)
2. the file_pool would morph into a mapping_pool, keeping an LRU (or
something) of mapped areas of files. (perhaps this could be put off as an
optimization as well. However, I believe python on windows is still running
as a 32 bit process)
To put things in perspective though, I would greatly appreciate any work
you put in towards this, so if you think my arguments are weak, please feel
free to ignore them!
--
Arvid Norberg