You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2024/09/12 05:21:47 UTC
(skywalking-banyandb) branch main updated: Add benchmarks for topological queries (#530)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new 59c39687 Add benchmarks for topological queries (#530)
59c39687 is described below
commit 59c396870ac2d81ec81113802d54277fe070d91b
Author: Huang Youliang <bu...@gmail.com>
AuthorDate: Thu Sep 12 13:21:43 2024 +0800
Add benchmarks for topological queries (#530)
---
pkg/test/query/metric.go | 62 +++++++++++++++++++++++++++++++++++
test/stress/trace/trace_suite_test.go | 4 +++
2 files changed, 66 insertions(+)
diff --git a/pkg/test/query/metric.go b/pkg/test/query/metric.go
index a890a118..0cfdfe74 100644
--- a/pkg/test/query/metric.go
+++ b/pkg/test/query/metric.go
@@ -25,6 +25,7 @@ import (
"sync"
"time"
+ "github.com/apache/skywalking-cli/pkg/graphql/dependency"
"github.com/apache/skywalking-cli/pkg/graphql/metrics"
"github.com/apache/skywalking-cli/pkg/graphql/utils"
"github.com/urfave/cli/v2"
@@ -191,3 +192,64 @@ func sortMetrics(name, svc string, limit int, order api.Order, fs *flag.FlagSet)
}
return elapsed, nil
}
+
+// Topology verifies the topology.
+func Topology(basePath string, timeout time.Duration, groupNum int, fs *flag.FlagSet) {
+ basePath = path.Join(basePath, "topology")
+ err := os.MkdirAll(basePath, 0o755)
+ if err != nil {
+ panic(err)
+ }
+ stopCh := make(chan struct{})
+ go func() {
+ time.Sleep(timeout)
+ close(stopCh)
+ }()
+ header := make([]string, groupNum)
+ for i := 0; i < groupNum; i++ {
+ header[i] = fmt.Sprintf("topology-%d", i)
+ }
+ var wg sync.WaitGroup
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ collect(basePath, func() ([]float64, error) {
+ data := make([]float64, groupNum)
+ var subWg sync.WaitGroup
+ for i := 0; i < groupNum; i++ {
+ subWg.Add(1)
+ go func() {
+ defer subWg.Done()
+ d, err := globalTopology(fs)
+ if err != nil {
+ fmt.Printf("query topology error: %v \n", err)
+ }
+ data[i] = d.Seconds()
+ }()
+ }
+ subWg.Wait()
+ return data, nil
+ }, 500*time.Millisecond, stopCh)
+ analyze(header, basePath)
+ }()
+ wg.Wait()
+}
+
+func globalTopology(fs *flag.FlagSet) (time.Duration, error) {
+ ctx := cli.NewContext(cli.NewApp(), fs, nil)
+ duration := api.Duration{
+ Start: time.Now().Add(-200 * time.Minute).Format(utils.StepFormats[api.StepMinute]),
+ End: time.Now().Format(utils.StepFormats[api.StepMinute]),
+ Step: api.StepMinute,
+ }
+ start := time.Now()
+ result, err := dependency.GlobalTopologyWithoutLayer(ctx, duration)
+ elapsed := time.Since(start)
+ if err != nil {
+ return 0, err
+ }
+ if len(result.Nodes) < 1 {
+ return 0, fmt.Errorf("no result")
+ }
+ return elapsed, nil
+}
diff --git a/test/stress/trace/trace_suite_test.go b/test/stress/trace/trace_suite_test.go
index 0aaee55b..b26acbf6 100644
--- a/test/stress/trace/trace_suite_test.go
+++ b/test/stress/trace/trace_suite_test.go
@@ -76,4 +76,8 @@ var _ = Describe("Query", func() {
It("TopN", func() {
query.TopN(basePath, timeout, 1, fs)
})
+
+ It("Topology", func() {
+ query.Topology(basePath, timeout, 1, fs)
+ })
})