clickhouse-go icon indicating copy to clipboard operation
clickhouse-go copied to clipboard

increased memory usage in native v2 client

Open mettledrum opened this issue 3 years ago • 6 comments

Issue description

Our system of ClickHouse inserters have been using the native v2.2.0 client with success for several weeks. After upgrading to v2.4.3 a few days ago, we noticed that the memory and CPU usage increased markedly. Memory usage was roughly 7-10x more, and CPU usage was 6-9x more on our k8 pods.

Example code

Our inserters collect in memory ~250k messages, morph them each into ClickHouse row batches and call client.WriteBatch() after checking to see if a lock table doesn't have any rows. The columns contain array(string), array(uint8) uint8, and string types. And some of the array(string) average about 500 elements.

Error log

didn't see any insert error logs

Configuration

OS: pod images are built using golang:1.19

I think this is the OS:

cat /etc/*-release
...
Debian GNU/Linux 11
...

Interface: E.g. native, database/sql native

Driver version: v.2.4.3

Go version: run go version in your console 1.19.4

ClickHouse Server version: 22.8.5.29

mettledrum avatar Dec 16 '22 23:12 mettledrum

seems possibly related to #843

mettledrum avatar Dec 17 '22 00:12 mettledrum

Doing quick benchmarks I can confirm much more CPU & memory (x4) appetite for a test that does ingestion as you do. This definitely requires more attention.

jkaflik avatar Dec 17 '22 12:12 jkaflik

@jkaflik can you please share your benchmark so I can investigate this issue too?

ernado avatar Mar 03 '23 18:03 ernado

@ernado benchmark I used to get mentioned results is: https://github.com/ClickHouse/clickhouse-go/blob/b7fbe1f4b3c36e43d135a02e340884cdc2f8a4c8/benchmark/v2/write-native/main.go

jkaflik avatar Mar 08 '23 06:03 jkaflik

Is this issue being worked upon? @ernado @jkaflik

makeavish avatar Nov 21 '23 09:11 makeavish

I’m not working on this. Will try to take a look, but no ETA.

ernado avatar Nov 21 '23 10:11 ernado