-
Notifications
You must be signed in to change notification settings - Fork 3
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrap in goroutine crashed #5
Comments
Hi. That happens because of session counter, I assume. What you could do is try using |
care to provide a working example? i've tried didnt work too. i understand the syncpool part... can u provide the example? thx |
What I meant is creating a pool of package main
import (
"context"
"log"
"sync"
"time"
flatbuffers "github.com/google/flatbuffers/go"
"github.com/smfrpc/smf-go/example/demo"
"github.com/smfrpc/smf-go/example/demo_gen"
"github.com/smfrpc/smf-go/src/smf"
)
// var xreq = strings.Repeat("x", 11)
var xreq = string([]byte{0, 3, 23, 41})
func buildRequest() []byte {
builder := flatbuffers.NewBuilder(0)
name := builder.CreateString(xreq)
demo.RequestStart(builder)
demo.RequestAddName(builder, name)
resp := demo.RequestEnd(builder)
builder.Finish(resp)
return builder.FinishedBytes()
}
func main() {
pool := sync.Pool{
New: func() any {
client, err := smf.Dial("tcp", "127.0.0.1:20766")
if err != nil {
log.Fatal(err)
}
return client
},
}
start := time.Now()
for i := 0; i < 100000; i++ {
go func() {
client := pool.Get().(*smf.Client)
defer pool.Put(client)
store := demo_gen.NewSmfStorageClient(client)
resp, err := store.Get(context.TODO(), buildRequest())
if err != nil {
log.Fatal(err)
}
log.Printf("Response: [ name=%q ]", resp.Name())
}()
}
elapsed := time.Since(start)
log.Printf("Binomial took %s", elapsed)
time.Sleep(100 * time.Second)
} |
Take in mind this benchmark will not result in an accurate result. This code will start What I would do instead is spin up one goroutine for each connection and measure only time between request and response. |
crash
The text was updated successfully, but these errors were encountered: