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
Note: I assume people are using malloc other than snmalloc, which says
snmalloc's design is particular well suited to the following two difficult scenarios that can be problematic for other allocators:
Allocations on one thread are freed by a different thread
Deallocations occur in large batches
Dropping a Box or Vec from another thread than the one it's created from involves an atomic operation.
It works, but for Program, we have one important fact we can exploit - almost all Box and Vec in one Program are allocated by the parser, and within a single thread. It means, we actually don't have to pay for all atomic operations in nested fields.
We can have a field with a type like oneshot::Sender<ast::Program> along with the ast::Program, and send it back to the thread the Program is created from.
Obviously, this will make the code more complex, but it will save enormous amount of atomic operations.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Note: I assume people are using malloc other than
snmalloc
, which saysDropping a
Box
orVec
from another thread than the one it's created from involves an atomic operation.It works, but for
Program
, we have one important fact we can exploit - almost allBox
andVec
in oneProgram
are allocated by the parser, and within a single thread. It means, we actually don't have to pay for all atomic operations in nested fields.We can have a field with a type like
oneshot::Sender<ast::Program>
along with theast::Program
, and send it back to the thread theProgram
is created from.Obviously, this will make the code more complex, but it will save enormous amount of atomic operations.
Beta Was this translation helpful? Give feedback.
All reactions