Skip to content
 
 

Repository files navigation

Golang Plugin Benchmark

A comparison of the go plugin package and other plugin implementations for golang. The reason for this is to compare alternatives from a performance perspective. As shown in a previous benchmark there is basically no difference in performance of using go plugins to running a function directly in code.

Benchmarks

Name Operations (higher is better) ns/op (lower is better) type
go plugin package 466388373 12.90 ns/op native
hashicorp/go-plugin 42607 137687 ns/op rpc
GoCodeAlone/go-plugin 36901 162668 ns/op grpc
natefinch/pie 66715 89390 ns/op rpc
dullgiulio/pingo 51844 114880 ns/op tcp
dullgiulio/pingo 55180 108367 ns/op unix
elliotmr/plug 180102 32750 ns/op ipc
traefik/yaegi 6725710 895.6 ns/op interpreter
GoCodeAlone/yaegi 6666477 901.1 ns/op interpreter
pkujhd/goloader ¹ N/A N/A native
tetratelabs/wazero 32659566 184.4 ns/op native

Several of the other packages use RPC or similar methods instead of the go plugin package which gets around issues such as, but not limited to, not being compatible with Windows and package paths and GOPATH needing to be the same between apps and plugins.

With the addition of Yaegi and GoCodeAlone/yaegi, I am also benchmarking interpreters.

Do you know any other plugin packages? Please open an issue or pull request.

Found an issue with a benchmark? Please open an issue or pull request.

Setup

I have moved to using Docker to run these benchmarks to make them easier to reproduce.

Build the docker image:

docker build --pull --no-cache --tag go-plugin-benchmark:local .

To run the benchmark run

docker run go-plugin-benchmark:local

Results

Most plugins tested are using RPC which adds about 30 - 50 microseconds to plugin calls (or 0.03 - 0.05 milliseconds) over the golang plugin package.

¹ The goloader package is interesting and may provide a good alternative to the go plugin package. One drawback is that it uses internal packages which requires renaming the internal folder locally and I have not tested compatibility to see if it solves the problems with the go plugin package. Note: goloader is currently excluded from benchmarks because it relies on //go:linkname access to unexported runtime symbols that are no longer accessible in Go 1.26.1.

Contributing

If you have a plugin or interpreter written in go which you would like to benchmark feel free to open an issue.

Would you like to add more benchmarks? Please feel free to fork this repository and open a pull request with the updated changes. Please make sure to add any needed code and also update the Readme. Your code belongs to you but it must fall under the same LICENSE as this repository to be included.

About

Benchmark comparing the go plugin package to other plugin implementations

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages