Skip to content

Performance optimization: create a new torrent repository using a SkipMap instead of a BTreeMap #777

Closed
@josecelano

Description

@josecelano

Relates to: #774

To simplify the description of the issue, we can say that we are using a torrent repository like this:

type TorrentRepository = BTreeMap<InfoHash, TorrentEntry>

struct TorrentEntry {
  peers: BTreeMap<PeerId, Peer>,
  downloaded: u32,
}

Check the discussion for more details.

One performance optimization proposal was to replace the outer BTreeMap with a data structure that allows for the simultaneous insertion of new torrents.

Another issue is trying with a different structure: a DashMap.

DashMap is based on sharding and does not keep the order of items. The other issues have not been merged yet because we need the order for the API. However, we are also discussing if we need to keep the order and what order to use.
The DashMap API is also very different to the BTreeMap one.

On the other hand, SkipMap API is very similar to the BTreeMap, and it keeps items ordered. Since the effort to implement was not too big I decided to do it.

SkipMap is being used in other trackers in Rust (https://github.com/Power2All/torrust-actix).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions