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

Performance improvements for easyconfig parsing and eb startup #3555

Merged
merged 10 commits into from
May 14, 2021

Conversation

Flamefire
Copy link
Contributor

With cProfile I identified 2 hotspots:

  • TEMPLATE_SOFTWARE_VERSIONS resolving was inefficient duplicating lot's of work
  • the Toolchain.get_module_version raises EasyBuildError which is a particularly expensive exception due to stack tracing, logging, ... There is a seemingly prominent case where failure is expected. Hence I added a param so None is returned instead
    The other function could be changed too, but it is not required or useful (yet).

My Python also complained about a leaked handle in run which might become a problem when it is called often (which we do) leading to anything from nothing over slowdown to crash.

@boegel boegel added this to the next release (4.3.3?) milestone Jan 29, 2021
@boegel boegel changed the title Performance improvements for EC parsing Performance improvements for easyconfig parsing Feb 3, 2021
@Flamefire Flamefire force-pushed the perf_improvement branch 3 times, most recently from ee89195 to e8d4e65 Compare February 4, 2021 09:35
@Flamefire Flamefire changed the title Performance improvements for easyconfig parsing Performance improvements for easyconfig parsing and eb startup Feb 5, 2021
Prior to this the handle was left open leading to a resource leak
As we use this function quite often this can become serious
Prior to this all dependencies were iterated over multiple times with
quite expensive handling, e.g. a full copy of the dependencies, list
concatenation, and many dict operations

Changes:
 - To avoid the search in the TEMPLATE_SOFTWARE_VERSIONS it is converted
   to a dict with the key already lowercased (instead of for every dep)
 - The copy of the dependencies list is done only when required
 - Dependencies are iterated only once and instead a matching template
   is searched for which is a lot less work
This avoids raising a traced and hence expensive exception although a
more or less common case is fine with "no result"
This yields a ~13% speedup in the parsing and sorting of all ECs in the
EC unit tests (3m -> 2:30m)
Allow empty PYTHONPATH and non-English LANG/LC_ALL settings by
explicitely handling those
The Python docs suggest against the current usage.
In profiles it has shown that this is very slow as for every translation
request the translation file is searched and an exception thrown as none
is found.
The change caches the translation which would be (temporarily) created by _gettext (on every call) and reuses it.
If none is found a fallback (NullTranslation) is automatically used.
@easybuilders easybuilders deleted a comment from boegelbot May 13, 2021
Copy link
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

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

Thoroughly reviewed, lgtm.

Also tested this a bit in the wild, didn't run into any surprises, so going in.

Thanks a lot @Flamefire, this probably took quite a bit of time to figure out...

@boegel boegel merged commit ef658b7 into easybuilders:develop May 14, 2021
@Flamefire Flamefire deleted the perf_improvement branch May 15, 2021 08:24
migueldiascosta added a commit to migueldiascosta/easybuild-framework that referenced this pull request May 27, 2021
…iden '_get_software_root' in fujitsu toolchain
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