Skip to content

Commit d47d060

Browse files
committed
build: Introduce PGO.
1 parent c80d484 commit d47d060

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

.gitattributes

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Helps Git use the right algorithms for diffs
22
# https://git-scm.com/docs/gitattributes
3-
43
# Auto detect text files and perform LF normalization
54
# https://www.davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
65
* text=auto
7-
86
# Front-end
97
*.css text eol=lf diff=css
108
*.htm text eol=lf diff=html
@@ -15,7 +13,6 @@
1513
*.scss text eol=lf diff=css
1614
*.ts text eol=lf
1715
*.xhtml text eol=lf diff=html
18-
1916
# Documents
2017
*.bibtex text diff=bibtex
2118
*.doc diff=astextplain
@@ -47,12 +44,10 @@
4744
*.mdtxt text eol=lf diff=markdown
4845
*.mdtext text eol=lf diff=markdown
4946
*.txt text eol=lf
50-
5147
# "Files"
5248
Dockerfile text eol=lf
5349
Makefile text eol=lf
5450
*README* text eol=lf
55-
5651
# Graphics
5752
*.png binary
5853
*.jpg binary
@@ -65,7 +60,6 @@ Makefile text eol=lf
6560
*.svg text eol=lf
6661
*.svgz binary
6762
*.webp binary
68-
6963
# Scripts
7064
*.bash text eol=lf
7165
*.fish text eol=lf
@@ -74,22 +68,19 @@ Makefile text eol=lf
7468
*.bat text eol=crlf
7569
*.cmd text eol=crlf
7670
*.ps1 text eol=crlf
77-
7871
# Fonts
7972
*.ttf binary
8073
*.eot binary
8174
*.otf binary
8275
*.woff binary
8376
*.woff2 binary
84-
8577
# Serialization
8678
*.ini text eol=lf
8779
*.json text eol=lf
8880
*.toml text eol=lf
8981
*.xml text eol=lf
9082
*.yaml text eol=lf
9183
*.yml text eol=lf
92-
9384
# Configs
9485
*.conf text eol=lf
9586
*.config text eol=lf
@@ -99,34 +90,28 @@ Makefile text eol=lf
9990
.gitconfig text eol=lf
10091
*.lock text eol=lf -diff
10192
package-lock.json text eol=lf -diff
102-
10393
# Archives
10494
*.7z binary
10595
*.gz binary
10696
*.tar binary
10797
*.tgz binary
10898
*.zip binary
109-
11099
# Database
111100
*.sql text eol=lf
112-
113101
# Text files where line endings should be preserved
114102
*.patch -text
115-
116103
# Exclude files from exporting
117104
.gitattributes export-ignore
118105
.gitignore export-ignore
119106
.gitkeep export-ignore
120-
121107
# Treat all Go files in this repo as binary, with no git magic updating
122108
# line endings. Windows users contributing to Go will need to use a
123109
# modern version of git and editors capable of LF line endings.
124110
*.go -text diff=golang
125-
126111
# Terraform
127112
*.tf text eol=lf
128113
*.tfvars text eol=lf
129114
*.hcl text eol=lf
130-
131115
# Ignore files (like .npmignore or .gitignore)
132116
*.*ignore text eol=lf
117+
*.pgo filter=lfs diff=lfs merge=lfs -text

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _provider.tf
99
*_override.tf
1010
*_override.tf.json
1111
*.pprof
12+
*.test
1213
*.tfstate*
1314
*.zip
1415
**/.terraform/*

cmd/version.go

+16
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ package cmd
1717
import (
1818
"fmt"
1919
"os"
20+
"path/filepath"
2021
"runtime"
2122
"runtime/debug"
23+
"strings"
2224
"text/tabwriter"
2325

2426
"github.com/gookit/color"
@@ -43,6 +45,9 @@ var (
4345
// Dirty represents whether or not the git repo was dirty when the software was built.
4446
Dirty = vcs("vcs.modified", "unknown")
4547

48+
// PGOEnabled represents whether or not the build leveraged Profile-Guided Optimization (PGO).
49+
PGOEnabled = vcs("-pgo", "false")
50+
4651
versionCmd = &cobra.Command{
4752
Use: "version",
4853
Short: "Long-form version information",
@@ -59,6 +64,9 @@ version, and external dependencies.`,
5964
if Dirty == "true" {
6065
fmt.Fprintf(w, " Dirty repo:\t%s\t\n", Dirty)
6166
}
67+
if !strings.Contains(PGOEnabled, "false") {
68+
fmt.Fprintf(w, " PGO:\t%s\t\n", filepath.Base(PGOEnabled))
69+
}
6270
fmt.Fprintf(w, " Build date:\t%s\t\n", BuildDate)
6371
fmt.Fprintf(w, " OS/Arch:\t%s/%s\t\n", runtime.GOOS, runtime.GOARCH)
6472
fmt.Fprintf(w, " System:\t%s\t\n", archstring.GetFriendlyName(runtime.GOOS, runtime.GOARCH))
@@ -89,6 +97,14 @@ version, and external dependencies.`,
8997
exiterrorf.ExitErrorf(err)
9098
}
9199

100+
// if info, ok := debug.ReadBuildInfo(); ok {
101+
// for i := range info.Settings {
102+
// setting := info.Settings[i]
103+
104+
// fmt.Printf("%s = %s\n", setting.Key, setting.Value)
105+
// }
106+
// }
107+
92108
fmt.Println("")
93109
},
94110
}

default.pgo

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:300e7032db1493d300c14feb9b241bd6ce5a8e1f47440969dcc55c8459bc6fd5
3+
size 75733

0 commit comments

Comments
 (0)