Implement GC for RHT Node
raararaara opened this issue · 2 comments
What would you like to be added:
Add a feature to RHT that allows the removal of attributes from elements
Currently, when performing Tree.RemoveStyle and calling RHT.Remove, the actual removal from the map is not performed. This is to avoid potential convergence issues in concurrent editing scenarios. Instead, the RHT Node is marked as isRemoved.
yorkie/pkg/document/crdt/rht.go
Lines 122 to 123 in 5ce2aa3
However, this approach of just marking the nodes as isRemoved can lead to memory issues if the number of marked RHT Nodes keeps increasing. Therefore, it is necessary to implement a garbage collector that handles tombstones to remove the marked nodes from memory.
Why is this needed:
To address potential memory issues caused by the increasing number of marked RHT Nodes and improve the efficiency of the RHT implementation.
Since Go automatically handles the garbage collection for objects that are not being referenced, there's no need for specific garbage collection implementation for rhtNode. Hence, I'm closing this issue.
Additionally, it seems that garbage collection for ElementRHT, which is already implemented, may not be necessary. I'll address the garbage collection removal for ElementRHT in a new issue.
The case where the reference count becomes 0 is when the value corresponding to the existing key is overwritten in the process of RHT.set
. Therefore, there is no need for gc logic in RHT.set.
In the case of RHT.Remove
, however, it is still a required specification in the concurrent editing scenario, so I reopen the issue.