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
agent:image: Refactor code to improve memory efficiency of image service #9325
Conversation
cc @Xynnn007 |
a2d87ce
to
8d6a22b
Compare
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a rust expert, but my understanding of this PR is that rather than have the lock().await.clone() on the singleton method which as you say will result in memory duplication, you've effectively moving the clone and lock down only when it's needed in functions, which should reduce the resources. Assuming that I've not missed the point - this makes sense to me. Thanks!
8d6a22b
to
0fb008b
Compare
/test |
098cfa9
to
dcad5ca
Compare
Currently, `.lock().await.clone()` results in `Option<ImageService>` being duplicated in memory with each call to `singleton()`. Consequently, if kata-agent receives numerous image pulling requests simultaneously, it will lead to the allocation of multiple `Option<ImageService>` instances in memory, thereby consuming additional memory resources. In image.rs, we introduce two public functions: `merge_bundle_oci()` and `init_image_service()`. These functions will encapsulate the operations on `IMAGE_SERVICE`, ensuring that its internal details remain hidden from external modules such as `rpc.rs`. Fixes: kata-containers#9225 -- part II Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com> Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
87fca3f
to
f47408f
Compare
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ChengyuZhu6 LGTM!
Currently,
.lock().await.clone()
results inOption<ImageService>
being duplicated in memory with each call tosingleton()
. Consequently, if kata-agent receives numerous image pulling requests simultaneously, it will lead to the allocation of multipleOption<ImageService>
instances in memory, thereby consuming additional memory resources.In image.rs, we introduce two public functions:
merge_bundle_oci()
andinit_image_service()
. These functions will encapsulate the operations onIMAGE_SERVICE
, ensuring that its internal details remain hidden from external modules such asrpc.rs
.Fixes: #9225 -- part II