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

task: reduce memory usage #104

Merged
merged 2 commits into from
Sep 6, 2016
Merged

task: reduce memory usage #104

merged 2 commits into from
Sep 6, 2016

Conversation

nokute78
Copy link
Collaborator

Refer to Valgrind, the size of flb_config is about 33KB.

$ valgrind --tool=massif bin/fluent-bit -i cpu -o stdout
.
$ ms_print massif.out.7631 
.
->55.89% (33,120B) 0x41334B: flb_config_init (in /home/taka/git/oss/pull_req/fluentbit_env/fluent-bit/build/bin/fluent-bit)
| ->55.89% (33,120B) 0x41092E: main (in /home/taka/git/oss/pull_req/fluentbit_env/fluent-bit/build/bin/fluent-bit)
.

It is caused by this member.

    struct flb_task_map tasks_map[2048];

flb_task_map is like this.

struct flb_task_map {
    uint8_t id;
    void    *task;
};

So, the size of array tasks_map is (8 + 8) *2048= 32.7KB.

By the way, the value id is used like bool.
So, I deleted id to reduce memory usage.

Signed-off-by: Takahiro YAMASHITA nokute78@gmail.com

Signed-off-by: Takahiro YAMASHITA <nokute78@gmail.com>
@nokute78
Copy link
Collaborator Author

My patch reduces memory usage of flb_config. 33.1KB -> 16.7KB.

Before

$ ms_print massif.out.7631 
.
->55.89% (33,120B) 0x41334B: flb_config_init (in /home/taka/git/oss/pull_req/fluentbit_env/fluent-bit/build/bin/fluent-bit)
| ->55.89% (33,120B) 0x41092E: main (in /home/taka/git/oss/pull_req/fluentbit_env/fluent-bit/build/bin/fluent-bit)
.

After

99.24% (17,070B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
->97.30% (16,736B) 0x41334B: flb_config_init (in /home/taka/git/oss/pull_req/fluentbit_env/fluent-bit/build/bin/fluent-bit)
| ->97.30% (16,736B) 0x41092E: main (in /home/taka/git/oss/pull_req/fluentbit_env/fluent-bit/build/bin/fluent-bit)

@edsiper edsiper merged commit b8b494e into fluent:master Sep 6, 2016
@edsiper
Copy link
Member

edsiper commented Sep 6, 2016

thanks.

fujimotos pushed a commit to fujimotos/fluent-bit that referenced this pull request Jul 22, 2019
* typo

Signed-off-by: Deirdre Storck <deirdre.storck@gmail.com>

* quick fixes

Signed-off-by: Deirdre Storck <deirdre.storck@gmail.com>
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

Successfully merging this pull request may close these issues.

2 participants