Skip to content

Fix benchmark workflow: drop goloader, fix proto panic, fix wazero module exit#4

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-benchmark-workflow-error
Open

Fix benchmark workflow: drop goloader, fix proto panic, fix wazero module exit#4
Copilot wants to merge 2 commits intomainfrom
copilot/fix-benchmark-workflow-error

Conversation

Copy link

Copilot AI commented Mar 7, 2026

The weekly benchmark workflow was failing at update_readme.py with "No benchmark results found" because the test binary either failed to link (goloader) or panicked at startup (proto conflict) before producing any output.

goloader removed (Go 1.26.1 incompatible)

Go 1.26.1 rejects //go:linkname references to unexported runtime symbols at link time when the symbol is actually called. goloader calls runtime.itabTable, runtime.itabLock, runtime.firstmoduledata, runtime.gostringnocopy, and several others — all now blocked. No local patch can fix this without rewriting the library's core approach.

  • Removed BenchmarkGoloaderRandInt and the github.com/pkujhd/goloader import from plugin_test.go
  • Dropped the dependency from go.mod and removed the cp cmd/internal→cmd/objfile + go tool compile goloader.o Dockerfile steps
  • Marked the README row N/A with an explanatory footnote; removed goloader from update_readme.py's pattern map

Protobuf registration panic fixed

github.com/GoCodeAlone/go-plugin and github.com/hashicorp/go-plugin both register identical proto file paths (internal/plugin/grpc_broker.proto, etc.), causing a panic in init() before any benchmark ran.

ENV GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn

Wazero benchmark fixed

runtime.Instantiate auto-runs _start, which in TinyGo's WASI target calls main() and then proc_exit(0), closing the module. Every RandInt call in the loop then fails with "module closed with exit_code(0)".

// Before: runtime.Instantiate runs _start → proc_exit(0) → module closed
module, err := runtime.Instantiate(ctx, wasmFile)

// After: skip _start so the module stays alive across benchmark iterations
cm, _ := runtime.CompileModule(ctx, wasmFile)
cfg := wazero.NewModuleConfig().WithStartFunctions() // no start functions
module, _ := runtime.InstantiateModule(ctx, cm, cfg)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error in benchmark workflow execution Fix benchmark workflow: drop goloader, fix proto panic, fix wazero module exit Mar 7, 2026
@intel352 intel352 marked this pull request as ready for review March 7, 2026 21:08
Copilot AI review requested due to automatic review settings March 7, 2026 21:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the weekly benchmark automation by removing the goloader benchmark/dependency (incompatible with Go 1.26.1), preventing a protobuf registration panic at startup, and adjusting the wazero benchmark so the WASM module doesn’t auto-exit before iterations run.

Changes:

  • Remove goloader benchmark code and module dependency; update README and README-update script accordingly.
  • Set GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn in the Docker benchmark environment to avoid init-time panics.
  • Change wazero benchmark instantiation to skip _start so the module remains usable across benchmark iterations.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/update_readme.py Removes goloader from the benchmark-to-README row mapping to keep automation in sync.
plugin_test.go Drops goloader benchmark/imports; updates wazero benchmark to compile + instantiate without auto-start.
go.mod Removes the goloader module requirement.
go.sum Removes goloader checksums.
README.md Marks goloader as N/A with an explanatory footnote; updates benchmark numbers/rows.
Dockerfile Adds protobuf conflict env var; removes goloader-specific build steps.
.github/workflows/benchmark.yml Removes workflow comments related to the prior goloader workaround.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +196 to 211
compiledModule, err := runtime.CompileModule(ctx, wasmFile)
if err != nil {
fmt.Println("failed to compile module:", err)
return
}

// WithStartFunctions() with no arguments skips the auto-start (_start)
// entry point so the WASI module stays alive for repeated RandInt calls.
// Without this, TinyGo's _start calls main() and then proc_exit(0),
// closing the module before any benchmark iterations can complete.
cfg := wazero.NewModuleConfig().WithStartFunctions()
module, err := runtime.InstantiateModule(ctx, compiledModule, cfg)
if err != nil {
fmt.Println("failed to instantiate module:", err)
return
}
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

In this benchmark, compile/instantiate failures are handled by printing and returning, which makes go test succeed while silently skipping the wazero sub-benchmark. That can reintroduce the "missing benchmark results" failure mode (or leave README rows stale). Prefer failing the benchmark (e.g., b.Fatalf / b.Fatal) so CI clearly reports the problem.

Copilot uses AI. Check for mistakes.
Comment on lines 214 to 215
b.Run("wazero", func(b *testing.B) {
randIntFunction := module.ExportedFunction("RandInt")
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

Within the b.Run("wazero", ...) body, an error from randIntFunction.Call is currently handled by printing and returning, which ends the sub-benchmark early and can yield misleading results. Prefer failing the benchmark via the testing.B API (e.g., b.Fatalf / b.FailNow) so the run is marked unsuccessful instead of reporting partial numbers.

Copilot uses AI. Check for mistakes.
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.

3 participants