You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dav1d sets the stack size of new worker threads, and initially rav1d did, too. But in order to switch to thread::spawn from the unsafepthread_create, the creation of Rav1dTaskContexts was moved from a Box<[_]> on the main thread's heap to on the stack in each worker thread. This was done to satisfy the borrow checker and ensure the Rav1dTaskContext's lifetime lasted as long as the thread, which aren't scoped. However, Rav1dTaskContext is huge (258,624 bytes), which is larger than a thread's min stack size, which dav1d sometimes set. Moving it to the heap with Box::new doesn't work since Box::new still takes it as an argument on the stack, and the way to directly create it on the heap through Box::new_uninit or Box::new_zeroed is unstable. Low-level alloc APIs could be used directly as well, but they're not ideal either. But since Rust uses a default stack size of 2 MB usually, there's more than enough stack space for Rav1dTaskContext if we don't set it lower. Thus, that's what we'll do for now (in #887). If memory usage of thread stacks proves to be an issue, we can restore the previous/dav1d behavior, perhaps by setting at least mem::size_of::<Rav1dTaskContext>() of stack size, which would be a net equal in memory usage overall.
The text was updated successfully, but these errors were encountered:
dav1d
sets the stack size of new worker threads, and initiallyrav1d
did, too. But in order to switch tothread::spawn
from theunsafe
pthread_create
, the creation ofRav1dTaskContext
s was moved from aBox<[_]>
on the main thread's heap to on the stack in each worker thread. This was done to satisfy the borrow checker and ensure theRav1dTaskContext
's lifetime lasted as long as the thread, which aren't scoped. However,Rav1dTaskContext
is huge (258,624 bytes), which is larger than a thread's min stack size, whichdav1d
sometimes set. Moving it to the heap withBox::new
doesn't work sinceBox::new
still takes it as an argument on the stack, and the way to directly create it on the heap throughBox::new_uninit
orBox::new_zeroed
is unstable. Low-levelalloc
APIs could be used directly as well, but they're not ideal either. But since Rust uses a default stack size of 2 MB usually, there's more than enough stack space forRav1dTaskContext
if we don't set it lower. Thus, that's what we'll do for now (in #887). If memory usage of thread stacks proves to be an issue, we can restore the previous/dav1d
behavior, perhaps by setting at leastmem::size_of::<Rav1dTaskContext>()
of stack size, which would be a net equal in memory usage overall.The text was updated successfully, but these errors were encountered: