Skip to content

Add runtime benchmark baseline before Msg redesign - #1023

Closed
emil14 wants to merge 0 commit into
mainfrom
codex/runtime-benchmarks-baseline
Closed

Add runtime benchmark baseline before Msg redesign#1023
emil14 wants to merge 0 commit into
mainfrom
codex/runtime-benchmarks-baseline

Conversation

@emil14

@emil14 emil14 commented Feb 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds runtime benchmark baselines that should land in main before merging #1004 (Redesign runtime Msg).

It addresses review comment: #1004 (comment)

What is included

  • Reworked runtime message-passing benchmark to be true e2e runtime execution:
    • builds cmd/neva once
    • compiles benchmark program once
    • times only execution of compiled output binary
  • Increased message-passing workload from 1000 to 100000 to reduce startup/process noise in measurements
  • Added focused internal/runtime microbenchmarks for stable runtime hotspots:
    • list iteration
    • dict lookup
    • list equality
    • struct field lookup
    • single-port send/receive round-trip

Why this shape

  • e2e benchmark gives release-level runtime signal
  • microbenchmarks give stable lower-level signal for runtime internals
  • together they provide a baseline for comparing Redesign runtime Msg #1004 and future runtime changes

Validation

  • golangci-lint run ./...
  • go test ./internal/runtime/...
  • go test ./benchmarks/message_passing -run=^$ -bench=BenchmarkMessagePassingE2E -benchtime=1x

Comment thread benchmarks/message_passing/bench_test.go Outdated
Comment thread benchmarks/message_passing/bench_test.go Outdated
Comment thread internal/runtime/message_bench_test.go Outdated
Comment thread benchmarks/simple/types/bool/map_even/main.neva
Comment thread benchmarks/message_passing/bench_test.go Outdated
Comment thread benchmarks/simple/message_passing/int/main.neva
Comment thread benchmarks/simple/types/bool/map_even/main.neva
Comment thread benchmarks/message_passing/bench_test.go Outdated
Comment thread benchmarks/message_passing/bench_test.go Outdated
Comment thread benchmarks/message_passing/bench_test.go Outdated
emil14

This comment was marked as outdated.

@emil14

emil14 commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator Author

Навигация по PR для ревью (коротко и по каждому файлу):

  • .github/workflows/runtime-benchmarks.yml — добавлен отдельный CI workflow для runtime-бенчмарков с загрузкой сырых результатов и метаданных как артефактов на PR/main/release.
  • benchmarks/README.md — добавлена документация по структуре runtime-бенчмарков, запуску и тому, как читать/использовать результаты.
  • benchmarks/bench_test.go — новый общий Go-harness: автообнаружение кейсов из simple/** и complex/**, единая сборка CLI/фикстур, и замер именно выполнения скомпилированного бинаря.
  • benchmarks/complex/control_flow/selectors_routers/main.neva — добавлен комплексный сценарий с комбинацией selectors + routers, чтобы покрыть более «боевую» ветвящуюся логику.
  • benchmarks/complex/types/struct_union_combo/main.neva — добавлен комплексный кейс на сочетание struct и union, чтобы измерять не только примитивные операции.
  • benchmarks/message_passing/bench_test.go — старый локальный harness удалён; логика перенесена в единый benchmarks/bench_test.go.
  • benchmarks/message_passing/main.neva — старый одиночный benchmark-файл удалён после реструктуризации набора кейсов.
  • benchmarks/simple/collections/basic/main.neva — добавлен простой benchmark на базовые операции с коллекциями.
  • benchmarks/simple/core/basic/main.neva — добавлен базовый «core» сценарий как минимальный ориентир по overhead в простом пайплайне.
  • benchmarks/simple/message_passing/int/main.neva — выделен отдельный простой benchmark на message passing для int.
  • benchmarks/simple/operators/bool/logical/main.neva — добавлены замеры логических операций над bool.
  • benchmarks/simple/operators/float/arithmetic/main.neva — добавлены замеры арифметики над float.
  • benchmarks/simple/operators/float/comparison/main.neva — добавлены замеры сравнений для float.
  • benchmarks/simple/operators/int/arithmetic/main.neva — добавлены замеры арифметики над int.
  • benchmarks/simple/operators/int/bitwise/main.neva — добавлены замеры битовых операций для int.
  • benchmarks/simple/operators/int/comparison/main.neva — добавлены замеры сравнений для int.
  • benchmarks/simple/operators/int/unary/main.neva — добавлены замеры унарных операций для int.
  • benchmarks/simple/operators/string/add/main.neva — добавлен простой benchmark на конкатенацию строк.
  • benchmarks/simple/operators/string/comparison/main.neva — добавлены замеры сравнений строк.
  • benchmarks/simple/routers/basic/main.neva — добавлен отдельный простой benchmark для routers из builtin.
  • benchmarks/simple/selectors/basic/main.neva — добавлен отдельный простой benchmark для selectors из builtin.
  • benchmarks/simple/types/bool/map_even/main.neva — добавлен типовой кейс с bool-трансформацией в простом потоке данных.
  • benchmarks/simple/types/dict/get/main.neva — добавлен benchmark на доступ к данным в dict.
  • benchmarks/simple/types/float/parse_add/main.neva — добавлен типовой сценарий с парсингом float и последующей арифметикой.
  • benchmarks/simple/types/list/roundtrip/main.neva — добавлен benchmark на базовый roundtrip для list.
  • benchmarks/simple/types/string/map_upper/main.neva — добавлен benchmark на строковые преобразования (map/upper-case путь).
  • benchmarks/simple/types/struct/build_select/main.neva — добавлен типовой сценарий сборки и выборки полей struct.
  • benchmarks/simple/types/union/wrap_unwrap/main.neva — добавлен benchmark на упаковку/распаковку union.
  • pkg/e2e/e2e.go — расширены переиспользуемые e2e-хелперы для benchmark-пайплайна (сборка CLI, изолированный HOME, копирование файлов/директорий) и приведён lint/gosec-комплаенс.

Если удобно, могу следующим комментом дать «рекомендуемый порядок чтения» этих файлов (5-7 шагов), чтобы пройти PR максимально быстро.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен отдельный workflow runtime-бенчмарков, который сохраняет сырые результаты и метаданные как CI-артефакты.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Этот файл удалён: старый harness заменён единым benchmarks/bench_test.go.

Comment thread benchmarks/README.md

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлена краткая документация по структуре runtime-бенчмарков и по использованию результатов.

Comment thread benchmarks/bench_test.go

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Новый единый benchmark-harness: автодискавери кейсов, подготовка окружения и замер выполнения скомпилированного бинаря.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен комплексный сценарий с ветвлением на selectors/routers для более реалистичной нагрузки.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен комплексный типовой сценарий, где комбинируются операции со struct и union.

Comment thread benchmarks/message_passing/main.neva Outdated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Файл удалён: старый одиночный message-passing кейс заменён структурированным набором simple/complex сценариев.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен простой benchmark на базовые операции с коллекциями.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен базовый core-сценарий как минимальный ориентир по runtime-overhead.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен простой benchmark message passing для int в новой иерархии simple/**.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлены замеры логических операций над bool.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлены замеры арифметических операций над float.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлены замеры сравнений значений float.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлены замеры арифметических операций над int.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлены замеры битовых операций над int.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлены замеры сравнений значений int.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлены замеры унарных операций для int.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен benchmark на конкатенацию строк.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлены замеры сравнений строк.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен отдельный простой benchmark для builtin-routers.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен отдельный простой benchmark для builtin-selectors.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен типовой простой сценарий с bool-преобразованием в dataflow.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен benchmark на операции доступа к данным в dict.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен сценарий с парсингом float и последующей арифметикой.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен простой roundtrip-сценарий для list.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен строковый сценарий с преобразованием в upper-case.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен benchmark на сборку struct и выборку полей.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Добавлен benchmark на wrap/unwrap операций с union.

Comment thread pkg/e2e/e2e.go

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[файл-обзор] Расширены общие e2e-хелперы (сборка CLI, изоляция HOME, копирование файлов/директорий) для переиспользования в benchmark harness.

@emil14

emil14 commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator Author

Служебная актуализация PR по навигации ревью:

  • Удален устаревший issue-комментарий #issuecomment-4106505076.
  • Старый review-комментарий про ReportAllocs() (review #3917360287) помечен как outdated (minimized), чтобы не мешал текущему проходу.
  • Добавлены file-level комментарии [файл-обзор] по каждому changed файлу (29/29) прямо в Files changed для последовательного чтения в контексте каждого файла.

Если нужно, следующим шагом могу пройти и аналогично минимизировать/прибрать любые другие старые conversation-сообщения, которые визуально шумят при ревью.

@emil14

emil14 commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator Author

Housekeeping link for the runtime benchmark track:

  • #1015 is the broader perf-observability issue this baseline work feeds into.
  • #1067 is the umbrella goperf.dev map for related follow-up optimization work.
  • #1088 now tracks the separate policy question about how to split unit vs e2e vs benchmark coverage as benchmark breadth expands.

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

PR Review Summary

This PR provides a solid runtime benchmark baseline. Here's my assessment:

Approved with Minor Observations

Strengths:

  1. Excellent Architecture: The three-tier taxonomy (atomic/simple/complex) provides clear organization. The harness correctly builds the CLI once, compiles each benchmark once, and times only execution.

  2. Auto-Discovery Design: The discoverBenchmarkPkgs() function scans for main.neva files, making it trivial to add new benchmarks without touching Go code.

  3. Comprehensive Coverage:

    • Atomic: Individual builtin components (add, eq, cond, etc.)
    • Simple: Focused scenarios (message_passing, operators, types, collections, routers, selectors)
    • Complex: Mixed workloads (control_flow selectors+routers, struct+union combos)
  4. CI Integration: GitHub Actions workflow uploads artifacts on PRs/main/releases. The 30-minute timeout is appropriate.

  5. Code Quality: Clean Go with proper error handling, #nosec annotations where needed, and good separation of concerns via pkg/e2e helpers.

  6. No Misleading Metrics: Correctly avoids ReportAllocs() since allocations would only measure the harness, not the external compiled binary.

Minor Observations:

  1. The benchmarks/simple/operators_*.neva files use flat naming (e.g., operators_arithmetic) rather than nested directories. This is acceptable but differs from the types/ nested structure.

  2. The atomic benchmarks use one-shot execution (no streams), which aligns with the AGENTS.md iteration policy - good adherence to documented conventions.

  3. Complex benchmarks use smaller iteration counts (10K vs 100K) which is sensible given their computational complexity.

Verification:

  • bench_test.go properly handles all three tiers (atomic/simple/complex)
  • All Neva programs include explanatory comments
  • pkg/e2e/e2e.go has clean helper abstractions

This is ready to merge and will serve as an excellent baseline for comparing the Msg redesign in #1004.

New%20session%20-%202026-04-09T17%3A14%3A34.952Z
opencode session  |  github run

@emil14
emil14 force-pushed the codex/runtime-benchmarks-baseline branch from e234c37 to 7dc02e8 Compare April 9, 2026 17:23
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

PR Review: Runtime Benchmark Baseline

Overall Assessment: ✅ Approved

This PR establishes a solid runtime benchmark baseline with excellent architecture and comprehensive coverage. All previous review feedback has been addressed.


Changes Summary

File Purpose
.github/workflows/runtime-benchmarks.yml CI workflow for PRs/main/releases with artifact upload
benchmarks/README.md Documentation for structure and usage
benchmarks/complex/control_flow/selectors_routers/main.neva Complex control-flow benchmark (10K iterations)
benchmarks/complex/types/struct_union_combo/main.neva Complex struct+union benchmark (100K iterations)
benchmarks/simple/routers/basic/main.neva Simple builtin routers benchmark (10K iterations)
benchmarks/simple/selectors/basic/main.neva Simple builtin selectors benchmark (10K iterations)

Strengths

  1. Excellent Architecture: Three-tier taxonomy (atomic/simple/complex) with auto-discovery of benchmark packages via discoverBenchmarkPkgs()

  2. Proper e2e Design: Builds CLI once → compiles each fixture once → times only execution of the external binary. This is the correct approach for measuring runtime performance.

  3. Comprehensive Coverage:

    • Simple: Focused single-concern paths (routers, selectors, operators, types)
    • Complex: Mixed workloads (control_flow selectors+routers, struct+union combos)
    • Uses appropriate iteration counts (10K for complex, 100K for message-passing)
  4. CI Integration: GitHub Actions workflow uploads raw results as artifacts; 30-minute timeout is appropriate

  5. Code Quality: Clean Go with proper error handling, #nosec annotations, and good separation of concerns via pkg/e2e helpers

  6. No Misleading Metrics: Correctly avoids ReportAllocs() since allocations would only measure the harness, not the external compiled binary


Review Comment Resolution Status

All previous review comments have been addressed:

Comment Status
Reuse pkg/e2e helpers ✅ Addressed
Add comments to code blocks ✅ Addressed
Remove internal runtime benchmarks to avoid Msg API coupling ✅ Addressed
Expand e2e suite with simple/complex groups ✅ Addressed
Auto-discovery instead of manual mapping ✅ Addressed
Restructure to benchmarks/simple and benchmarks/complex ✅ Addressed
Remove ReportAllocs() from e2e suite ✅ Addressed
Sync with latest AGENTS.md ✅ Addressed

Minor Observations

  1. Benchmark Documentation: All Neva programs include explanatory comments explaining intent (e.g., // Benchmarks router-style branching components)

  2. Naming: Sub-benchmark names are generated from paths (simple_routers_basic, complex_types_struct_union_combo) - clear and consistent

  3. Timeout: 30-second per-run timeout in runProgramBinary is reasonable for preventing hung processes

  4. Iteration Policy: Aligns with AGENTS.md guidance - one-shot programs for builtins, harness controls iteration via b.Loop()


Verification Commands

# Run the benchmark suite locally
go test ./benchmarks -run=^$ -bench BenchmarkRuntimeE2E -benchtime=1x -count=1

# Compare two benchmark runs (after downloading artifacts)
benchstat old.txt new.txt

This PR is ready to merge and will serve as an excellent baseline for comparing the Msg redesign in #1004. The architecture is sound, coverage is comprehensive, and all previous review feedback has been addressed.

New%20session%20-%202026-04-09T17%3A24%3A17.483Z
opencode session  |  github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant