-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dns: start adding benchmarks for performance regressions (#1325)
* dont use log colours in CI * dns: start adding benchmarks * fix output? * fix benchmark output * cleanup * more benchmarks * separate benchmarks
- Loading branch information
Showing
8 changed files
with
261 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Benchmark | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
permissions: | ||
contents: write | ||
deployments: write | ||
|
||
jobs: | ||
test: | ||
name: Benchmark | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
cache: true | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: web/package.json | ||
cache: "npm" | ||
cache-dependency-path: web/package-lock.json | ||
- run: make web-install web-build | ||
- run: make test-env-start | ||
- run: make install-deps | ||
- run: make bench | ||
- uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: Gravity Benchmark | ||
tool: 'go' | ||
output-file-path: test-output | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
auto-push: true | ||
# Show alert with commit comment on detecting possible performance regression | ||
alert-threshold: '200%' | ||
comment-on-alert: true | ||
fail-on-alert: true | ||
alert-comment-cc-users: '@BeryJu' | ||
summary-always: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package dns_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"beryju.io/gravity/pkg/instance" | ||
"beryju.io/gravity/pkg/roles/dns" | ||
"beryju.io/gravity/pkg/roles/dns/types" | ||
"beryju.io/gravity/pkg/tests" | ||
d "github.com/miekg/dns" | ||
) | ||
|
||
func BenchmarkRoleDNS_Etcd(b *testing.B) { | ||
defer tests.Setup(nil)() | ||
rootInst := instance.New() | ||
ctx := tests.Context() | ||
inst := rootInst.ForRole("dns", ctx) | ||
tests.PanicIfError(inst.KV().Put( | ||
ctx, | ||
inst.KV().Key( | ||
types.KeyRole, | ||
types.KeyZones, | ||
TestZone, | ||
).String(), | ||
tests.MustJSON(dns.Zone{ | ||
HandlerConfigs: []map[string]interface{}{ | ||
{ | ||
"type": "etcd", | ||
}, | ||
}, | ||
}), | ||
)) | ||
tests.PanicIfError(inst.KV().Put( | ||
ctx, | ||
inst.KV().Key( | ||
types.KeyRole, | ||
types.KeyZones, | ||
TestZone, | ||
"foo", | ||
types.DNSRecordTypeA, | ||
"0", | ||
).String(), | ||
tests.MustJSON(dns.Record{ | ||
Data: "10.1.2.3", | ||
}), | ||
)) | ||
|
||
role := dns.New(inst) | ||
_ = role.Start(ctx, RoleConfig()) | ||
defer role.Stop() | ||
|
||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
fw := NewNullDNSWriter() | ||
role.Handler(fw, &d.Msg{ | ||
Question: []d.Question{ | ||
{ | ||
Name: "foo.example.com.", | ||
Qtype: d.TypeA, | ||
Qclass: d.ClassINET, | ||
}, | ||
}, | ||
}) | ||
_ = fw.Msg() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package dns_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"beryju.io/gravity/pkg/instance" | ||
"beryju.io/gravity/pkg/roles/dns" | ||
"beryju.io/gravity/pkg/roles/dns/types" | ||
"beryju.io/gravity/pkg/tests" | ||
d "github.com/miekg/dns" | ||
) | ||
|
||
func BenchmarkRoleDNS_Memory(b *testing.B) { | ||
defer tests.Setup(nil)() | ||
rootInst := instance.New() | ||
ctx := tests.Context() | ||
inst := rootInst.ForRole("dns", ctx) | ||
tests.PanicIfError(inst.KV().Put( | ||
ctx, | ||
inst.KV().Key( | ||
types.KeyRole, | ||
types.KeyZones, | ||
".", | ||
).String(), | ||
tests.MustJSON(dns.Zone{ | ||
HandlerConfigs: []map[string]interface{}{ | ||
{ | ||
"type": "memory", | ||
}, | ||
}, | ||
}), | ||
)) | ||
tests.PanicIfError(inst.KV().Put( | ||
ctx, | ||
inst.KV().Key( | ||
types.KeyRole, | ||
types.KeyZones, | ||
".", | ||
"foo", | ||
types.DNSRecordTypeA, | ||
"0", | ||
).String(), | ||
tests.MustJSON(dns.Record{ | ||
Data: "10.1.2.3", | ||
}), | ||
)) | ||
|
||
role := dns.New(inst) | ||
_ = role.Start(ctx, RoleConfig()) | ||
defer role.Stop() | ||
|
||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
fw := NewNullDNSWriter() | ||
role.Handler(fw, &d.Msg{ | ||
Question: []d.Question{ | ||
{ | ||
Name: "foo.", | ||
Qtype: d.TypeA, | ||
Qclass: d.ClassINET, | ||
}, | ||
}, | ||
}) | ||
_ = fw.Msg() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package dns_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"beryju.io/gravity/pkg/instance" | ||
"beryju.io/gravity/pkg/roles/dns" | ||
"beryju.io/gravity/pkg/roles/dns/types" | ||
"beryju.io/gravity/pkg/tests" | ||
d "github.com/miekg/dns" | ||
) | ||
|
||
func BenchmarkRoleDNS_DefaultRootZone(b *testing.B) { | ||
defer tests.Setup(nil)() | ||
rootInst := instance.New() | ||
ctx := tests.Context() | ||
inst := rootInst.ForRole("dns", ctx) | ||
tests.PanicIfError(inst.KV().Put( | ||
ctx, | ||
inst.KV().Key( | ||
types.KeyRole, | ||
types.KeyZones, | ||
".", | ||
).String(), | ||
tests.MustJSON(dns.Zone{ | ||
HandlerConfigs: []map[string]interface{}{ | ||
{ | ||
"type": "memory", | ||
}, | ||
{ | ||
"type": "etcd", | ||
}, | ||
{ | ||
"type": "forward_ip", | ||
"to": []string{"127.0.0.1:1053"}, | ||
"cache_ttl": 3600, | ||
}, | ||
}, | ||
}), | ||
)) | ||
|
||
role := dns.New(inst) | ||
_ = role.Start(ctx, RoleConfig()) | ||
defer role.Stop() | ||
|
||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
fw := NewNullDNSWriter() | ||
role.Handler(fw, &d.Msg{ | ||
Question: []d.Question{ | ||
{ | ||
Name: "gravity.beryju.io.", | ||
Qtype: d.TypeA, | ||
Qclass: d.ClassINET, | ||
}, | ||
}, | ||
}) | ||
_ = fw.Msg() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters