Skip to content

Use Exit terminal values for short-circuit in flatMap callbacks#112

Closed
EtaCassiopeia wants to merge 1 commit into
mainfrom
perf/use-exit-terminal-values
Closed

Use Exit terminal values for short-circuit in flatMap callbacks#112
EtaCassiopeia wants to merge 1 commit into
mainfrom
perf/use-exit-terminal-values

Conversation

@EtaCassiopeia
Copy link
Copy Markdown
Owner

Summary

ZIO.succeed(x), ZIO.unit, and ZIO.none create a Sync node that the ZIO runloop must interpret. Exit values (Exit.succeed(x), Exit.unit, Exit.none) are pre-allocated terminal values the runloop can short-circuit on, avoiding the interpretation step.

Applied in five hot-path callbacks where the value is unconditionally terminal:

  • FeatureFlagsLive.checkProviderStatusZIO.unitExit.unit (catch-all after error cases)
  • FeatureFlagsLive.currentEvaluatedFlagsZIO.succeed(Map.empty)Exit.succeed(Map.empty) (no-transaction branch)
  • Hook.scala structuredLogging.beforeZIO.unitExit.unit (level-disabled branch)
  • FeatureFlagRegistry.getClientZIO.succeed(c)Exit.succeed(c) (cache-hit branch)
  • FeatureFlagRegistry.defaultClient — same

Credit

Spotted in #110 by @guizmaii.

Test plan

  • All 340 tests pass
  • scalafmtCheckAll clean

@EtaCassiopeia
Copy link
Copy Markdown
Owner Author

Tested independently; closing in favor of #110.

@EtaCassiopeia EtaCassiopeia deleted the perf/use-exit-terminal-values branch May 13, 2026 01:52
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.

1 participant