benchmark

package module
v0.0.0-...-e1352a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 2 Imported by: 0

README

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 44219324 30.35 ns/op native
hashicorp/go-plugin 3682 413257 ns/op rpc
natefinch/pie 3933 328025 ns/op rpc
dullgiulio/pingo 4197 329354 ns/op tcp
dullgiulio/pingo 3110 465628 ns/op unix
elliotmr/plug 7998 162677 ns/op ipc
traefik/yaegi 1000000 1184 ns/op interpreter
pkujhd/goloader 68201743 19.11 ns/op native
tetratelabs/wazero 11401358 105.0 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RandIntPlugin

type RandIntPlugin struct {
	Impl RandIntResponder
}

RandIntPlugin is a struct used while benchmarking hashicorp/go-plugin

func (RandIntPlugin) Client

func (RandIntPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client is the client used while benchmarking hashicorp/go-plugin

func (*RandIntPlugin) Server

func (p *RandIntPlugin) Server(*plugin.MuxBroker) (interface{}, error)

Server is the server used while benchmarking hashicorp/go-plugin

type RandIntRPC

type RandIntRPC struct {
	// contains filtered or unexported fields
}

RandIntRPC is a struct used for hashicorp/go-plugin

func (*RandIntRPC) Respond

func (g *RandIntRPC) Respond() int

Respond is a function used while benchmarking hashicorp/go-plugin

type RandIntRPCServer

type RandIntRPCServer struct {
	Impl RandIntResponder
}

RandIntRPCServer is the RPC server used when benchmarking hashicorp/go-plugin

func (*RandIntRPCServer) Respond

func (s *RandIntRPCServer) Respond(args interface{}, resp *int) error

Respond is a function used while benchmarking hashicorp/go-plugin

type RandIntResponder

type RandIntResponder interface {
	Respond() int
}

RandIntResponder is a responder for hashicorp/go-plugin

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL