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
Global process counter and table #100
Conversation
Getting pids for processes no longer needs to go through the Process's Environment.
Process by pid map is moved to process::local. Processes are always passed as immutable pointers and interior mutability is used to support global process map trait requirements and to support smaller locks for future work.
One thing I think we'll want to steal from BEAM is the way process locks are designed (i.e. the hierarchical locking system). If you need to access more than one locked field of the process, it is trivially easy to deadlock without that design. Thoughts? |
I thought you were supplying the hierarchical lock system as part of your GC work because It wouldn’t have the arenas anymore. If you’re not doing that part, I can switch the locks to be nested on top of this. This was doing just enough to make register/2 work on top of it. |
@KronicDeth I am supplying the actual locking primitives with the allocator framework, but the hierarchical locking system for processes is more general than allocation/GC, and I've been trying to keep my hands off the process stuff until I get allocation finished. You are right that the arenas are going away, but the locks are still needed for things that are otherwise part of the PCB (things like sending messages, scheduling, etc.). Probably not a change that is needed for this PR per se, but figured I would bring it up, since it seems to be related. |
Looking at erl_process_locl.h, I think all the mutexes would fall under the |
Yeah that sounds like the way to go to me for now, once we add in some of the other capabilities, then the more complex locking setup can be implemented. That specific lock design is not something I have implemented as part of the allocator framework, since it is pretty unique to this specific area of the system, and I wasn't sure how much we would have in common with BEAM as things evolved, but I suspect we will want to copy it - it is fairly complex, but is one area that the OTP team put a ton of engineering effort in order to make things performant (on multithreaded systems anyway) |
Changelog
Enhancements
Process
'sEnvironment
.process::local
.Process
es are always passed as immutable references and interior mutability is used to support global process map trait requirements and to support smaller locks for future work.Arc
s around arenas when it is know the callers would always be in the same process.impl Process
to eliminate need forRefCell
.Send
andSyn
onProcess
.im_rc
toim
so that the map arena isSend
.heap::Binary
Send
to override*const u8
inbytes
not beingSend
.heap::Binary
are immutable after create, so they can be safelySend
even with the raw pointer.Process
inMutex
. In most cases there will only be one be accessed by the one scheduler thread. TheMutex
is only needed to makeSync
derivation happy and potentially during scheduler hand-off.Incompatible Changes
Environment
as anything that would have been in theEnvironment
will not be global to eliminate unnecessary pointer hops.