[ODLPARENT-39] Code Generation Performance optimization required in YangTemplate (Xtend bug?) Created: 19/Jul/16 Updated: 24/Jan/18 Resolved: 02/Feb/17 |
|
| Status: | Resolved |
| Project: | odlparent |
| Component/s: | General |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Michael Vorburger | Assignee: | Michael Vorburger |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| External issue ID: | 6236 | ||||||||
| Description |
|
I have finally found a moment to performance profile the yangtools/mdsal code generation which occurs during a Maven build by attaching Java Mission Control (JMC) from Oracle JDK (not available on OpenJDK) to a local Maven build. This is similar to earlier Here are the exact steps I've used, if anyone wants to reproduce: $ export JAVA_HOME=/home/vorburger/bin/jdk1.8.0_92-ORACLE The result, attached as netvirt-mvn-o-Pq-clean-install.jfr.7z, is interesting IMHO - unless JMC is totally off, it would seem in [2] that we are spending ca. 20% of total Maven build time of e.g. netvirt in Xtend's org.eclipse.xtend2.lib.StringConcatenation called by YangTemplate, just to build those "verboseClassComments" for 'generated classes will include javadoc comments which re useful for users' with the "This class represents the following YANG schema fragment defined in module ...". The 20% just for that seems a lot - that's just a bunch of String concatenations, through the Xtend helper, which is supposed to "allow for efficient [, indentation aware] concatenation of character sequences" - I think either something is wrong with, or we're using it wrong. But the latter seems unlikely, as [1] YangTemplate looks like a pretty standard plain Xtend template class, to me... As a first step, I'll try to raise this with the Xmen (Xtend community), to see what they have to say about this. [2] JMC Code top Hot Method TXT copy/paste: Stack Trace Sample Count Percentage(%) |
| Comments |
| Comment by Michael Vorburger [ 19/Jul/16 ] |
|
Attachment netvirt-mvn-o-Pq-clean-install.jfr.7z has been added with description: Oracle Java Mission Control JFR profiling of "mvno -o -Pq clean install" in netvirt on latest netvirt master today (65fb44e) with export MAVEN_OPTS="-Xmx4096m -Xverify:none" |
| Comment by Michael Vorburger [ 19/Jul/16 ] |
|
> raise this with the Xmen (Xtend community), to see what they have to say |
| Comment by Martin Ciglan [ 17/Oct/16 ] |
|
any updates on this? Thanks. |
| Comment by Michael Vorburger [ 17/Oct/16 ] |
|
Martin, thanks for the ping - it's sometimes useful to get reminders... Dug a little more into this today. In https://git.opendaylight.org/gerrit/#/c/47036/, I'm introducing a proposed new "yang.skip.javadoc" system property, which if true skips the generation of those "verboseClassComments" for 'generated classes will include javadoc comments which re useful for users' with the "This class represents the following YANG schema fragment defined in module ...". The results are too small to be significant on a single project, but on a multi-module reactor as small as e.g. netvirt/vpnservice this looks very interesting, and makes me thing I'm onto something that is worth digging more into, check this out: netvirt/vpnservice: At the scale of a full ODL (autobuild), this would obviously likely be even more significant. I'll use this as motivation to reach out to eclipse.org friends about https://bugs.eclipse.org/bugs/show_bug.cgi?id=427909. In the mean time, if we would get https://git.opendaylight.org/gerrit/#/c/47036/ into ODL (and I would follow with an oldparent change to leverage this IFF -Pq), that would probably be something useful in the very short term already. |
| Comment by Robert Varga [ 25/Oct/16 ] |
|
Michael, is this still being worked on? |
| Comment by Michael Vorburger [ 31/Oct/16 ] |
|
> Michael, is this still being worked on? Robert, yup it is; this is proceeding on two levels, as outlined above: a) https://git.opendaylight.org/gerrit/#/c/47036/ for short-term b) https://bugs.eclipse.org/bugs/show_bug.cgi?id=427909 for medium term. I've actually discussed that with Sven Efftinge (AKA Mr. Xtext & Xtend..) at EclipseCon just last week! I've demonstrated the problem, and convinced him that there is one, which is always a good first step.. |
| Comment by Robert Varga [ 31/Oct/16 ] |
|
yeah, it's maybe 30 minutes – if that protected splitter method can be made non-public |
| Comment by Robert Varga [ 31/Oct/16 ] |
|
Attachment xtextlib.diff has been added with description: prototype dirty fix |
| Comment by Michael Vorburger [ 01/Nov/16 ] |
|
Robert, as per private email exchange, I've tested your "prototype dirty fix" (above), fixed what we agreed in email was left in there but you meant to remove, and done a few other things in StringConcatenation orthogonal to your change, which in my measurements have an additional measurable positive impact; see https://bugs.opendaylight.org/show_bug.cgi?id=6236 for full details, and https://github.com/eclipse/xtext-lib/pull/16/files for the proposed combined change. It's a step, but somehow I'm not entirely satisfied - still hot spot, when the goal should be to not have any in three.. Please do shout if you see any potential for further improvement? I've attempted to try out the full scenario from above with this fix, by replacing the x3 xtext/xbase/xtend (except xtend-maven-plugin) 2.9.2 in odlparent with locally built 2.11.0-SNAPSHOT: An "mvno -o -Pq clean install" in netvirt/vpnservice seems to go from approx. 3:07 down to 2:40, so 27s gained (BTW with a master 2.11.0-SNAPSHOT without changes it's still 3:06; tested). That's something, and reason enough for me to keep suggesting to Xtend to do something about this, on their side. For us in ODL in the short term though, as even this gain, if they accept it, when we upgrade, is still less than the more significant 1’ gain seen earlier above when just completely skipping Xtend with https://git.opendaylight.org/gerrit/#/c/47036/. My suggestion would thus be that we integrate c/47036 anyway. PS: When I JMC profile mvn then the hotstop still looks like the old one, so I doubted for a moment whether the lib switch from 2.9.2 to 2.11.0-SNAPSHOT even worked.. but as there is a measurable difference, that must be something else - the most likely explanation I have is that perhaps the test YangTemplateWithoutAnyDependencies.xtend doesn't lead to the exact same result as our "real" YangTemplate.xtend? |
| Comment by Robert Varga [ 04/Nov/16 ] |
|
Another performance improvement for codegen to not emit empty indentation strings: https://bugs.eclipse.org/bugs/show_bug.cgi?id=507077 |
| Comment by Michael Vorburger [ 12/Nov/16 ] |
| Comment by Martin Ciglan [ 02/Dec/16 ] |
|
Hi Michael I guess this can be closed as RESOLVED FIXED, right? |
| Comment by Michael Vorburger [ 12/Dec/16 ] |
|
> I guess this can be closed as RESOLVED FIXED, right? I would suggest to keep it open until a new Xtend version 2.11 including our (Robert's) fixes is released, and then switch to it, and retest.. According to https://typefox.io/xtext-2-11-beta-1-is-here, "The Xtext 2.11 release has been rescheduled for January 24th 2017." |
| Comment by Robert Varga [ 12/Dec/16 ] |
|
boron backport: https://git.opendaylight.org/gerrit/49234 |
| Comment by Robert Varga [ 12/Dec/16 ] |
|
The rest should be handled by odlparent upgrading to xtend to 2.11 once it is out. |
| Comment by Michael Vorburger [ 12/Dec/16 ] |
|
> boron backport: https://git.opendaylight.org/gerrit/49234 OK but in that case, also https://git.opendaylight.org/gerrit/#/c/49235/ |
| Comment by Robert Varga [ 22/Dec/16 ] |
|
The workarounds have been delivered to Boron-SR3, upstream patches have been accepted and will be part of xtend-2.11, which is scheduled to release on Jan 24. Targeting for M4 for the corresponding version bump. |
| Comment by Robert Varga [ 30/Jan/17 ] |
|
xtext release has been delayed, we will probably not make it to M5. patch to bump to 2.11.0.RC2: https://git.opendaylight.org/gerrit/51185 |
| Comment by Robert Varga [ 02/Feb/17 ] |
|
final bump: https://git.opendaylight.org/gerrit/51357 |