hashicorp / go-plugin

Golang plugin system over RPC.
Mozilla Public License 2.0
5.25k stars 450 forks source link

Loading plugins is slow for the first time #209

Closed kingangelAOA closed 1 year ago

kingangelAOA commented 2 years ago
func TestPluginMan(t *testing.T) {
    configs.FlagInit()
    config := getConfig()
    db.InitMongo(config.Mongo)
    path, err := db.DownloadPluginFile("6304cf3d95182056b4794ad3", "go")
    if err != nil {
        panic(err)
    }
    pc := shared.LoadPluginClient(path)
    startT := time.Now()
    pc.Client()
    tc := time.Since(startT)
    fmt.Printf("InitPlugin time cost = %v\n", tc)
}

[WARN] plugin: plugin configured with a nil SecureConfig InitPlugin time cost = 8.669762172s --- PASS: TestPluginMan (13.84s) PASS ok plugin/shared 14.795s pc.Client() consuming 8 seconds

fairclothjm commented 2 years ago

hi @kingangelAOA, I tested this with Vault loading plugins using the most recent go-plugin v1.4.5 and did not see the same issue. Here are my results:

2022-08-31T09:21:23.042-0500 [DEBUG] core: InitPlugin time: cost=61.713753ms
2022-08-31T09:21:23.197-0500 [DEBUG] core: InitPlugin time: cost=104.083246ms
2022-08-31T09:21:23.333-0500 [DEBUG] core: InitPlugin time: cost=67.529133ms
2022-08-31T09:21:23.486-0500 [DEBUG] core: InitPlugin time: cost=100.904741ms
2022-08-31T09:21:23.603-0500 [DEBUG] core: InitPlugin time: cost=66.049939ms
2022-08-31T09:21:23.771-0500 [DEBUG] core: InitPlugin time: cost=108.239343ms

Using:

startT := time.Now()
rpcClient, err := pc.client.Client()
tc := time.Since(startT)
c.logger.Debug("InitPlugin time", "cost", tc)

Could you please provide some more details on your setup?

fairclothjm commented 1 year ago

@kingangelAOA please reopen if you are still seeing the issue and can provide more details