Revert "Make federationsender_cache_size configurable"

This reverts commit 4631f53241.
This commit is contained in:
Neil Alexander 2020-12-04 14:51:51 +00:00
parent d3da54e738
commit 423bdf3f0f
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
7 changed files with 17 additions and 36 deletions

View file

@ -42,7 +42,7 @@ func main() {
fmt.Println("Fetching", len(snapshotNIDs), "snapshot NIDs") fmt.Println("Fetching", len(snapshotNIDs), "snapshot NIDs")
cache, err := caching.NewInMemoryLRUCache(&cfg.Global) cache, err := caching.NewInMemoryLRUCache(true)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View file

@ -257,7 +257,7 @@ func testRoomserver(input []string, wantOutput []string, checkQueries func(api.R
panic(err) panic(err)
} }
cache, err := caching.NewInMemoryLRUCache(&cfg.Global) cache, err := caching.NewInMemoryLRUCache(false)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View file

@ -103,11 +103,6 @@ global:
username: metrics username: metrics
password: metrics password: metrics
# Advanced options for tuning in-memory caches. Do not change these unless
# you know what you are doing.
# caches:
# federationsender_cache_size: 128
# Configuration for the Appservice API. # Configuration for the Appservice API.
app_service_api: app_service_api:
internal_api: internal_api:

View file

@ -7,8 +7,9 @@ import (
) )
const ( const (
FederationSenderCacheName = "federation_event" FederationEventCacheName = "federation_event"
FederationSenderCacheMutable = true // to allow use of Unset only FederationEventCacheMaxEntries = 256
FederationEventCacheMutable = true // to allow use of Unset only
) )
// FederationSenderCache contains the subset of functions needed for // FederationSenderCache contains the subset of functions needed for

View file

@ -4,17 +4,16 @@ import (
"fmt" "fmt"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
"github.com/matrix-org/dendrite/setup/config"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promauto"
) )
func NewInMemoryLRUCache(cfg *config.Global) (*Caches, error) { func NewInMemoryLRUCache(enablePrometheus bool) (*Caches, error) {
roomVersions, err := NewInMemoryLRUCachePartition( roomVersions, err := NewInMemoryLRUCachePartition(
RoomVersionCacheName, RoomVersionCacheName,
RoomVersionCacheMutable, RoomVersionCacheMutable,
RoomVersionCacheMaxEntries, RoomVersionCacheMaxEntries,
cfg.Metrics.Enabled, enablePrometheus,
) )
if err != nil { if err != nil {
return nil, err return nil, err
@ -23,7 +22,7 @@ func NewInMemoryLRUCache(cfg *config.Global) (*Caches, error) {
ServerKeyCacheName, ServerKeyCacheName,
ServerKeyCacheMutable, ServerKeyCacheMutable,
ServerKeyCacheMaxEntries, ServerKeyCacheMaxEntries,
cfg.Metrics.Enabled, enablePrometheus,
) )
if err != nil { if err != nil {
return nil, err return nil, err
@ -32,7 +31,7 @@ func NewInMemoryLRUCache(cfg *config.Global) (*Caches, error) {
RoomServerStateKeyNIDsCacheName, RoomServerStateKeyNIDsCacheName,
RoomServerStateKeyNIDsCacheMutable, RoomServerStateKeyNIDsCacheMutable,
RoomServerStateKeyNIDsCacheMaxEntries, RoomServerStateKeyNIDsCacheMaxEntries,
cfg.Metrics.Enabled, enablePrometheus,
) )
if err != nil { if err != nil {
return nil, err return nil, err
@ -41,7 +40,7 @@ func NewInMemoryLRUCache(cfg *config.Global) (*Caches, error) {
RoomServerEventTypeNIDsCacheName, RoomServerEventTypeNIDsCacheName,
RoomServerEventTypeNIDsCacheMutable, RoomServerEventTypeNIDsCacheMutable,
RoomServerEventTypeNIDsCacheMaxEntries, RoomServerEventTypeNIDsCacheMaxEntries,
cfg.Metrics.Enabled, enablePrometheus,
) )
if err != nil { if err != nil {
return nil, err return nil, err
@ -50,7 +49,7 @@ func NewInMemoryLRUCache(cfg *config.Global) (*Caches, error) {
RoomServerRoomNIDsCacheName, RoomServerRoomNIDsCacheName,
RoomServerRoomNIDsCacheMutable, RoomServerRoomNIDsCacheMutable,
RoomServerRoomNIDsCacheMaxEntries, RoomServerRoomNIDsCacheMaxEntries,
cfg.Metrics.Enabled, enablePrometheus,
) )
if err != nil { if err != nil {
return nil, err return nil, err
@ -59,16 +58,16 @@ func NewInMemoryLRUCache(cfg *config.Global) (*Caches, error) {
RoomServerRoomIDsCacheName, RoomServerRoomIDsCacheName,
RoomServerRoomIDsCacheMutable, RoomServerRoomIDsCacheMutable,
RoomServerRoomIDsCacheMaxEntries, RoomServerRoomIDsCacheMaxEntries,
cfg.Metrics.Enabled, enablePrometheus,
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
federationEvents, err := NewInMemoryLRUCachePartition( federationEvents, err := NewInMemoryLRUCachePartition(
FederationSenderCacheName, FederationEventCacheName,
FederationSenderCacheMutable, FederationEventCacheMutable,
cfg.Caches.FederationSenderEventCacheSize, FederationEventCacheMaxEntries,
cfg.Metrics.Enabled, enablePrometheus,
) )
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -106,7 +106,7 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, useHTTPAPIs boo
logrus.WithError(err).Panicf("failed to start opentracing") logrus.WithError(err).Panicf("failed to start opentracing")
} }
cache, err := caching.NewInMemoryLRUCache(&cfg.Global) cache, err := caching.NewInMemoryLRUCache(true)
if err != nil { if err != nil {
logrus.WithError(err).Warnf("Failed to create cache") logrus.WithError(err).Warnf("Failed to create cache")
} }

View file

@ -48,9 +48,6 @@ type Global struct {
// Metrics configuration // Metrics configuration
Metrics Metrics `yaml:"metrics"` Metrics Metrics `yaml:"metrics"`
// Cache configuration
Caches Caches `yaml:"caches"`
} }
func (c *Global) Defaults() { func (c *Global) Defaults() {
@ -143,14 +140,3 @@ func (c DatabaseOptions) MaxOpenConns() int {
func (c DatabaseOptions) ConnMaxLifetime() time.Duration { func (c DatabaseOptions) ConnMaxLifetime() time.Duration {
return time.Duration(c.ConnMaxLifetimeSeconds) * time.Second return time.Duration(c.ConnMaxLifetimeSeconds) * time.Second
} }
type Caches struct {
FederationSenderEventCacheSize int `yaml:"federationsender_cache_size"`
}
func (c *Caches) Defaults() {
c.FederationSenderEventCacheSize = 128
}
func (c *Caches) Verify(configErrs *ConfigErrors, isMonolith bool) {
}