From 03a54c6d5f8211721524570e82f68b252526d0a1 Mon Sep 17 00:00:00 2001 From: "Jason E. Aten" Date: Tue, 8 Dec 2020 23:18:45 +0000 Subject: [PATCH] rowcache off by default. pilosa server --rowcache-on turns it back on. --- ctl/server.go | 4 ++-- holder.go | 10 +++++----- server.go | 10 +++++----- server/config.go | 6 ++++-- server/server.go | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ctl/server.go b/ctl/server.go index c548f93f3..8fd828d2d 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -95,8 +95,8 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { // cannot detect and honor the PILOSA_TXSRC env var over-ride. flags.StringVarP(&srv.Config.Txsrc, "txsrc", "", "", fmt.Sprintf("transaction/storage to use: one of roaring, rbf, bolt, lmdb, or a blue-green setup: rbf_roaring, roaring_rbf, bolt_roaring, roaring_bolt, bolt_rbf, etc. The default is: %v. The env var PILOSA_TXSRC is over-ridden by --tx option on the command line.", pilosa.DefaultTxsrc)) - // RowcacheOff - flags.BoolVarP((&srv.Config.RowcacheOff), "rowcache-off", "", srv.Config.RowcacheOff, "turn off the rowcache for all backends (reduces memory use)") + // RowcacheOn + flags.BoolVarP((&srv.Config.RowcacheOn), "rowcache-on", "", srv.Config.RowcacheOn, "turn on the rowcache for all backends (may speed some queries)") // RBF specific flags. See pilosa/rbf/cfg/cfg.go for definitions. srv.Config.RBFConfig.DefineFlags(flags) diff --git a/holder.go b/holder.go index 4a22cfa43..9ac008b08 100644 --- a/holder.go +++ b/holder.go @@ -145,8 +145,8 @@ type HolderOpts struct { // server.go OptServerTxsrc Txsrc string - // RowcacheOff, if true, turns off the row cache for all storage backends. - RowcacheOff bool + // RowcacheOn, if true, turns on the row cache for all storage backends. + RowcacheOn bool } func (h *Holder) StartTransaction(ctx context.Context, id string, timeout time.Duration, exclusive bool) (*Transaction, error) { @@ -207,7 +207,7 @@ type HolderConfig struct { NewAttrStore func(string) AttrStore Logger logger.Logger Txsrc string - RowcacheOff bool + RowcacheOn bool RBFConfig *rbfcfg.Config AntiEntropyInterval time.Duration @@ -263,7 +263,7 @@ func NewHolder(path string, cfg *HolderConfig) *Holder { OpenIDAllocator: cfg.OpenIDAllocator, translationSyncer: cfg.TranslationSyncer, Logger: cfg.Logger, - Opts: HolderOpts{Txsrc: cfg.Txsrc, RowcacheOff: cfg.RowcacheOff}, + Opts: HolderOpts{Txsrc: cfg.Txsrc, RowcacheOn: cfg.RowcacheOn}, SnapshotQueue: defaultSnapshotQueue, @@ -274,7 +274,7 @@ func NewHolder(path string, cfg *HolderConfig) *Holder { indexes: make(map[string]*Index), } - rbf.SetRowcacheOn(!cfg.RowcacheOff) + rbf.SetRowcacheOn(cfg.RowcacheOn) txf, err := NewTxFactory(cfg.Txsrc, path, h) panicOn(err) diff --git a/server.go b/server.go index 4e9fa6565..4d77eb195 100644 --- a/server.go +++ b/server.go @@ -356,11 +356,11 @@ func OptServerTxsrc(txsrc string) ServerOption { } } -// OptServerRowcacheOff is a functional option on Server -// used to turn off the row cache. -func OptServerRowcacheOff(rowcacheOff bool) ServerOption { +// OptServerRowcacheOn is a functional option on Server +// used to turn on the row cache. +func OptServerRowcacheOn(rowcacheOn bool) ServerOption { return func(s *Server) error { - s.holderConfig.RowcacheOff = rowcacheOff + s.holderConfig.RowcacheOn = rowcacheOn return nil } } @@ -438,7 +438,7 @@ func NewServer(opts ...ServerOption) (*Server, error) { } s.holder = NewHolder(path, s.holderConfig) s.holder.Stats.SetLogger(s.logger) - s.holder.Logger.Printf("RowCacheOff: %v", s.holderConfig.RowcacheOff) + s.holder.Logger.Printf("RowCacheOn: %v", s.holderConfig.RowcacheOn) cwd, err := os.Getwd() if err != nil { return nil, err diff --git a/server/config.go b/server/config.go index 838ed235f..f6b98e64e 100644 --- a/server/config.go +++ b/server/config.go @@ -201,8 +201,10 @@ type Config struct { // returned from the blueGreenTx. Txsrc string `toml:"txsrc"` - // RowcacheOff, if true, turns off the row cache for all storage backends. - RowcacheOff bool `toml:"rowcache-off"` + // RowcacheOn, if true, turns on the row cache for all storage backends. + // The default is now off because it makes rbf queries faster and uses + // much less memory. + RowcacheOn bool `toml:"rowcache-on"` // RBFConfig defines all externally configurable RBF flags. RBFConfig *rbfcfg.Config diff --git a/server/server.go b/server/server.go index 9fbf5c9bd..4ffa3c72c 100644 --- a/server/server.go +++ b/server/server.go @@ -411,7 +411,7 @@ func (m *Command) SetupServer() error { pilosa.OptServerClusterName(m.Config.Cluster.Name), pilosa.OptServerSerializer(proto.Serializer{}), pilosa.OptServerTxsrc(m.Config.Txsrc), - pilosa.OptServerRowcacheOff(m.Config.RowcacheOff), + pilosa.OptServerRowcacheOn(m.Config.RowcacheOn), pilosa.OptServerRBFConfig(m.Config.RBFConfig), pilosa.OptServerQueryHistoryLength(m.Config.QueryHistoryLength), coordinatorOpt,