Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize ObjId2FullSidMap::extractObjectId #599

Conversation

quijote
Copy link
Contributor

@quijote quijote commented Jul 19, 2024

Monitoring of one of our Jenkins instances showed that ObjId2FullSidMap::extractObjectId was a major CPU hotspot.

image

This PR attempts to make the code significantly faster.

Testing done

The change was tested with the newly created functional test (ObjId2FullSidMapTest::testExtractObjectId) and the newly created microbenchmark (ObjId2FullSidMapTest::testExtractObjectIdPerformance).

On my local machine the benchmark reported the following with the original code:

Median duration per call (nanos): 981

With the new code the benchmark reports:

Median duration per call (nanos): 34

So, this suggest that the new code is roughly 28 times faster than the previous one for typical input.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

Thanks!


@Ignore
@Test
public void testExtractObjectIdPerformance() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

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

FWIW JMH benchmarks are supported with something like this:
https://github.com/jenkinsci/junit-sql-storage-plugin/blob/master/src/test/java/io/jenkins/plugins/junit/storage/database/benchmarks/TrendGraphBenchmark.java

in case you are interested in converting but probably not worth it.

unsure if its worth committing this but certainly useful to provide it demonstrating the change.

@timja timja merged commit 747b318 into jenkinsci:master Jul 19, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants