diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-04 10:57:22 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-04 10:57:22 +0300 |
| commit | aa2f547cf2b6136dc60f541f30c27a426ec7c6c8 (patch) | |
| tree | 6180691fc7a0753f82c16aefdbf7da078928a3ae /internal | |
| parent | becf8a2ea235ee37adceabc1733ae8727cec5488 (diff) | |
refactor: change turbo boost to be enabled by default
- Changed environment variable from DTAIL_TURBOBOOST_ENABLE to DTAIL_TURBOBOOST_DISABLE
- Changed config field from TurboModeEnable to TurboBoostDisable
- Turbo boost is now enabled by default and must be explicitly disabled
- Updated all code references, documentation, and examples
- No change in functionality, only inverted the boolean logic
This makes turbo boost opt-out rather than opt-in, providing better
default performance for large files while allowing users to disable
it for scenarios where it adds overhead.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/config/initializer.go | 8 | ||||
| -rw-r--r-- | internal/config/server.go | 12 | ||||
| -rw-r--r-- | internal/mapr/server/turbo_aggregate_test.go | 4 | ||||
| -rw-r--r-- | internal/server/handlers/mapcommand.go | 8 | ||||
| -rw-r--r-- | internal/server/handlers/readcommand.go | 12 |
5 files changed, 22 insertions, 22 deletions
diff --git a/internal/config/initializer.go b/internal/config/initializer.go index e750a1a..146d1a0 100644 --- a/internal/config/initializer.go +++ b/internal/config/initializer.go @@ -92,10 +92,10 @@ func (in *initializer) processEnvVars(args *Args) { if len(sshPrivateKeyPathFile) > 0 && args.SSHPrivateKeyFilePath == "" { args.SSHPrivateKeyFilePath = sshPrivateKeyPathFile } - // Check if turbo mode should be enabled from environment variable - // This allows backward compatibility with existing scripts - if Env("DTAIL_TURBOBOOST_ENABLE") { - in.Server.TurboModeEnable = true + // Check if turbo boost should be disabled from environment variable + // Turbo boost is enabled by default, can be explicitly disabled + if Env("DTAIL_TURBOBOOST_DISABLE") { + in.Server.TurboBoostDisable = true } } diff --git a/internal/config/server.go b/internal/config/server.go index d108ea3..efa7335 100644 --- a/internal/config/server.go +++ b/internal/config/server.go @@ -67,11 +67,11 @@ type ServerConfig struct { Ciphers []string `json:",omitempty"` // The allowed MAC algorithms. MACs []string `json:",omitempty"` - // Enable turbo mode for optimized file processing. When enabled, cat/grep/tail operations - // use a direct writing approach that bypasses internal channels for better performance. - // Note: This is disabled by default for MapReduce operations due to known issues with - // high-concurrency aggregate processing. - TurboModeEnable bool `json:",omitempty"` + // Disable turbo boost mode. When set to true, disables the optimized file processing mode. + // By default, turbo boost is enabled for cat/grep/tail and MapReduce operations, providing + // better performance through direct writing that bypasses internal channels. + // Set this to true only if you experience issues with turbo boost mode. + TurboBoostDisable bool `json:",omitempty"` } // Create a new default server configuration. @@ -90,7 +90,7 @@ func newDefaultServerConfig() *ServerConfig { Permissions: Permissions{ Default: defaultPermissions, }, - TurboModeEnable: false, // Default to false for safety, can be enabled via config + TurboBoostDisable: false, // Default to false, meaning turbo boost is enabled by default } } diff --git a/internal/mapr/server/turbo_aggregate_test.go b/internal/mapr/server/turbo_aggregate_test.go index b247201..ec1d6a3 100644 --- a/internal/mapr/server/turbo_aggregate_test.go +++ b/internal/mapr/server/turbo_aggregate_test.go @@ -25,7 +25,7 @@ func TestTurboAggregateVsRegular(t *testing.T) { if config.Server == nil { config.Server = &config.ServerConfig{ MapreduceLogFormat: "default", - TurboModeEnable: false, + TurboBoostDisable: false, } } if dlog.Server == nil { @@ -210,7 +210,7 @@ func TestTurboAggregateConcurrency(t *testing.T) { if config.Server == nil { config.Server = &config.ServerConfig{ MapreduceLogFormat: "default", - TurboModeEnable: false, + TurboBoostDisable: false, } } if dlog.Server == nil { diff --git a/internal/server/handlers/mapcommand.go b/internal/server/handlers/mapcommand.go index c804189..83c4c75 100644 --- a/internal/server/handlers/mapcommand.go +++ b/internal/server/handlers/mapcommand.go @@ -23,10 +23,10 @@ func newMapCommand(serverHandler *ServerHandler, argc int, m := mapCommand{server: serverHandler} queryStr := strings.Join(args[1:], " ") - // If turbo mode is enabled AND we're in server mode (not serverless), create a TurboAggregate - // Turbo mode is a server-side optimization and should not be used in serverless mode - dlog.Server.Debug("MapReduce mode check", "turboModeEnable", config.Server.TurboModeEnable, "serverless", serverHandler.serverless) - if config.Server.TurboModeEnable && !serverHandler.serverless { + // If turbo boost is not disabled AND we're in server mode (not serverless), create a TurboAggregate + // Turbo boost is enabled by default and is a server-side optimization + dlog.Server.Debug("MapReduce mode check", "turboBoostDisable", config.Server.TurboBoostDisable, "serverless", serverHandler.serverless) + if !config.Server.TurboBoostDisable && !serverHandler.serverless { dlog.Server.Info("Creating turbo aggregate for MapReduce", "query", queryStr) turboAggregate, err := server.NewTurboAggregate(queryStr) if err != nil { diff --git a/internal/server/handlers/readcommand.go b/internal/server/handlers/readcommand.go index 2ce1fc7..7037e5f 100644 --- a/internal/server/handlers/readcommand.go +++ b/internal/server/handlers/readcommand.go @@ -123,7 +123,7 @@ func (r *readCommand) readFiles(ctx context.Context, ltx lcontext.LContext, // In turbo mode, signal EOF after all files are processed // This is crucial for proper shutdown in server mode - if config.Server.TurboModeEnable && r.server.aggregate == nil && + if !config.Server.TurboBoostDisable && r.server.aggregate == nil && (r.mode == omode.CatClient || r.mode == omode.GrepClient || r.mode == omode.TailClient) { if r.server.IsTurboMode() && r.server.turboEOF != nil { dlog.Server.Debug(r.server.user, "Turbo mode: flushing data before EOF signal") @@ -261,12 +261,12 @@ func (r *readCommand) read(ctx context.Context, ltx lcontext.LContext, // Check if we should use the turbo boost optimizations // Enable turbo boost for cat/grep/tail modes, and now also for MapReduce operations // MapReduce now has a turbo mode implementation that bypasses channels - dlog.Server.Debug(r.server.user, "Checking turbo mode", "turboModeEnable", config.Server.TurboModeEnable, + dlog.Server.Debug(r.server.user, "Checking turbo mode", "turboBoostDisable", config.Server.TurboBoostDisable, "mode", r.mode, "hasTurboAggregate", r.server.turboAggregate != nil, "hasAggregate", r.server.aggregate != nil) // Only use turbo mode if: - // 1. Turbo mode is enabled AND + // 1. Turbo boost is NOT disabled (it's enabled by default) AND // 2. We have a turbo aggregate OR (we're in cat/grep/tail mode AND we don't have a regular aggregate) - if config.Server.TurboModeEnable && + if !config.Server.TurboBoostDisable && (r.server.turboAggregate != nil || ((r.mode == omode.CatClient || r.mode == omode.GrepClient || r.mode == omode.TailClient) && r.server.aggregate == nil)) { dlog.Server.Info(r.server.user, "Using turbo mode for reading", path, "mode", r.mode, "hasTurboAggregate", r.server.turboAggregate != nil) r.readWithTurboProcessor(ctx, ltx, path, globID, re, reader) @@ -327,8 +327,8 @@ func (r *readCommand) readWithProcessor(ctx context.Context, ltx lcontext.LConte aggregate := r.server.aggregate var lines chan *line.Line - // Use the optimized version if turbo boost is enabled - turboBoostEnabled := config.Server.TurboModeEnable + // Use the optimized version if turbo boost is not disabled (enabled by default) + turboBoostEnabled := !config.Server.TurboBoostDisable for { if aggregate != nil { |
