Skip to content

perf: enable backend and render optimizations by default - #583

Merged
timtofan merged 1 commit into
masterfrom
atimofieiev/default-performance-paths
Oct 22, 2026
Merged

timtofan merged 1 commit into
masterfrom
atimofieiev/default-performance-paths

Conversation

@timtofan

@timtofan timtofan commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The five backend/render performance paths already used in production require separate =1 environment overrides. Without those overrides, a new installation or a service-unit cleanup silently selects the previous implementations. Make the application own these defaults so deployment configuration does not need to repeat them.

Architecture

This is a startup-default change in the existing application and HTTP backend constructors. It does not add an implementation or change the request/response boundary. Synchronous HTTP, streaming render decoding, native gzip, packed backend points, and stable render batching become default-on. Each existing variable remains an independent =0 opt-out.

Native gzip still falls back to Go gzip in portable builds. Packed points still require streaming; stable batching still follows the existing glob mode and configured batch size. The prior buffered decoder, Go transport, unpacked points, and previous batching paths remain available for diagnosis. This preserves the existing compatibility paths without adding another maintained implementation.

This change does not alter the cross-target prefetch scheduling introduced in #582, backend deadlines, connection-pool settings, or the configured render batch size.

Before / after

Startup environment Before After
Variables absent or empty Previous implementations Optimized implementations
Variables set to 1 Optimized implementations Same optimized implementations
Individual variable set to 0 Previous implementation Same previous implementation
Native gzip unavailable in the build Go gzip fallback Same Go gzip fallback

Only the literal 0 disables a path after this change; other values enable it. The README documents the startup semantics and existing feature dependencies.

Usage

Start carbonapi without these previously required environment settings:

CARBONAPI_SYNC_BACKEND_HTTP=1
CARBONAPI_STREAM_RENDER=1
CARBONAPI_NATIVE_GZIP=1
CARBONAPI_PACK_BACKEND_POINTS=1
CARBONAPI_STABLE_RENDER_BATCH=1

For an individual opt-out, for example, set CARBONAPI_NATIVE_GZIP=0 and restart the process.

Validation

  • make test: full race suite with Cairo/native gzip/zlib-ng, followed by backend tests with system zlib and portable Go gzip; passed.
  • golangci-lint run: zero issues.
  • Backend and application race tests also passed with all five variables set to 0, exercising the retained opt-out paths.
  • Constructor tests exercise an absent environment and independent opt-outs.
  • The streaming differential test explicitly retains the buffered decoder as its oracle and compares default construction against it, including float bits and absence metadata.
  • Existing real-driver batching, packed replica merging, transport cancellation, and gzip corruption tests passed with the new defaults.

This PR changes defaults; it claims no additional production latency improvement over running the same binary with all five variables set to 1.

Rollout and rollback

Deploy this binary while retaining existing =1 service overrides. Then remove the redundant overrides. A new binary with the variables absent selects the same paths as the existing =1 configuration.

Before reverting to an older binary after removing the service overrides, restore all five =1 settings if the optimized paths should remain enabled. Individual =0 opt-outs continue to work with either binary.

@timtofan
timtofan merged commit 6be69a2 into master Oct 22, 2026
6 checks passed
@timtofan
timtofan deleted the atimofieiev/default-performance-paths branch October 22, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants