Skip to content

Commit

Permalink
feat: init dfbench framework
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi committed Aug 29, 2024
1 parent 36d9aed commit 49ec4b6
Show file tree
Hide file tree
Showing 16 changed files with 552 additions and 59 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/check-size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check Size

on:
push:
branches: [main, release-*]
pull_request:
branches: [main, release-*]

env:
GO_VERSION: '1.21'

jobs:
check_size:
name: Check Size
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Check large files
uses: actionsdesk/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filesizelimit: "1048576"
exclusionPatterns: |
deploy/helm-charts
manager/console
client-rs
36 changes: 36 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CodeQL Analysis

on:
push:
branches: [main, release-*]
paths-ignore: ['**.md', '**.png', '**.jpg', '**.svg', '**/docs/**']
pull_request:
branches: [main, release-*]
paths-ignore: ['**.md', '**.png', '**.jpg', '**.svg', '**/docs/**']
schedule:
- cron: '0 4 * * *'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [go]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
7 changes: 7 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Golangci lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54
args: --verbose
working-directory: benchmark

- name: Markdown lint
uses: docker://avtodev/markdown-lint:v1
with:
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,22 @@ This repository includes performance test tools of dragonfly.

Provide dragonfly performance test solution and related metics.

- [Scheduler GRPC performance tests](benchmarks/scheduler/README.md)
## Community

Join the conversation and help the community.

- **Slack Channel**: [#dragonfly](https://cloud-native.slack.com/messages/dragonfly/) on [CNCF Slack](https://slack.cncf.io/)
- **Discussion Group**: <[email protected]>
- **Developer Group**: <[email protected]>
- **Github Discussions**: [Dragonfly Discussion Forum](https://github.com/dragonflyoss/Dragonfly2/discussions)
- **Twitter**: [@dragonfly_oss](https://twitter.com/dragonfly_oss)
- **DingTalk**: [22880028764](https://qr.dingtalk.com/action/joingroup?code=v1,k1,pkV9IbsSyDusFQdByPSK3HfCG61ZCLeb8b/lpQ3uUqI=&_dt_no_comment=1&origin=11)

## Contributing

You should check out our
[CONTRIBUTING](https://github.com/dragonflyoss/Dragonfly2/blob/main/CONTRIBUTING.md) and develop the project together.

## Code of Conduct

Please refer to our [Code of Conduct](https://github.com/dragonflyoss/Dragonfly2/blob/main/CODE_OF_CONDUCT.md).
60 changes: 60 additions & 0 deletions benchmark/cmd/dfbench/dragonfly.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2024 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dfbench

import (
"context"
"fmt"

"github.com/dragonflyoss/perf-tests/benchmark/pkg/config"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// dragonflyCmd represents the benchmark command for dragonfly.
var dragonflyCmd = &cobra.Command{
Use: "dragonfly [flags]",
Short: "A command line tool for benchmarking Dragonfly",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
RunE: func(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), cfg.Timeout)
defer cancel()

logrus.Infof("running dragonfly benchmark %d times", cfg.Dragonfly.Number)
return runDragonfly(ctx, cfg)
},
}

// init initializes dragonfly command.
func init() {
flags := dragonflyCmd.Flags()
flags.Uint32VarP(&cfg.Dragonfly.Number, "number", "n", cfg.Dragonfly.Number, "Specify the number of times to run the dragonfly benchmark")

if err := viper.BindPFlags(flags); err != nil {
panic(fmt.Errorf("bind cache dragonfly flags to viper: %w", err))
}
}

// runDragonfly runs the dragonfly benchmark.
func runDragonfly(ctx context.Context, cfg *config.Config) error {
// TODO: Add dragonfly benchmark logic here.
return nil
}
53 changes: 0 additions & 53 deletions benchmark/cmd/dfbench/main.go

This file was deleted.

58 changes: 58 additions & 0 deletions benchmark/cmd/dfbench/nydus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2024 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dfbench

import (
"context"
"fmt"

"github.com/dragonflyoss/perf-tests/benchmark/pkg/config"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// nydusCmd represents the benchmark command for nydus.
var nydusCmd = &cobra.Command{
Use: "nydus [flags]",
Short: "A command line tool for benchmarking Nydus",
Args: cobra.NoArgs,
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
RunE: func(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), cfg.Timeout)
defer cancel()

logrus.Infof("running nydus benchmark %d times", cfg.Nydus.Number)
return runNydus(ctx, cfg)
},
}

// init initializes nydus command.
func init() {
flags := nydusCmd.Flags()
if err := viper.BindPFlags(flags); err != nil {
panic(fmt.Errorf("bind cache nydus flags to viper: %w", err))
}
}

// runNydus runs the nydus benchmark.
func runNydus(ctx context.Context, cfg *config.Config) error {
// TODO: Add nydus benchmark logic here.
return nil
}
73 changes: 73 additions & 0 deletions benchmark/cmd/dfbench/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2024 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dfbench

import (
"os"

"github.com/dragonflyoss/perf-tests/benchmark/pkg/config"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// Initialize default dfbench config.
var cfg = config.NewConfig()

// rootCmd represents the benchmark command.
var rootCmd = &cobra.Command{
Use: "dfbench",
Short: "A command line tool for benchmarking Dragonfly",
Args: cobra.ExactArgs(1),
DisableAutoGenTag: true,
SilenceUsage: true,
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
RunE: func(cmd *cobra.Command, args []string) error {
logrus.Debug("dfbench is running")

// Set the configured log level
if level, err := logrus.ParseLevel(cfg.LogLevel); err == nil {
logrus.SetLevel(level)
}
logrus.Debug("dfbench log initialized")
return nil
},
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}

func init() {
// Bind more cache specific persistent flags.
flags := rootCmd.PersistentFlags()
flags.DurationVar(&cfg.Timeout, "timeout", cfg.Timeout, "Specify the timeout for benchmarking")
flags.StringVar(&cfg.LogLevel, "log-level", cfg.LogLevel, "Specify the log level [debug, info, warn, error, fatal, panic], default is info")

// Bind common flags.
if err := viper.BindPFlags(flags); err != nil {
panic(err)
}

// Add sub command.
rootCmd.AddCommand(dragonflyCmd)
rootCmd.AddCommand(nydusCmd)
}
23 changes: 23 additions & 0 deletions benchmark/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package main

import "github.com/dragonflyoss/perf-tests/benchmark/cmd/dfbench"

func main() {
dfbench.Execute()
}
Loading

0 comments on commit 49ec4b6

Please sign in to comment.