-
Notifications
You must be signed in to change notification settings - Fork 64
Memory Leak + Performance Decrease per Connection #72
Copy link
Copy link
Closed
Description
It looks like there's a leak in the emulator - If you do a bunch of reads, but use new connections, the emulator gets slower and slower to respond, regardless of what your queries are.
Deleting rows, dropping tables, deleting the database, and deleting the instance has no effect on performance after that - Only stopping the process causes it to get speedy again.
Below is an example of a naïve test case - Running this results in 10-20ms additional latency per query per 100 connections, with no upper bound until your machine runs out of memory. Moving the client creation to have the connection persist removes the impact on latency.
Some incompetent digging in some core files shows these two symbols as possibly notable:
(gdb) info symbol 0x33a0280
grpc_core::kNoopRefcount in section .bss of /home/graham/google-cloud-sdk/bin/cloud_spanner_emulator/emulator_main
(gdb) info symbol 0x301b6e0
grpc_core::ParsedMetadata<grpc_core::MetadataMap<grpc_core::GrpcTimeoutMetadata, grpc_core::TeMetadata, grpc_core::UserAgentMetadata, grpc_core::GrpcMessageMetadata, grpc_core::
HostMetadata, grpc_core::XEndpointLoadMetricsBinMetadata, grpc_core::GrpcServerStatsBinMetadata, grpc_core::GrpcTraceBinMetadata, grpc_core::GrpcTagsBinMetadata> >::EmptyVTable(
)::vtable in section .rodata of /home/graham/google-cloud-sdk/bin/cloud_spanner_emulator/emulator_main
package main
import (
"context"
"fmt"
"time"
"cloud.google.com/go/spanner"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
for i := 1; i < 10000; i++ {
t := time.Now()
client, err := spanner.NewClient(ctx, "projects/test/instances/instance0/databases/database0")
if err != nil {
panic(err)
}
stmt := spanner.Statement{SQL: `SELECT count(1) FROM table`}
iter := client.Single().Query(ctx, stmt)
defer iter.Stop()
for {
_, err := iter.Next()
if err == iterator.Done {
break
}
if err != nil {
panic(err)
}
}
client.Close()
if i%100 == 1 {
fmt.Println(time.Since(t))
}
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels