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

Make cross-platform #88

Open
vimpunk opened this issue Dec 22, 2020 · 3 comments · May be fixed by #95
Open

Make cross-platform #88

vimpunk opened this issue Dec 22, 2020 · 3 comments · May be fixed by #95
Labels
enhancement New feature or request

Comments

@vimpunk
Copy link
Owner

vimpunk commented Dec 22, 2020

There's really no need to make cratetorrent Linux-only. The only places that rely on platform specific APIs are:

The real issue is the first two. The solution is very simple: feature gate those methods of TorrentFile behind a Linux flag, and fallback to coalescing buffers and issuing a single write call for other platforms.

[update]: It may actually be better to create a fallback of the Piece::write method instead of the lower level TorrentFile::write method.

This is because the current piece write method allocates a temporary buffer of iovecs, which is only needed for the pwritev syscall. However, if we're coalescing buffers and issuing a single write, we can skip the iovecs allocation step and save an allocation and other additional logic. A little more work for better performance.

@vimpunk vimpunk added the enhancement New feature or request label Dec 22, 2020
@vimpunk vimpunk mentioned this issue Dec 22, 2020
24 tasks
@ExceptionallyHandsome
Copy link
Contributor

ExceptionallyHandsome commented Dec 23, 2020

I presume something resembling preadv could be built on top of Overlapped IO on Windows, but I'm not sure it would worth it.

@vimpunk
Copy link
Owner Author

vimpunk commented Dec 30, 2020

That could be a future optimization for sure, but I think for now something simpler is enough. Besides, that solution would not fix incompatibility with mac/darwin/bsd, so someting more generic that is easy to maintain is better for now.

@ExceptionallyHandsome
Copy link
Contributor

ExceptionallyHandsome commented Jan 1, 2021

Actually, Write::write_vectored should be able to replace it entirely. I'll send you a PR tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants