Skip to content

Conversation

@ngngwr
Copy link
Collaborator

@ngngwr ngngwr commented Nov 3, 2025

Issues

  • My PR addresses the following Helix issues and references them in the PR description:

Helix is facing increased pipeline execution time for very large clusters. Here we are trying to optimise the segments which are taking lot of time.

Description

  • Here are some details about my PR, including screenshots of any UI changes:

(Write a concise description including what, why, how)

  • getPath() is being called multiple times during the pipeline execution and not very efficient due to regex matching.


Screenshot 2025-11-03 at 2 36 59 PM

  1. How it works before this change?
  • Every time a ZooKeeper path needs to be built:
  • Template string is retrieved: "/{clusterName}/INSTANCES/{instanceName}/CURRENTSTATES/{sessionId}"
  • Regex pattern matcher is created to find all placeholders (e.g., {clusterName}, {instanceName})
  • String scanning: Matcher scans the entire template string multiple times to locate each {...} placeholder
  • String replacement: Each placeholder is replaced using String.replace(), creating new intermediate string objects
  • This process repeats for every single path built during execution
  1. How it will work after this change?
  • One-time initialization (at application startup):
  • Each template is parsed once into a PathTemplate object
  • Static text parts are extracted and stored: ["/", "/INSTANCES/", "/CURRENTSTATES/", ""]
  • No regex needed after this point
  • Runtime path building (hot path):
  • Uses StringBuilder to concatenate pre-parsed static parts with parameters
  • Example: "/" + clusterName + "/INSTANCES/" + instanceName + "/CURRENTSTATES/" + sessionId
  • Simple, fast string appending with no regex or searching

The above optimisation makes a difference when the cluster size is huge.

Tests

  • The following tests are written for this issue:

(List the names of added unit/integration tests)

  • The following is the result of the "mvn test" command on the appropriate module:

(If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)

Unit tested.

Changes that Break Backward Compatibility (Optional)

  • My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:

(Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
None.

Documentation (Optional)

  • In case of new functionality, my PR adds documentation in the following wiki page:

(Link the GitHub wiki you added)

Commits

  • My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Code Quality

  • My diff has been formatted using helix-style.xml
    (helix-style-intellij.xml if IntelliJ IDE is used)

Copy link
Collaborator

@laxman-ch laxman-ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ngngwr : Can we please get some evidence (detailed CPU profile) to prove if this really is a bottleneck.

@proud-parselmouth
Copy link
Collaborator

I think Grant already optimized PropertyPathKey, can you check this PR once?
apache#3040

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.

4 participants