Skip to content

Conversation

@PranaviAncha
Copy link
Collaborator

Improve CriteriaEvaluator performance by reducing ZooKeeper reads

Description

What: Optimizes CriteriaEvaluator to reduce message recipient evaluation time by minimizing redundant ZooKeeper reads.

Why: The current implementation performs unnecessary ZooKeeper roundtrips when evaluating message recipients. For common query patterns (e.g., targeting all instances or instance-only criteria), the evaluator reads more data than needed and performs redundant filtering, which increases latency especially in large clusters.

How:

  1. Direct LIVEINSTANCES lookup for all-instances queries: When no specific instance filter is provided (empty, "*", or "%"), the code now uses LIVEINSTANCES directly instead of querying INSTANCES first and then filtering by live participants.

  2. Optimized instance-only criteria: When only instance names are specified without resource/partition/state filters, the evaluator switches from EXTERNALVIEW to LIVEINSTANCES to avoid reading potentially large EXTERNALVIEW data.

  3. Skip redundant live participant checks: When the data source is already LIVEINSTANCES, the code skips fetching live participants again since all results are guaranteed to be live.

  4. Early exit optimization: Returns immediately when no live instances exist, avoiding unnecessary iteration.

  5. Code quality improvements: Uses SLF4J parameterized logging and Guava's string utilities for cleaner, more efficient code.

Tests

Modified tests:

  • TestDefaultMessagingService - Enhanced mock to support LIVEINSTANCES property type queries to properly test the optimized data source selection logic.

Existing test coverage:

  • The existing test suite in TestDefaultMessagingService validates the message routing behavior with the optimized criteria evaluation.
  • No new tests needed as the optimization preserves existing behavior while improving performance.

Changes that Break Backward Compatibility

None. This change is purely an internal optimization that preserves the existing API and behavior. The same messages are routed to the same recipients; the implementation simply does so more efficiently.

GrantPSpencer and others added 5 commits September 17, 2025 11:28
… calculate assignment (apache#3034)

* prevent DROPPED messages when mapping cannot be computed

* add test for CRUSHED resource

* add message generation phase tst

* fix test

* respond feedback
…eated workflows (linkedin#55)

* Fix stale cache issue causing erroneous workflow deletion in WorkflowDispatcher

* Address review comments

* Remove redundant tests
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