Friday Facts #408 - Statistics improvements, Linux adventures

Regular reports on Factorio development.
yangbowen1028
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Apr 09, 2019 7:08 am
Contact:

Re: Friday Facts #408 - Statistics improvements, Linux adventures

Post by yangbowen1028 »

the80srobot wrote: Sun Oct 20, 2024 9:44 pm 3. You now have a file descriptor for the part of the CoW address space and your C runtime is not going to deadlock.
4. Do crazy things to read and your game from the address space snapshot
I'm unfamiliar with Linux. But if I understand it correctly, this would mean the async saver could only access that CoW address space indirectly by some file descriptors, instead of directly accessing the data structures like in the same process. Even if that file descriptor gets mmap-ed, it wouldn't be at the same virtual address, would it?
So for example a pointer resides in such data structures, then you cannot just dereference that pointer since whatever stuff it was pointing at is no longer at the same virtual address. Similarly you can't just call the member functions to do various things, but have to invent specific ways to decode those in-memory representations. It seems to me that this would be too much work if feasible at all.
To say it another way, the best thing about fork is that you can access all your stuff pretending nothing has happened. Except that it's actually a lot trickier.
pleegwat
Filter Inserter
Filter Inserter
Posts: 278
Joined: Fri May 19, 2017 7:31 pm
Contact:

Re: Friday Facts #408 - Statistics improvements, Linux adventures

Post by pleegwat »

The first argument to mmap() is the target address to map to. Of course, the kernel can only respect that if no other memory is in the way (and page alignment is met, but that should not be a problem in this case). Otherwise, you'd simply have to avoid pointers and use offsets instead.
Post Reply

Return to “News”