Skip to content

Commit

Permalink
test: basic benchmarks for workflow archive
Browse files Browse the repository at this point in the history
This adds basic benchmarks for listing and counting archived workflows
so we can evaluate potential optimizations, e.g. #13601

```
$ make BenchmarkWorkflowArchive
GIT_COMMIT=f218fc540367840d013a99642590d3509560de51 GIT_BRANCH=feat-postgresql-jsonb GIT_TAG=untagged GIT_TREE_STATE=dirty RELEASE_TAG=false DEV_BRANCH=true VERSION=latest
KUBECTX=k3d-k3s-default DOCKER_DESKTOP=false K3D=true DOCKER_PUSH=false TARGET_PLATFORM=linux/amd64
RUN_MODE=local PROFILE=minimal AUTH_MODE=hybrid SECURE=false  STATIC_FILES=false ALWAYS_OFFLOAD_NODE_STATUS=false UPPERIO_DB_DEBUG=0 LOG_LEVEL=debug NAMESPACED=true
go test --tags api,cli,cron,executor,examples,corefunctional,functional,plugins ./test/e2e -run='BenchmarkWorkflowArchive' -benchmem -bench .
WARN[0000] Non-transient error: <nil>
WARN[0000] Non-transient error: <nil>
goos: linux
goarch: amd64
pkg: github.com/argoproj/argo-workflows/v3/test/e2e
cpu: 12th Gen Intel(R) Core(TM) i5-12400
BenchmarkWorkflowArchive/ListWorkflows-12                      6         167109091 ns/op          527468 B/op       8614 allocs/op
--- BENCH: BenchmarkWorkflowArchive/ListWorkflows-12
    workflow_archive_test.go:27: Found 100 workflows
    workflow_archive_test.go:27: Found 100 workflows
    workflow_archive_test.go:27: Found 100 workflows
    workflow_archive_test.go:27: Found 100 workflows
    workflow_archive_test.go:27: Found 100 workflows
    workflow_archive_test.go:27: Found 100 workflows
    workflow_archive_test.go:27: Found 100 workflows
BenchmarkWorkflowArchive/CountWorkflows-12                    31          36799882 ns/op            9022 B/op        212 allocs/op
--- BENCH: BenchmarkWorkflowArchive/CountWorkflows-12
    workflow_archive_test.go:37: Found 100756 workflows
    workflow_archive_test.go:37: Found 100756 workflows
    workflow_archive_test.go:37: Found 100756 workflows
    workflow_archive_test.go:37: Found 100756 workflows
    workflow_archive_test.go:37: Found 100756 workflows
    workflow_archive_test.go:37: Found 100756 workflows
    workflow_archive_test.go:37: Found 100756 workflows
    workflow_archive_test.go:37: Found 100756 workflows
    workflow_archive_test.go:37: Found 100756 workflows
    workflow_archive_test.go:37: Found 100756 workflows
        ... [output truncated]
PASS
ok      github.com/argoproj/argo-workflows/v3/test/e2e  3.392s
```

Signed-off-by: Mason Malone <[email protected]>
  • Loading branch information
MasonM committed Oct 16, 2024
1 parent d05cf64 commit 5502599
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ E2E_WAIT_TIMEOUT ?= 90s # timeout for wait conditions
E2E_PARALLEL ?= 20
E2E_SUITE_TIMEOUT ?= 15m
GOTEST ?= go test -v -p 20
ALL_BUILD_TAGS ?= api,cli,cron,executor,examples,corefunctional,functional,plugins

# should we build the static files?
ifneq (,$(filter $(MAKECMDGOALS),codegen lint test docs start))
Expand Down Expand Up @@ -608,8 +609,10 @@ test-%-sdk:
make --directory sdks/$* install test -B

Test%:
E2E_WAIT_TIMEOUT=$(E2E_WAIT_TIMEOUT) go test -failfast -v -timeout $(E2E_SUITE_TIMEOUT) -count 1 --tags api,cli,cron,executor,examples,corefunctional,functional,plugins -parallel $(E2E_PARALLEL) ./test/e2e -run='.*/$*'
E2E_WAIT_TIMEOUT=$(E2E_WAIT_TIMEOUT) go test -failfast -v -timeout $(E2E_SUITE_TIMEOUT) -count 1 --tags $(ALL_BUILD_TAGS) -parallel $(E2E_PARALLEL) ./test/e2e -run='.*/$*'

Benchmark%:
go test --tags $(ALL_BUILD_TAGS) ./test/e2e -run='$@' -benchmem -bench .

# clean

Expand Down
2 changes: 1 addition & 1 deletion docs/running-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ To test SSO integration, use `PROFILE=sso`:
make start UI=true PROFILE=sso
```

## TLS
### TLS

By default, `make start` will start Argo in [plain text mode](tls.md#plain-text).
To simulate a TLS proxy in front of Argo, use `UI_SECURE=true` (which implies `UI=true`):
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/fixtures/e2e_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (s *E2ESuite) DeleteResources() {

// delete archived workflows from the archive
if s.Persistence.IsEnabled() {
archive := s.Persistence.workflowArchive
archive := s.Persistence.WorkflowArchive
parse, err := labels.ParseToRequirements(Label)
s.CheckError(err)
workflows, err := archive.ListWorkflows(utils.ListOptions{
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/fixtures/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
)

type Persistence struct {
WorkflowArchive sqldb.WorkflowArchive
session db.Session
offloadNodeStatusRepo sqldb.OffloadNodeStatusRepo
workflowArchive sqldb.WorkflowArchive
}

func newPersistence(kubeClient kubernetes.Interface, wcConfig *config.Config) *Persistence {
Expand All @@ -38,9 +38,9 @@ func newPersistence(kubeClient kubernetes.Interface, wcConfig *config.Config) *P
}
instanceIDService := instanceid.NewService(wcConfig.InstanceID)
workflowArchive := sqldb.NewWorkflowArchive(session, persistence.GetClusterName(), Namespace, instanceIDService)
return &Persistence{session, offloadNodeStatusRepo, workflowArchive}
return &Persistence{workflowArchive, session, offloadNodeStatusRepo}
} else {
return &Persistence{offloadNodeStatusRepo: sqldb.ExplosiveOffloadNodeStatusRepo, workflowArchive: sqldb.NullWorkflowArchive}
return &Persistence{offloadNodeStatusRepo: sqldb.ExplosiveOffloadNodeStatusRepo, WorkflowArchive: sqldb.NullWorkflowArchive}
}
}

Expand Down
42 changes: 42 additions & 0 deletions test/e2e/workflow_archive_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//go:build functional

package e2e

import (
"testing"

sutils "github.com/argoproj/argo-workflows/v3/server/utils"
"github.com/argoproj/argo-workflows/v3/test/e2e/fixtures"
)

func BenchmarkWorkflowArchive(b *testing.B) {
// Workaround for https://github.com/stretchr/testify/issues/811
suite := fixtures.E2ESuite{}
suite.SetT(&testing.T{})
suite.SetupSuite()
b.ResetTimer()

b.Run("ListWorkflows", func(b *testing.B) {
for range b.N {
wfs, err := suite.Persistence.WorkflowArchive.ListWorkflows(sutils.ListOptions{
Limit: 100,
})
if err != nil {
b.Fatal(err)
}
b.Logf("Found %d workflows", wfs.Len())
}
})

b.Run("CountWorkflows", func(b *testing.B) {
for range b.N {
wfCount, err := suite.Persistence.WorkflowArchive.CountWorkflows(sutils.ListOptions{})
if err != nil {
b.Fatal(err)
}
b.Logf("Found %d workflows", wfCount)
}
})

suite.TearDownSuite()
}

0 comments on commit 5502599

Please sign in to comment.