From 03c4d93f36f2bba455456d5b9ae0208d1461d424 Mon Sep 17 00:00:00 2001 From: u5surf Date: Mon, 1 Jan 2024 22:19:20 +0900 Subject: [PATCH] Add example of build process for PGO supported binary #283 --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 6729d9d..27db659 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,38 @@ Earlier versions is not tested. 4. Install the nginx binary. +### Instralltion with Profile-Guided Optimization + +It can be built with Profile-Guided Optimization (PGO) using gcc `fprofile` options. The detail of the PGO mechanisms has refer to the section 7.4 of [this paper](https://people.freebsd.org/~lstewart/articles/cpumemory.pdf). +Here is an example of the process to make a PGO supported binary. Please use at your own risk. + +1. Compile with fprofile-generate. + + ``` + shell> pwd + /somewhere/nginx + shell> CC=gcc ./auto/configure --with-cc-opt='-fprofile-generate -fprofile-dir=./objs' --with-ld-opt='-lgcov' --add-module=/somewhere/nginx-module-vts + shell> make + ``` + +2. Execute this module tests. + + ``` + shell> pwd + /somewhere/nginx-module-vts + shell> sudo PATH=/somewhere/nginx/objs:$PATH prove -r t/000.display_html.t + ...(during runtime it records coverage data into .gcda files) + ``` + +3. Recompile with fprofile-use + + ``` + shell> pwd + /somewhere/nginx + shell> CC=gcc ./auto/configure --with-cc-opt='-fprofile-use -fprofile-dir=/somewhere/nginx-module-vts/objs' --with-ld-opt='-lgcov' --add-module=/somewhere/nginx-module-vts + shell> make + ``` + ## Synopsis ```Nginx