Object copying with re-copying concurrently written objects
Objects are copied concurrently with mutator execution, while tracking writes to the objects being copied. Objects (or fields) that are written into during copying are re-copied to the same destination locations. Mutators use the original objects until copying is complete and are, in some embodiments, atomically (with respect to the mutators) switched to use the new copies, together with a final re-copy.
1 . In a computing system, a method of copying a set of objects, comprising:
allocating space for a new copy of an original object that is a member of the set of objects;
copying the original object to the space allocated for the new copy;
during the copying, tracking writes to the original object by mutators; and
re-copying the original object to the allocated space if the original object has been written into during copying.
2 . The method of claim 1 , wherein the copying and re-copying take place during a garbage collection cycle and at least one mutator is executing concurrently with the copying.
3 . The method of claim 2 , further comprising updating all references to objects in the set of objects to refer to the corresponding new copies atomically with respect to mutators.
4 . The method of claim 3 , wherein a final re-copy is done atomically with the updating of the references with respect to mutators.
5 . The method of claim 1 , wherein space is allocated for new copies of a plurality of objects that are members of the set before copying the first one of the objects.
6 . The method of claim 1 , wherein the space is allocated from a popular object region.
7 . The method of claim 1 , wherein, in a distributed system, the space is allocated from a node different from the home node of the original object.
8 . The method of claim 1 , further comprising:
during the re-copying, tracking writes to the original object by mutators; and
re-copying the original object a second time to the allocated space if the original object has been written into during the first re-copying.
9 . The method of claim 1 , wherein mutators access the original object but not the new copy during copying and re-copying.
10 . The method of claim 9 , wherein after a mutator has accessed the new copy, it will no longer access the original object.
11 . The method of claim 9 , wherein writes by mutators to a new copy after the last re-copy, but before all mutators have switched to using only new copies, are propagated to the corresponding original object.
12 . The method of claim 9 , wherein, after the last re-copy but before all mutators have ceased accessing any objects in the set, if a write to a new copy is performed by a thread holding a mutex, propagating the write to the original copy before another thread obtains a lock on the mutex.
13 . The method of claim 1 , wherein the re-copying copies the original object to the allocated space in its entirety.
14 . The method of claim 1 , wherein the re-copying copies only the modified fields of the original object to the new copy.
15 . The method of claim 14 , wherein the re-copying is implemented by a write barrier that propagates a write to the original object also to the corresponding field in the new copy.
16 . The method of claim 1 , wherein copying updates any pointers in the new copy pointing to any of the objects in the set to point to their respective new copies.
17 . The method of claim 1 , wherein re-copying updates any pointers in re-copied fields in the new copy pointing to any of the objects in the set to point to their respective new copies.
18 . The method of claim 1 , further comprising:
receiving information from another node in a distributed system indicating that an object in the set has been written into by a mutator during copying; and
re-copying the object in response to receiving such information.
19 . The method of claim 1 , further comprising:
tracking writes by mutators to an object being copied by another node in a distributed system; and
in response to detecting a write to the object, sending information to that other node indicating that the object has been written into.
20 . The method of claim 1 , wherein tracking writes comprises:
using a write barrier to record writes in a thread-local write barrier buffer; and
using a soft synchronization to read the thread-local write barrier buffer.
21 . A computer program product stored on a tangible computer readable medium operable to cause a computer to:
allocate space for a new copy of an original object that is a member of a set of objects to be copied;
copy the original object to the space allocated for the new copy;
track writes to the original object by mutators during the copying; and
re-copy the original object to the allocated space if the original object has been written into during copying.
22 . The computer program product of claim 21 , further operable to cause the computer to perform the allocating, copying, tracking, and re-copying during a garbage collection cycle and concurrently execute mutators.
23 . The computer program product of claim 21 , further operable to cause the computer to:
receive information from another node in a distributed system indicating that an object in the set has been written into by a mutator during copying; and
re-copy the object in response to receiving such information.
24 . The computer program product of claim 21 , further operable to cause the computer to:
track writes by mutators to an object being copied by another node in a distributed system; and
in response to detecting a write to the object, send information to that other node indicating that the object has been written into.
25 . A computing system comprising:
a means for allocating space for a new copy of an original object that is a member of a set of objects to be copied;
a means for copying the original object to the space allocated for the new copy;
a means for tracking writes to the original object during the copying; and
a means for re-copying the original object to the allocated space if the original object has been written into during copying.
26 . The computing system of claim 25 , further comprising a means for collecting garbage, where the means for copying is configured to be active only while the means for collecting garbage is active.
27 . The computing system of claim 26 , further comprising a means for updating references to objects in the set of objects to be copied to refer to the respective new copies atomically with respect to mutators.
28 . The computing system of claim 25 , wherein the means for tracking writes uses a thread-local write barrier buffer for recording the writes.
29 . The computing system of claim 28 , further comprising a means for reading tracked writes using soft synchronization.
30 . A computing system comprising:
an allocator configured to allocate space for a new copy of an original object that is a member of a set of original objects to be copied;
a copier connected the allocator and a memory for copying the original object to the space allocated for the new copy;
a write tracker connected to one or more mutators, configured to track writes to at least one of the original objects during copying; and
a re-copier connected to the write tracker and the memory, configured to re-copy at least one of the original objects to the space allocated for its new copy in response to the write tracker detecting at least one write to it.