[#1375] node: Configure of the container cache size
All checks were successful
DCO action / DCO (pull_request) Successful in 1m43s
Vulncheck / Vulncheck (pull_request) Successful in 2m8s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m21s
Tests and linters / Run gofumpt (pull_request) Successful in 2m38s
Tests and linters / gopls check (pull_request) Successful in 2m43s
Build / Build Components (pull_request) Successful in 2m59s
Tests and linters / Staticcheck (pull_request) Successful in 2m58s
Tests and linters / Lint (pull_request) Successful in 3m37s
Tests and linters / Tests (pull_request) Successful in 5m30s
Tests and linters / Tests with -race (pull_request) Successful in 5m33s
All checks were successful
DCO action / DCO (pull_request) Successful in 1m43s
Vulncheck / Vulncheck (pull_request) Successful in 2m8s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m21s
Tests and linters / Run gofumpt (pull_request) Successful in 2m38s
Tests and linters / gopls check (pull_request) Successful in 2m43s
Build / Build Components (pull_request) Successful in 2m59s
Tests and linters / Staticcheck (pull_request) Successful in 2m58s
Tests and linters / Lint (pull_request) Successful in 3m37s
Tests and linters / Tests (pull_request) Successful in 5m30s
Tests and linters / Tests with -race (pull_request) Successful in 5m33s
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
66e17f4b8e
commit
fa0480a3b6
6 changed files with 24 additions and 7 deletions
|
@ -165,13 +165,11 @@ type ttlContainerStorage struct {
|
|||
delInfoCache *ttlNetCache[cid.ID, *container.DelInfo]
|
||||
}
|
||||
|
||||
func newCachedContainerStorage(v container.Source, ttl time.Duration) ttlContainerStorage {
|
||||
const containerCacheSize = 100
|
||||
|
||||
lruCnrCache := newNetworkTTLCache(containerCacheSize, ttl, func(id cid.ID) (*container.Container, error) {
|
||||
func newCachedContainerStorage(v container.Source, ttl time.Duration, containerCacheSize uint32) ttlContainerStorage {
|
||||
lruCnrCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(id cid.ID) (*container.Container, error) {
|
||||
return v.Get(id)
|
||||
}, metrics.NewCacheMetrics("container"))
|
||||
lruDelInfoCache := newNetworkTTLCache(containerCacheSize, ttl, func(id cid.ID) (*container.DelInfo, error) {
|
||||
lruDelInfoCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(id cid.ID) (*container.DelInfo, error) {
|
||||
return v.DeletionInfo(id)
|
||||
}, metrics.NewCacheMetrics("container_deletion_info"))
|
||||
|
||||
|
|
|
@ -574,6 +574,8 @@ type cfgMorph struct {
|
|||
// TTL of Sidechain cached values. Non-positive value disables caching.
|
||||
cacheTTL time.Duration
|
||||
|
||||
containerCacheSize uint32
|
||||
|
||||
proxyScriptHash neogoutil.Uint160
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ const (
|
|||
|
||||
// FrostfsIDCacheSizeDefault is a default value of APE chain cache.
|
||||
FrostfsIDCacheSizeDefault = 10_000
|
||||
|
||||
// ContainerCacheSizeDefault is a default value of size container cache.
|
||||
ContainerCacheSizeDefault = 100
|
||||
)
|
||||
|
||||
var errNoMorphEndpoints = errors.New("no morph chain RPC endpoints, see `morph.rpc_endpoint` section")
|
||||
|
@ -103,6 +106,18 @@ func CacheTTL(c *config.Config) time.Duration {
|
|||
return CacheTTLDefault
|
||||
}
|
||||
|
||||
// ContainerCacheSize returns the value of "container_cache_size" config parameter
|
||||
// from "morph" section.
|
||||
//
|
||||
// Returns 0 if the value is not positive integer.
|
||||
// Returns ContainerCacheSizeDefault if the value is missing.
|
||||
func ContainerCacheSize(c *config.Config) uint32 {
|
||||
if c.Sub(subsection).Value("container_cache_size") == nil {
|
||||
return ContainerCacheSizeDefault
|
||||
}
|
||||
return config.Uint32Safe(c.Sub(subsection), "container_cache_size")
|
||||
}
|
||||
|
||||
// SwitchInterval returns the value of "switch_interval" config parameter
|
||||
// from "morph" section.
|
||||
//
|
||||
|
|
|
@ -79,7 +79,7 @@ func configureEACLAndContainerSources(c *cfg, client *cntClient.Client, cnrSrc c
|
|||
neoClient: client,
|
||||
}
|
||||
|
||||
if c.cfgMorph.cacheTTL <= 0 {
|
||||
if c.cfgMorph.cacheTTL <= 0 || c.cfgMorph.containerCacheSize == 0 {
|
||||
c.cfgObject.eaclSource = eACLFetcher
|
||||
cnrRdr.eacl = eACLFetcher
|
||||
c.cfgObject.cnrSource = cnrSrc
|
||||
|
@ -87,7 +87,7 @@ func configureEACLAndContainerSources(c *cfg, client *cntClient.Client, cnrSrc c
|
|||
cnrRdr.lister = client
|
||||
} else {
|
||||
// use RPC node as source of Container contract items (with caching)
|
||||
cachedContainerStorage := newCachedContainerStorage(cnrSrc, c.cfgMorph.cacheTTL)
|
||||
cachedContainerStorage := newCachedContainerStorage(cnrSrc, c.cfgMorph.cacheTTL, c.cfgMorph.containerCacheSize)
|
||||
cachedEACLStorage := newCachedEACLStorage(eACLFetcher, c.cfgMorph.cacheTTL)
|
||||
|
||||
subscribeToContainerCreation(c, func(e event.Event) {
|
||||
|
|
|
@ -90,6 +90,7 @@ func initMorphComponents(ctx context.Context, c *cfg) {
|
|||
|
||||
var netmapSource netmap.Source
|
||||
|
||||
c.cfgMorph.containerCacheSize = morphconfig.ContainerCacheSize(c.appCfg)
|
||||
c.cfgMorph.cacheTTL = morphconfig.CacheTTL(c.appCfg)
|
||||
|
||||
if c.cfgMorph.cacheTTL == 0 {
|
||||
|
|
|
@ -80,6 +80,7 @@ morph:
|
|||
cache_ttl: 15s # Sidechain cache TTL value (min interval between similar calls). Negative value disables caching.
|
||||
# Default value: block time. It is recommended to have this value less or equal to block time.
|
||||
# Cached entities: containers, container lists, eACL tables.
|
||||
container_cache_size: 1000 # container_cache_size is responsible for the number of containers that are in the cache.
|
||||
switch_interval: 3m # interval b/w RPC switch attempts if the node is connected not to the highest priority node
|
||||
rpc_endpoint: # side chain NEO RPC endpoints; are shuffled and used one by one until the first success
|
||||
- address: wss://rpc1.morph.frostfs.info:40341/ws
|
||||
|
|
Loading…
Reference in a new issue