-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concurrent commit IsolatePath type env in root_state, system memory leak #159
Comments
According to your method, I've written a more straightforward test case:
However, there's a difference: I removed an interfering factor from your test case:
The test case is in the cyfs-stack-test project, compiled and run under the following conditions:
During the running process, the memory usage peaks at around 6GB, and when commit complete, the memory usage drops to 160MB. From the perspective of op-env, the memory usage is analyzed as follows: First, let's look at the following code snippet and what it does internally: CYFS/src/tests/cyfs-stack-test/src/case/root_state.rs Lines 789 to 800 in 3fb68f9
Two key points of object_map designLet's start with two key points of object_map design and see how many intermediate objects and result objects are generated during the operation process, as well as the corresponding memory usage:
Therefore, after the 1000 insert_with_path operations above, before the commit, a recycling of the internal objects will be performed. From the analysis of the logs, there are about 1200 temporary objects on average.
In the test case, the size of each (key, value) pair is about 78 bytes. let object_id = ObjectId::from_str("95RvaS5Wy2UZC4Pzy7A6PZTs47bsWLCPtZe834oVvbQ4").unwrap();
let s = object_id.to_string();
let len = object_id.raw_measure(&None).unwrap() + s.raw_measure(&None).unwrap();
println!("len={}", len); So it can be estimated that (65536/78) ≈ 840, so these 1000 operations will eventually cause the root object-map to change modes, switching from simple mode to hub mode, generating a large number of sub object maps, and increasing memory usage. Some results and data analysis obtained by adding some logsFrom the analysis in point 1, we can deduce the distribution of the 1,200 temporary objects mentioned as follows:
Additionally, the logs show that after the 1,000 operations, there are on average around 770 sub object_map child objects created. These child objects need to be saved to the noc during commit. The size of these 770 sub object_maps is not very large, occupying about 71KB. Thus, the total amount of child objects created by a single op-env is about 30MB, with the majority being the size of the temporary objects created by copying. This size is only based on the raw_codec encoding, but the actual memory usage of the Object in memory is much larger. From the test case analysis, it is determined that the actual memory usage of the 2,000 objects generated after 1,000 operations in a single op-env is about 60MB. Some conclusionsBased on the current data analysis, the cache of op-env occupies around 60MB. When 100 op-envs are running concurrently, the total memory usage is about 6GB. Several points need optimization:
|
Regarding the optimization of this case, I built two features about optimization as follows
Welcome to pay attention to relevant progress! |
In addition, during the above test case process, I did not find any memory leak phenomenon. After the commit operation of op-env is completed, the memory usage will decrease to the previous level. However, the performance of the commit operation will be poor under the 100 concurrent situations, which takes a long time. From the test, memory usage can be divided into three stages: CYFS/src/component/cyfs-base/src/objects/object_map/isolate_path_env.rs Lines 361 to 374 in 1cb0c96
So, in your test case, the "memory leak" may be due to op-env not having completed the commit operation, or it could be a side effect caused by other factors introduced in the test case. |
Describe the bug
Concurrent commit IsolatePath type env in root_state, system memory leak
To Reproduce
Each op_env inserts 1000 key values, and 100 concurrent op_env.commit() operations, the system memory overflows and is not released after the commit success
Expected behavior
The overall size of 100,000 key values is only about 40MB, OOD consumes about 69%*4GB=2.8GB of memory, and there should be memory overflow in the op_env.commit operation of CYFS Stack
System information
Linux OOD
4GB memory
The text was updated successfully, but these errors were encountered: