mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 02:48:45 +08:00
Clean up not used id_cache related code (#16655)
Signed-off-by: shaoyue.chen <shaoyue.chen@zilliz.com>
This commit is contained in:
parent
337ad53613
commit
fa97f86cda
@ -130,8 +130,6 @@ proxy:
|
|||||||
maxDimension: 32768 # Maximum dimension of a vector
|
maxDimension: 32768 # Maximum dimension of a vector
|
||||||
maxShardNum: 256 # Maximum number of shards in a collection
|
maxShardNum: 256 # Maximum number of shards in a collection
|
||||||
maxTaskNum: 1024 # max task number of proxy task queue
|
maxTaskNum: 1024 # max task number of proxy task queue
|
||||||
bufFlagExpireTime: 3600 # second, the time to expire bufFlag from cache in collectResultLoop
|
|
||||||
bufFlagCleanupInterval: 600 # second, the interval to clean bufFlag cache in collectResultLoop
|
|
||||||
# please adjust in embedded Milvus: false
|
# please adjust in embedded Milvus: false
|
||||||
ginLogging: false # Whether to produce gin logs.
|
ginLogging: false # Whether to produce gin logs.
|
||||||
|
|
||||||
|
@ -131,8 +131,6 @@ proxy:
|
|||||||
maxDimension: 32768 # Maximum dimension of a vector
|
maxDimension: 32768 # Maximum dimension of a vector
|
||||||
maxShardNum: 256 # Maximum number of shards in a collection
|
maxShardNum: 256 # Maximum number of shards in a collection
|
||||||
maxTaskNum: 1024 # max task number of proxy task queue
|
maxTaskNum: 1024 # max task number of proxy task queue
|
||||||
bufFlagExpireTime: 3600 # second, the time to expire bufFlag from cache in collectResultLoop
|
|
||||||
bufFlagCleanupInterval: 600 # second, the interval to clean bufFlag cache in collectResultLoop
|
|
||||||
# please adjust in embedded Milvus: false
|
# please adjust in embedded Milvus: false
|
||||||
ginLogging: true # Whether to produce gin logs.
|
ginLogging: true # Whether to produce gin logs.
|
||||||
|
|
||||||
|
1
go.mod
1
go.mod
@ -31,7 +31,6 @@ require (
|
|||||||
github.com/mitchellh/mapstructure v1.4.1
|
github.com/mitchellh/mapstructure v1.4.1
|
||||||
github.com/opentracing/opentracing-go v1.2.0
|
github.com/opentracing/opentracing-go v1.2.0
|
||||||
github.com/panjf2000/ants/v2 v2.4.8 // indirect
|
github.com/panjf2000/ants/v2 v2.4.8 // indirect
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
|
||||||
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
|
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/prometheus/client_golang v1.11.0
|
github.com/prometheus/client_golang v1.11.0
|
||||||
|
2
go.sum
2
go.sum
@ -534,8 +534,6 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw
|
|||||||
github.com/panjf2000/ants/v2 v2.4.8 h1:JgTbolX6K6RreZ4+bfctI0Ifs+3mrE5BIHudQxUDQ9k=
|
github.com/panjf2000/ants/v2 v2.4.8 h1:JgTbolX6K6RreZ4+bfctI0Ifs+3mrE5BIHudQxUDQ9k=
|
||||||
github.com/panjf2000/ants/v2 v2.4.8/go.mod h1:f6F0NZVFsGCp5A7QW/Zj/m92atWwOkY0OIhFxRNFr4A=
|
github.com/panjf2000/ants/v2 v2.4.8/go.mod h1:f6F0NZVFsGCp5A7QW/Zj/m92atWwOkY0OIhFxRNFr4A=
|
||||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
|
||||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ=
|
github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ=
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
// Licensed to the LF AI & Data foundation under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package proxy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/patrickmn/go-cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
type idCache struct {
|
|
||||||
cache *cache.Cache
|
|
||||||
}
|
|
||||||
|
|
||||||
func newIDCache(defaultExpiration, cleanupInterval time.Duration) *idCache {
|
|
||||||
c := cache.New(defaultExpiration, cleanupInterval)
|
|
||||||
return &idCache{
|
|
||||||
cache: c,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *idCache) Set(id UniqueID, value bool) {
|
|
||||||
r.cache.Set(strconv.FormatInt(id, 36), value, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *idCache) Get(id UniqueID) (value bool, exists bool) {
|
|
||||||
valueRaw, exists := r.cache.Get(strconv.FormatInt(id, 36))
|
|
||||||
if valueRaw == nil {
|
|
||||||
return false, exists
|
|
||||||
}
|
|
||||||
return valueRaw.(bool), exists
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package proxy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestIDCache_SetGet(t *testing.T) {
|
|
||||||
cache := newIDCache(time.Hour, time.Hour)
|
|
||||||
// not exist before set
|
|
||||||
_, exist := cache.Get(1)
|
|
||||||
assert.False(t, exist)
|
|
||||||
cache.Set(1, true)
|
|
||||||
// exist after set & before expire
|
|
||||||
value, exist := cache.Get(1)
|
|
||||||
assert.True(t, exist)
|
|
||||||
assert.True(t, value)
|
|
||||||
|
|
||||||
cache = newIDCache(time.Millisecond, time.Hour)
|
|
||||||
cache.Set(1, true)
|
|
||||||
<-time.After(time.Millisecond)
|
|
||||||
// not exists after set & expire
|
|
||||||
_, exist = cache.Get(1)
|
|
||||||
assert.False(t, exist)
|
|
||||||
}
|
|
@ -431,8 +431,6 @@ type proxyConfig struct {
|
|||||||
MaxFieldNum int64
|
MaxFieldNum int64
|
||||||
MaxShardNum int32
|
MaxShardNum int32
|
||||||
MaxDimension int64
|
MaxDimension int64
|
||||||
BufFlagExpireTime time.Duration
|
|
||||||
BufFlagCleanupInterval time.Duration
|
|
||||||
GinLogging bool
|
GinLogging bool
|
||||||
|
|
||||||
// required from QueryCoord
|
// required from QueryCoord
|
||||||
@ -460,8 +458,6 @@ func (p *proxyConfig) init(base *BaseTable) {
|
|||||||
p.initMaxDimension()
|
p.initMaxDimension()
|
||||||
|
|
||||||
p.initMaxTaskNum()
|
p.initMaxTaskNum()
|
||||||
p.initBufFlagExpireTime()
|
|
||||||
p.initBufFlagCleanupInterval()
|
|
||||||
p.initGinLogging()
|
p.initGinLogging()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,16 +542,6 @@ func (p *proxyConfig) initMaxTaskNum() {
|
|||||||
p.MaxTaskNum = p.Base.ParseInt64WithDefault("proxy.maxTaskNum", 1024)
|
p.MaxTaskNum = p.Base.ParseInt64WithDefault("proxy.maxTaskNum", 1024)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *proxyConfig) initBufFlagExpireTime() {
|
|
||||||
expireTime := p.Base.ParseInt64WithDefault("proxy.bufFlagExpireTime", 3600)
|
|
||||||
p.BufFlagExpireTime = time.Duration(expireTime) * time.Second
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *proxyConfig) initBufFlagCleanupInterval() {
|
|
||||||
interval := p.Base.ParseInt64WithDefault("proxy.bufFlagCleanupInterval", 600)
|
|
||||||
p.BufFlagCleanupInterval = time.Duration(interval) * time.Second
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *proxyConfig) initGinLogging() {
|
func (p *proxyConfig) initGinLogging() {
|
||||||
// Gin logging is on by default.
|
// Gin logging is on by default.
|
||||||
p.GinLogging = p.Base.ParseBool("proxy.ginLogging", true)
|
p.GinLogging = p.Base.ParseBool("proxy.ginLogging", true)
|
||||||
|
Loading…
Reference in New Issue
Block a user