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

NRT thread can block disk I/O thread #5511

Open
Spacechild1 opened this issue Jul 17, 2021 · 4 comments
Open

NRT thread can block disk I/O thread #5511

Spacechild1 opened this issue Jul 17, 2021 · 4 comments
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs.

Comments

@Spacechild1
Copy link
Contributor

The disk I/O thread in DiskIO_UGens.cpp locks the NRT thread when it wants to write data from the buffer to the disk. AFAICT, this is only necessary because the user might accidentally free the buffer concurrently (which shouldn't really happen).

I understand that (ab)using Server sound buffers for disk I/O is convenient because it already handles the opening and closing of soundfiles. However, it also means the disk I/O thread is implicitly tied to the NRT thread, which kind of defeats the whole purpose of having a dedicated disk I/O thread in the first place...

Note that asynchronous commands executed on the NRT thread can take an arbitrary amount of time!

This causes problems such as this: https://git.iem.at/pd/vstplugin/-/issues/58

@Spacechild1 Spacechild1 added the bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. label Jul 17, 2021
@joshpar
Copy link
Member

joshpar commented Jul 18, 2021 via email

@Spacechild1
Copy link
Contributor Author

Spacechild1 commented Jul 18, 2021

No, DiskIn and VDiskIn contain different code paths for RT and NRT synthesis. The latter doesn't use the disk I/O thread at all, instead it reads from the file synchronously.


BTW, I find it strange that DiskOut does use the disk I/O thread in NRT mode. There is basically no synchronization between the main thread and the I/O thread, so if the latter can't catch up with the former, it would drop audio... I think it should write to disk synchronously instead.

@joshpar
Copy link
Member

joshpar commented Jul 18, 2021

I'm surprised. I've used DiskOut a LOT for large NRT files without any problems. Regardless - if you propose any changes, please make sure reading and writing for those UGens in NRT still works. Thanks!

@Spacechild1
Copy link
Contributor Author

I've used DiskOut a LOT for large NRT files without any problems

That's interesting to know! In practice it's not a problem if the buffer is sufficiently big, but it's definitely not safe.

please make sure reading and writing for those UGens in NRT still works

Sure, good point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs.
Projects
None yet
Development

No branches or pull requests

2 participants