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

Why are client-level locks reused at the torrent level instead of using locks specific to torrents? #988

Open
Zerolzj opened this issue Oct 30, 2024 · 1 comment

Comments

@Zerolzj
Copy link
Contributor

Zerolzj commented Oct 30, 2024

Recently, while using the torrent reader to read data, I've frequently noticed that due to issues with lock contention, a significant amount of data isn't returned to me for half a minute or even several minutes. This has caused me considerable frustration. I discovered that the locks within the reader are client-level locks, which means that whenever any other torrent is added, the reader may become blocked for a long time. I tried replacing the locks in the reader with torrent-level locks, but found that this requires a substantial amount of work.

I have two questions:

  1. Could you explain why this design decision was made initially?
  2. Would adding torrent-level locks be a good approach in the end?
@anacrolix
Copy link
Owner

Do you have some profiles that show contention on the client level lock? You should be able to use the block profiler.

I've talked about the client level lock in a few other places. I have found that it's appropriate and faster than finer grained locking (although there are some other locks elsewhere in the code in a few places where it provided speed up) in this use case, however that could be changed if there is evidence of contention.

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