copr-cache mem leak
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
- set copr-cache cap to 1GB
- run tidb with memory quta 10GB
- construct sql to make copr-cache hit/update frequently
- run workload for a long time
### 2. What did you expect to see? (Required)
- no mem leak
### 3. What did you see instead (Required)
Mem leak
- the approximate mem consumption of copr-cache(red square parts) is about 1GB, which is as expect.
- the memory consumption of the model ristretto / expiringMap is large and beyond TiDB's control
- It is known that https://github.com/golang/go/issues/20135 map will not shrink automatically
```
// bucket type is a map of key to conflict.
type bucket map[uint64]uint64
// expirationMap is a map of bucket number to the corresponding bucket.
type expirationMap struct {
sync.RWMutex
buckets map[int64]bucket
}
```
### 4. What is your TiDB version? (Required)
since #13824
version >= v4.0
Contributor guide
Assessment
This issue has not been assessed yet.