Skip to content
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

The protobuf library 0.3.0 memory usage is about 300KB higher than 0.28.0 #728

Open
zzzzzzzzzy9 opened this issue May 21, 2024 · 3 comments

Comments

@zzzzzzzzzy9
Copy link

I'm using the open source repository containerd/rust-extensions. When I use protobuf 0.28.0, the memory cost is about 900KB. But when I use protobuf 0.3.0 or 0.4.0, the momory usage is abot 1200KB.
I used the valgrind memory capture tool to collect the memory of the process, and the result is as follows:

  1. for 0.3.0 or 0.4.0
  2. for 0.28.0

By analyzing the results, I found that the function file_descriptor takes up about 300KB of heap memory. This function is in the end of file /src/descriptor.rs. This function was not available in version 0.28.0.

Also, I found that the Message struct in 0.28.0 became the current MessageFull struct, and when I removed the related dependencies of the messageFull struct in the containerd/rust-extensions project (which of course caused the rust-extensions project to not work properly) I noticed that the memory dropped by about 400KB.

I cannot use Message struct in 0.3.0 because of PartialEq.

The differences between 0.28.0(/src/message.rs) and 0.3.0(/src/message.rs and /src/messagedyn.rs):

  1. 0.28.0
    pub trait Message: fmt::Debug + Clear + Any + Send + Sync { .....
  2. 0.3.0
    pub trait Message: Default + Clone + Send + Sync + Sized + PartialEq + 'static {
    pub trait MessageDyn: Any + fmt::Debug + fmt::Display + Send + Sync + 'static {
    We can see that in 0.3.0 static is used in both the Message struct and the MessageDyn struct, but not in 0.28.0

I wonder what the modification of the Message struct and the addition of file_descriptor functions are? Does it really need to be defined as static? This results in an unusually large memory overhead.

@zzzzzzzzzy9
Copy link
Author

@stepancheg

@stepancheg
Copy link
Owner

Version 0.3 is prehistoric. Current version is 3.x.

@zzzzzzzzzy9
Copy link
Author

zzzzzzzzzy9 commented May 24, 2024

Oh, I'm sorry. It is 2.28.0/2.27.1 and 3.3.0/3.4.0. @stepancheg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants