-
Notifications
You must be signed in to change notification settings - Fork 0
Disk management: Global GC stop the universe
In this solution we want to mimic the Java Garbage Collector. Java Garbage Collector needs to stop all processes running in the JVM (STW, stop the world) in order to analyze the heap and check which objects are unreachable. If the JVM are not stopped, there could be new references created during the analysis and Java Garbage Collector decisions would be wrong. New versions of JVM uses different algorithms to avoid blocking during a stop of the world by doing as much work as possible on the background. So, there is some Vms that are almost pause-free.
In dataClay, it is important to know that in our case new references can be created not just on one node but on anyone. Imagine that one node realizes that one of its objects is unreachable from any other object in the node. However, the node is not able to check if any other node is referencing it or, even worse, no object is referencing it but some node is ‘sending’ it as a parameter. Or even even worse, what about if client objects are referencing the object the node wants to delete?
Based on that, this solution proposes a Stop the Universe design, imitating Java’s stop the world. First, we need the following:
- MetaDataService is the node that has all the metadata of the objects like alias, class ID the object belongs to, … In this solution, we add a new information: number of references pointing to the object. Any reference created in the node will update this information including objects currently being used by threads (GC roots)
- All nodes will have a replica of the MetaDataService database. The reason for that is to avoid having too many communications.
- We will have, in each node, information about the ids of objects send and received from clients. Every time we receive a request with an oid as a parameter, we will annotate it as a reference from the session X, and also if we send to client a response with an oid. Every time a session is closed, LM advises the node (broadcast :() to remove any entry using the session X, and the node removes it.
At certain moment, dataClay is completely ‘stopped’, all its nodes stop all requests. The locks for GC Hints explained before can be used for that. This is called Stop the Universe.
First, each node will count, for each object, how many references from client exist using the information of objects send or received from client. These references are added to the number of references pointing to the object. At this point each node knows how many references inside the node or from client are pointing to each object.
Now, the MetaData database of all nodes will be synchronized. For example, if one node has created the object A with 10 references pointing to it but the object A was send to another node that created 10 more, now both nodes will have ‘object A → 20 references’.
The universe continues now.
In background, at this point we know that any object having 0 references:
- Is not pointed by any client
- Any node has the object in memory
- Any node has an object pointing to it
So, we can delete it.
It is not easy to calculate the performance impact of this solution. Let’s say that:
- We have N nodes.
- Per each node, the time spend to synchronize the metadata is Mx where x is the number of the node. Synchronizing metadata could require more than one communication package if the number of objects is huge.
- The node with more Mx is the node Z. The worst case is when there is no concurrency (for many reasons). Then, the maximum time of the stop the universe is:
MaxTime = M1 + M2 + M3 … + Mz
We could think about a ‘distributed stop the universe’. It means that each stop the universe is only focused in one node so MaxTime will be M1, the next MaxTime will be M2, … Remember that each node only checks the objects stored in it. The main problem of this solution is that we should block dataClay. Also, this solution requires sessions to not last forever since a long session retaining objects would affect the cleaning process. Notice that: ‘Stop the universe’ might be necessary for applying enrichments (see later in next section)