-
Notifications
You must be signed in to change notification settings - Fork 105
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
#1181: GCOV compilation option #1219
Conversation
…o build http_parser.c with "profile-use=/root/tempesta/http_parser.c.gcov" in #pragma GCC optimize. http_parser.c.gcov is generated by $ cd ~/tempesta $ ./scripts/gcov_gather.sh /tmp/gcov.tgz $ cd /tmp && tar -zxf gcov.tgz && cd - $ gcov -o /tmp/sys/kernel/debug/gcov/root/tempesta/tempesta_fw http_parser.c perf(1) also can be used for the profile generation, see -fauto-profile GCC command line option. PGO generates slightly better code layout, but the profile counts total samples and doesn't record sequence of called code. E.g. for a normal HTTP request the parser spends more time in URI processing than in method processing, so PGO moves URI before method processing which is completely wrong. The second drawback of PGO is that each code update requires regeneration of the profile. Moreover, in general it's tricky to correctly choose the right workload for the profile, so it looks more like workload programming than the parser programming. All in all, I leave the GCOV compilation option only for the test coverage and we need to use more flexible way to generate proper code layout.
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.
Looks good to me.
scripts/gcov_gather.sh
Outdated
#!/bin/bash | ||
# | ||
# Gcov gather script for Tempesta FW data. | ||
# Mainly bothered from linux/Documentation/dev-tools/gcov.rst |
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.
borrowed?
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.
Looks good to me
The option is useful for profile guided optimization (PGO). I tried to build
http_parser.c with "profile-use=/root/tempesta/http_parser.c.gcov" in #pragma
GCC optimize. http_parser.c.gcov is generated by
$ cd ~/tempesta
$ ./scripts/gcov_gather.sh /tmp/gcov.tgz
$ cd /tmp && tar -zxf gcov.tgz && cd -
$ gcov -o /tmp/sys/kernel/debug/gcov/root/tempesta/tempesta_fw http_parser.c
perf(1) also can be used for the profile generation, see -fauto-profile GCC
command line option.
PGO generates slightly better code layout, but the profile counts total
samples and doesn't record sequence of called code. E.g. for a normal HTTP
request the parser spends more time in URI processing than in method
processing, so PGO moves URI before method processing which is completely
wrong.
The second drawback of PGO is that each code update requires regeneration of
the profile. Moreover, in general it's tricky to correctly choose the right
workload for the profile, so it looks more like workload programming than the
parser programming.
All in all, I leave the GCOV compilation option only for the test coverage and
we need to use more flexible way to generate proper code layout.