From c89292ca47ecb3c70343343059725c9842234f5a Mon Sep 17 00:00:00 2001 From: sabevzenko Date: Tue, 25 Jun 2024 12:35:21 +0300 Subject: [PATCH] discard overflow sliding window discard overflow sliding window 119a0330b912b4023932f3612b25cb36c8792fed --- .changes/v0.5.28.md | 3 + .github/workflows/test.yml | 83 ++++--------------- .mapping.json | 2 +- CHANGELOG.md | 4 + cli/cli.go | 2 +- core/coreutil/waiter.go | 23 ++--- docs/eng/best_practices/discard-overflow.md | 3 +- docs/rus/best_practices.md | 3 - docs/rus/best_practices/discard-overflow.md | 3 +- performance-test/automation/_agent_create.sh | 0 performance-test/automation/_agent_delete.sh | 0 .../automation/_compose_test_create_args.sh | 0 performance-test/automation/_functions.sh | 0 performance-test/automation/_test_check.sh | 0 performance-test/automation/_test_run.sh | 0 performance-test/automation/_variables.sh | 0 performance-test/automation/agent.sh | 0 .../automation/default_check_report.sh | 0 .../automation/default_check_summary.sh | 0 performance-test/automation/s3_upload.sh | 0 performance-test/automation/test.sh | 0 21 files changed, 40 insertions(+), 86 deletions(-) create mode 100644 .changes/v0.5.28.md delete mode 100644 docs/rus/best_practices.md mode change 100644 => 100755 performance-test/automation/_agent_create.sh mode change 100644 => 100755 performance-test/automation/_agent_delete.sh mode change 100644 => 100755 performance-test/automation/_compose_test_create_args.sh mode change 100644 => 100755 performance-test/automation/_functions.sh mode change 100644 => 100755 performance-test/automation/_test_check.sh mode change 100644 => 100755 performance-test/automation/_test_run.sh mode change 100644 => 100755 performance-test/automation/_variables.sh mode change 100644 => 100755 performance-test/automation/agent.sh mode change 100644 => 100755 performance-test/automation/default_check_report.sh mode change 100644 => 100755 performance-test/automation/default_check_summary.sh mode change 100644 => 100755 performance-test/automation/s3_upload.sh mode change 100644 => 100755 performance-test/automation/test.sh diff --git a/.changes/v0.5.28.md b/.changes/v0.5.28.md new file mode 100644 index 000000000..c41a54b85 --- /dev/null +++ b/.changes/v0.5.28.md @@ -0,0 +1,3 @@ +## v0.5.28 - 2024-06-24 +### Changed +* `discard_overflow` logic. Waiter wait 2 seconds sliding window before skip payload diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a52b12b35..320827441 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,15 +10,6 @@ on: - master - dev -env: - YC_LT_FOLDER_ID: b1gacohsvc2kc4d76tu5 - YC_LT_AUTHORIZED_KEY_JSON: ${{ secrets.YC_LOADTESTING_CI_AUTHORIZED_KEY_JSON }} - YC_LT_TEST_AGENT_FILTER: "name = 'agent-pandora-perf-medium'" - YC_LT_TEST_EXTRA_DESCRIPTION: "GitHub Actions workflow - ${{github.run_id}}" - YC_LT_SKIP_TEST_CHECK: "1" - YC_LT_DATA_BUCKET: ${{ secrets.YC_LT_DATA_BUCKET }} - YC_LT_OUTPUT_DIR: ${{github.workspace}}/performance-test/output - jobs: run-unit-tests: name: Unit Tests @@ -28,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu] + os: [ubuntu, macOS] env: OS: ${{ matrix.os }}-latest GO: ${{ matrix.go-version }} @@ -37,64 +28,18 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Parse to Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_ID: 161082234 - run: | - cat < imbalance.txt - ## Performance tests - - pandora-perf-grpc-300inst-sleep0ms: 12344 - - pandora-perf-grpc-3000inst-sleep0ms: 15555 - EOF - - sed G imbalance.txt > imbalance.md - - - name: Update release - id: update_release - uses: tubone24/update_release@v1.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG_NAME: v0.5.27.alpha13 + - name: Install Go + uses: actions/setup-go@v3 with: - body_path: ./imbalance.md - is_append_body: true + go-version: 1.21.x + cache: true -# build-and-upload: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# - uses: ./.github/actions/setup-yc -# - name: Install Go -# uses: actions/setup-go@v3 -# with: -# go-version: 1.21.x -# cache: true -# - name: Test -# run: go test -race -covermode atomic ./... -# - name: Build -# run: | -# export GOOS=linux -# export CGO_ENABLED=0 -# go build -o pandora_perf_2 -# - name: Upload -# run: | -# source performance-test/automation/_functions.sh && source performance-test/automation/_variables.sh; yc_s3_upload ./pandora_perf_2 pandora-perf ${YC_LT_DATA_BUCKET} -# -# test-pandora-perf: -# needs: [ build-and-upload ] -# runs-on: ubuntu-latest -# concurrency: { group: loadtesting } -# steps: -# - uses: actions/checkout@v4 -# - uses: ./.github/actions/setup-yc -# - name: Run Test HTTP-300inst-sleep0ms -# run: | -# stripped_tag="${{ github.event.release.tag_name }}" -# STRIPPED_TAG=${stripped_tag:1} -# YC_LT_VERBOSE=2 YC_LT_TEST_EXTRA_LABELS="version=${STRIPPED_TAG}" ./performance-test/automation/test.sh ./performance-test/test-config/pandora-perf-http-uri-300inst-sleep0ms -# - name: Upload Artifacts GRPC 300inst-sleep0ms -# uses: actions/upload-artifact@v4 -# with: -# name: pandora-perf-grpc-300inst-sleep0ms -# path: ${{ env.YC_LT_OUTPUT_DIR }} + - name: Test + run: go test -race -coverprofile unit.txt -covermode atomic ./... + + - name: Upload coverage report to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./unit.txt + flags: unit,${{ matrix.os }},go-${{ matrix.go-version }} + name: unit diff --git a/.mapping.json b/.mapping.json index 2b9242b50..15e8ad0d8 100644 --- a/.mapping.json +++ b/.mapping.json @@ -25,6 +25,7 @@ ".changes/v0.5.25.md":"load/projects/pandora/.changes/v0.5.25.md", ".changes/v0.5.26.md":"load/projects/pandora/.changes/v0.5.26.md", ".changes/v0.5.27.md":"load/projects/pandora/.changes/v0.5.27.md", + ".changes/v0.5.28.md":"load/projects/pandora/.changes/v0.5.28.md", ".changie.yaml":"load/projects/pandora/.changie.yaml", ".github/actions/setup-yc/action.yml":"load/projects/pandora/.github/actions/setup-yc/action.yml", ".github/workflows/release.yml":"load/projects/pandora/.github/workflows/release.yml", @@ -293,7 +294,6 @@ "docs/index.md":"load/projects/pandora/docs/index.md", "docs/rus/architecture.md":"load/projects/pandora/docs/rus/architecture.md", "docs/rus/best-practices.md":"load/projects/pandora/docs/rus/best-practices.md", - "docs/rus/best_practices.md":"load/projects/pandora/docs/rus/best_practices.md", "docs/rus/best_practices/discard-overflow.md":"load/projects/pandora/docs/rus/best_practices/discard-overflow.md", "docs/rus/best_practices/rps-per-instance.md":"load/projects/pandora/docs/rus/best_practices/rps-per-instance.md", "docs/rus/best_practices/shared-client.md":"load/projects/pandora/docs/rus/best_practices/shared-client.md", diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b960e620..ef093dc65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v0.5.28 - 2024-06-24 +### Changed +* `discard_overflow` logic. Waiter wait 2 seconds sliding window before skip payload + ## v0.5.27 - 2024-06-18 ### Added * Performance test on release diff --git a/cli/cli.go b/cli/cli.go index 2572fae43..42dc6f3d7 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -25,7 +25,7 @@ import ( "go.uber.org/zap/zapcore" ) -const Version = "0.5.27" +const Version = "0.5.28" const defaultConfigFile = "load" const stdinConfigSelector = "-" diff --git a/core/coreutil/waiter.go b/core/coreutil/waiter.go index 867a10ef8..3b46ff84e 100644 --- a/core/coreutil/waiter.go +++ b/core/coreutil/waiter.go @@ -7,10 +7,12 @@ import ( "github.com/yandex/pandora/core" ) +const MaxOverdueDuration = 2 * time.Second + // Waiter goroutine unsafe wrapper for efficient waiting schedule. type Waiter struct { - sched core.Schedule - slowDownItems int + sched core.Schedule + overdueDuration time.Duration // Lazy initialized. timer *time.Timer @@ -28,28 +30,29 @@ func (w *Waiter) Wait(ctx context.Context) (ok bool) { // Check, that context is not done. Very quick: 5 ns for op, due to benchmark. select { case <-ctx.Done(): - w.slowDownItems = 0 + w.overdueDuration = 0 return false default: } next, ok := w.sched.Next() if !ok { - w.slowDownItems = 0 + w.overdueDuration = 0 return false } // Get current time lazily. // For once schedule, for example, we need to get it only once. - if next.Before(w.lastNow) { - w.slowDownItems++ + waitFor := next.Sub(w.lastNow) + if waitFor <= 0 { + w.overdueDuration = 0 - waitFor return true } w.lastNow = time.Now() - waitFor := next.Sub(w.lastNow) + waitFor = next.Sub(w.lastNow) if waitFor <= 0 { - w.slowDownItems++ + w.overdueDuration = 0 - waitFor return true } - w.slowDownItems = 0 + w.overdueDuration = 0 // Lazy init. We don't need timer for unlimited and once schedule. if w.timer == nil { w.timer = time.NewTimer(waitFor) @@ -70,7 +73,7 @@ func (w *Waiter) IsSlowDown(ctx context.Context) (ok bool) { case <-ctx.Done(): return false default: - return w.slowDownItems >= 2 + return w.overdueDuration >= MaxOverdueDuration } } diff --git a/docs/eng/best_practices/discard-overflow.md b/docs/eng/best_practices/discard-overflow.md index d57a1d2c0..a8ff89aee 100644 --- a/docs/eng/best_practices/discard-overflow.md +++ b/docs/eng/best_practices/discard-overflow.md @@ -23,7 +23,8 @@ The instance setting `discard_overflow` determines which behavior to follow. instances. 2. `discard_overflow: true` - Strict adherence to the request schedule by the generator. Requests that do not fit into the schedule are discarded. The test duration is predetermined. Requests that fail to meet the schedule are marked as - failed (with a net error `777`, and also tagged as discarded). + failed (with a net error `777`, and also tagged as discarded). Pandora considers a test to have failed schedule, if + the time of the request is 2 seconds behind. That is 2 second sliding window is used. By default, starting from version pandora@0.5.24, the setting `discard_overflow: true` is enabled. diff --git a/docs/rus/best_practices.md b/docs/rus/best_practices.md deleted file mode 100644 index 65bc489bb..000000000 --- a/docs/rus/best_practices.md +++ /dev/null @@ -1,3 +0,0 @@ -# Практики использования - -- [RPS per instance](./best_practices/rps_per_instance.md) diff --git a/docs/rus/best_practices/discard-overflow.md b/docs/rus/best_practices/discard-overflow.md index d95b856f1..f349d3976 100644 --- a/docs/rus/best_practices/discard-overflow.md +++ b/docs/rus/best_practices/discard-overflow.md @@ -22,7 +22,8 @@ и количества инстансов. 2. `discard_overflow: true` - строгое следование генератором расписания запросов. Запросы, не уложившиеся в расписание, отбрасываются. Время выполнения теста предопределено. Запросы, которые не укладываются в расписание, - помечаются неудавшимися (ошибка net `777`, а так же добавляется tag:discarded). + помечаются неудавшимися (ошибка net `777`, а так же добавляется tag:discarded). Пандора считает, что тест не уложился + в расписание, если время запроса отстало на 2 сек. То есть используется 2 секундное скользящее окно. По-умолчанию, начиная с версии pandora@0.5.24 настройка `discard_overflow: true` diff --git a/performance-test/automation/_agent_create.sh b/performance-test/automation/_agent_create.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/_agent_delete.sh b/performance-test/automation/_agent_delete.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/_compose_test_create_args.sh b/performance-test/automation/_compose_test_create_args.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/_functions.sh b/performance-test/automation/_functions.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/_test_check.sh b/performance-test/automation/_test_check.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/_test_run.sh b/performance-test/automation/_test_run.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/_variables.sh b/performance-test/automation/_variables.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/agent.sh b/performance-test/automation/agent.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/default_check_report.sh b/performance-test/automation/default_check_report.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/default_check_summary.sh b/performance-test/automation/default_check_summary.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/s3_upload.sh b/performance-test/automation/s3_upload.sh old mode 100644 new mode 100755 diff --git a/performance-test/automation/test.sh b/performance-test/automation/test.sh old mode 100644 new mode 100755