Seb-C / go-plugin-benchmark

Benchmark comparing the go plugin package to other plugin implementations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 38803566 27.79 ns/op native
hashicorp/go-plugin 3211 360805 ns/op rpc
natefinch/pie 3956 315455 ns/op rpc
dullgiulio/pingo 3861 315183 ns/op tcp
dullgiulio/pingo 3295 334641 ns/op unix
elliotmr/plug 10000 136947 ns/op ipc
traefik/yaegi 1156857 1029 ns/op interpreter
pkujhd/goloader 66774448 18.82 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, 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.

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

License:MIT License


Languages

Language:Go 89.5%Language:Dockerfile 8.7%Language:Shell 1.8%