mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-28 05:00:08 +00:00
cmd/omitsize: add flag to disable the removal table
And remove a bogus omit feature from feature/featuretags. Updates #12614 Change-Id: I0a08183fb75c73ae75b6fd4216d134e352dcf5a0 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
0cc1b2ff76
commit
7d2101f352
@@ -35,16 +35,14 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
var keep = map[string]bool{}
|
||||
var keep = map[featuretags.FeatureTag]bool{}
|
||||
for t := range strings.SplitSeq(*add, ",") {
|
||||
if t != "" {
|
||||
keep[t] = true
|
||||
keep[featuretags.FeatureTag(t)] = true
|
||||
}
|
||||
}
|
||||
var tags []string
|
||||
if keep["cli"] {
|
||||
// The "cli" --add value is special in that it's a build tag
|
||||
// that adds something, rather than removes something.
|
||||
if keep[featuretags.CLI] {
|
||||
tags = append(tags, "ts_include_cli")
|
||||
}
|
||||
if *min {
|
||||
@@ -52,22 +50,24 @@ func main() {
|
||||
if f == "" {
|
||||
continue
|
||||
}
|
||||
if !keep[f] {
|
||||
tags = append(tags, "ts_omit_"+f)
|
||||
if !keep[f] && f.IsOmittable() {
|
||||
tags = append(tags, f.OmitTag())
|
||||
}
|
||||
}
|
||||
}
|
||||
for f := range strings.SplitSeq(*remove, ",") {
|
||||
if f == "" {
|
||||
for v := range strings.SplitSeq(*remove, ",") {
|
||||
if v == "" {
|
||||
continue
|
||||
}
|
||||
f := featuretags.FeatureTag(v)
|
||||
if _, ok := features[f]; !ok {
|
||||
log.Fatalf("unknown feature %q in --remove", f)
|
||||
}
|
||||
tags = append(tags, "ts_omit_"+f)
|
||||
tags = append(tags, f.OmitTag())
|
||||
}
|
||||
slices.Sort(tags)
|
||||
tags = slices.Compact(tags)
|
||||
if len(tags) != 0 {
|
||||
fmt.Println(strings.Join(tags, ","))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import (
|
||||
var (
|
||||
cacheDir = flag.String("cachedir", "", "if non-empty, use this directory to store cached size results to speed up subsequent runs. The tool does not consider the git status when deciding whether to use the cache. It's on you to nuke it between runs if the tree changed.")
|
||||
features = flag.String("features", "", "comma-separated list of features to consider, with or without the ts_omit_ prefix")
|
||||
|
||||
showRemovals = flag.Bool("show-removals", false, "if true, show a table of sizes removing one feature at a time from the full set")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -31,7 +33,9 @@ func main() {
|
||||
var all []string
|
||||
if *features == "" {
|
||||
for k := range featuretags.Features {
|
||||
all = append(all, "ts_omit_"+k)
|
||||
if k.IsOmittable() {
|
||||
all = append(all, k.OmitTag())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for v := range strings.SplitSeq(*features, ",") {
|
||||
@@ -49,27 +53,30 @@ func main() {
|
||||
baseC := measure("tailscale")
|
||||
baseBoth := measure("tailscaled", "ts_include_cli")
|
||||
|
||||
fmt.Printf("(a) starting with everything and removing a feature...\n\n")
|
||||
|
||||
fmt.Printf("%9s %9s %9s\n", "tailscaled", "tailscale", "combined (linux/amd64)")
|
||||
fmt.Printf("%9d %9d %9d\n", baseD, baseC, baseBoth)
|
||||
|
||||
minD := measure("tailscaled", all...)
|
||||
minC := measure("tailscale", all...)
|
||||
minBoth := measure("tailscaled", append(slices.Clone(all), "ts_include_cli")...)
|
||||
fmt.Printf("-%8d -%8d -%8d omit-all\n", baseD-minD, baseC-minC, baseBoth-minBoth)
|
||||
|
||||
for _, t := range all {
|
||||
sizeD := measure("tailscaled", t)
|
||||
sizeC := measure("tailscale", t)
|
||||
sizeBoth := measure("tailscaled", append([]string{t}, "ts_include_cli")...)
|
||||
saveD := max(baseD-sizeD, 0)
|
||||
saveC := max(baseC-sizeC, 0)
|
||||
saveBoth := max(baseBoth-sizeBoth, 0)
|
||||
fmt.Printf("-%8d -%8d -%8d %s\n", saveD, saveC, saveBoth, t)
|
||||
if *showRemovals {
|
||||
fmt.Printf("Starting with everything and removing a feature...\n\n")
|
||||
|
||||
fmt.Printf("%9s %9s %9s\n", "tailscaled", "tailscale", "combined (linux/amd64)")
|
||||
fmt.Printf("%9d %9d %9d\n", baseD, baseC, baseBoth)
|
||||
|
||||
fmt.Printf("-%8d -%8d -%8d omit-all\n", baseD-minD, baseC-minC, baseBoth-minBoth)
|
||||
|
||||
for _, t := range all {
|
||||
sizeD := measure("tailscaled", t)
|
||||
sizeC := measure("tailscale", t)
|
||||
sizeBoth := measure("tailscaled", append([]string{t}, "ts_include_cli")...)
|
||||
saveD := max(baseD-sizeD, 0)
|
||||
saveC := max(baseC-sizeC, 0)
|
||||
saveBoth := max(baseBoth-sizeBoth, 0)
|
||||
fmt.Printf("-%8d -%8d -%8d %s\n", saveD, saveC, saveBoth, t)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("\n(b) or, starting at minimal and adding one feature back...\n")
|
||||
fmt.Printf("\nStarting at a minimal binary and adding one feature back...\n")
|
||||
fmt.Printf("%9s %9s %9s\n", "tailscaled", "tailscale", "combined (linux/amd64)")
|
||||
fmt.Printf("%9d %9d %9d omitting everything\n", minD, minC, minBoth)
|
||||
for _, t := range all {
|
||||
|
||||
Reference in New Issue
Block a user