5 ms·
They possibly store just the version number for each cookie in shared memory, whereas storing complete cookie data in shared memory would need more synchronizat
by xuhu 2y ago
They possibly store just the version number for each cookie in shared memory, whereas storing complete cookie data in shared memory would need more synchronization.
- kevingadd 2y agoYou could come up with a scheme to store each version of the cookie in an accessible part of the SHM at a fixed address, but then you have to do GC to evict the oldest versions over time without causing problems etc. So I'd bet they are still retrieving the actual cookie contents via an RPC like before.
- tedd4u 2y agoThey don't quite spell it out fully but it seems like a good guess that they use a datatype (like a 64-bit word) for the version number that can be read and written atomically, so no synchronization is needed at all and it can be very fast. So it's only if you don't have the latest version that you do a slower fetch of the updated value (that you can cache) with a mutex to make sure you don't get a partial update.
- OlivierLi 2y agoRight now it’s falling back on a mojo IPC. Next step is indeed shared memory mutex :)
- OlivierLi 2y agoHey, one of the authors here. That’s pretty much it. That said I’m currently working in the next iteration of this which would indeed share more. That said for now it’s not super trivial because it needs a cross-platform condition variable like abstraction that works across shared memory. The pthread based one is not that bad and I’m hacking on it.