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

[MNG-6693] Various speed improvements #259

Closed
wants to merge 5 commits into from
Closed

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Jun 28, 2019

No description provided.

Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

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

Can you please explain how your changes improve performance?

@gnodet
Copy link
Contributor Author

gnodet commented Jun 28, 2019

How ? You mean why each change helps improving performance or how did I measure the effect ? or how did i find those ?
For the what, my main goal is to speed up time mvn foo when running the build on https://github.com/apache/camel, so that's easily reproducible. Currently, with 3.6.1, it takes more than 50s. I'm now slightly above 30s with all the included changes.
As for the how, I'm using YourKit profile to find out the spots that takes times. I've been spending a lot of time trying to improve the model building mechanism in various ways, but could not get any significant results, so I'm back to a bunch of smaller improvements, which is the subject of this PR.
For the specifics, it depends:

  • using regexp is quite slow for simple checks, so checking if there's a '-' in a string is way faster than running the regexp in the first place, so if we can avoid it, it's better
  • avoid running the full model interpolation on the parent if the version is not to be interpolated
  • speed up the string search interpolator by reusing the plexus interpolator instead of adding / removing the same value sources / processors each time
  • cache valid ids (they are mostly always the same)
  • avoid concatenating strings which are not used (during validation, as they are only used when there's a violation)
  • the second commit provides a full blown new model interpolator which does not use reflection and is much master
  • the third commit does early checking before calling Validate.notBlank which proves to be quite slow when called a few million times

@gnodet
Copy link
Contributor Author

gnodet commented Jun 28, 2019

Another point to consider for speed improvements would be to use specific Map implementations where it makes sense. In my run, I end up with 9.951.957 calls to HashMap.put taking up to 12% of the time used when running DefaultMaven.buildGraph, so it's worth investigating.

@michael-o
Copy link
Member

Thanks, I will go through. I think the new model interpolator deserves a separate ticket. The rest seems to be spot improvements.

This map is not used by maven and the computation can be quite heavy, so lazy compute it.  In addition, do not clone the map, as it's an unmodifiable one.
@gnodet
Copy link
Contributor Author

gnodet commented Jun 28, 2019

I'll create a separate ticket on monday for the interpolator and will thus keep this PR for the other small changes.

@gnodet
Copy link
Contributor Author

gnodet commented Jun 28, 2019

I've pushed 2 new commits. I'll create a separate JIRA issue for the one about the ManagedVersionMap which saves another couple of seconds.

@gnodet
Copy link
Contributor Author

gnodet commented Jun 29, 2019

Closing this PR as I've opened 4 smaller ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants