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

#1181: GCOV compilation option #1219

Merged
merged 2 commits into from
Mar 26, 2019
Merged

#1181: GCOV compilation option #1219

merged 2 commits into from
Mar 26, 2019

Conversation

krizhanovsky
Copy link
Contributor

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.

…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.
@krizhanovsky krizhanovsky changed the title GCOV compilation option #1181: GCOV compilation option Mar 23, 2019
@krizhanovsky krizhanovsky requested a review from avbelov23 March 23, 2019 15:45
Copy link
Contributor

@i-rinat i-rinat left a 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.

#!/bin/bash
#
# Gcov gather script for Tempesta FW data.
# Mainly bothered from linux/Documentation/dev-tools/gcov.rst
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

borrowed?

Copy link
Contributor

@vankoven vankoven left a 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

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.

4 participants