Uploaded image for project: 'odlparent'
  1. odlparent
  2. ODLPARENT-39

Code Generation Performance optimization required in YangTemplate (Xtend bug?)

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • General
    • None
    • Operating System: All
      Platform: All

    • 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 YANGTOOLS-629 but here focusing on looking at Maven itself, Maven plugins, code generation and build - so intentionally excluding the SingleFeatureTest and integration tests etc. using my new -Pq quick profile which local developers are increasingly using now.

      Here are the exact steps I've used, if anyone wants to reproduce:

      $ export JAVA_HOME=/home/vorburger/bin/jdk1.8.0_92-ORACLE
      $ export PATH=$JAVA_HOME/bin:$PATH
      $ export MAVEN_OPTS="-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexitpath=/home/vorburger/dev/ODL/git/netvirt/mvn.jfr"
      $ mvno -o -Pq clean install

      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.

      [1] https://github.com/opendaylight/mdsal/blob/32d45af3bfde08f4e8741632ecab43241831d1fe/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/YangTemplate.xtend

      [2] JMC Code top Hot Method TXT copy/paste:

      Stack Trace Sample Count Percentage(%)
      org.eclipse.xtend2.lib.StringConcatenation.appendSegments(String, int, List, String) 2,407 19.344
      org.eclipse.xtend2.lib.StringConcatenation.append(Object, String, int) 2,407 19.344
      org.eclipse.xtend2.lib.StringConcatenation.append(Object, String) 2,407 19.344
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeListSchemaNode(ListSchemaNode) 674 5.417
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeDataSchemaNode(DataSchemaNode) 674 5.417
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeDataSchemaNodes(Collection) 609 4.894
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeContSchemaNode(ContainerSchemaNode) 423 3.4
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeDataSchemaNode(DataSchemaNode) 423 3.4
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeDataSchemaNodes(Collection) 223 1.792
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeListSchemaNode(ListSchemaNode) 128 1.029
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeDataSchemaNode(DataSchemaNode) 128 1.029
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeDataSchemaNodes(Collection) 105 0.844
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeListSchemaNode(ListSchemaNode) 34 0.273
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeDataSchemaNode(DataSchemaNode) 34 0.273
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeDataSchemaNodes(Collection) 31 0.249
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeContSchemaNode(ContainerSchemaNode) 11 0.088
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.writeDataSchemaNode(DataSchemaNode) 11 0.088
      org.opendaylight.yangtools.sal.binding.generator.impl.YangTemplate.generateYangSnipet(SchemaNode) 8 0.064
      org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl.createDescription(SchemaNode, String) 8 0.064

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              vorburger Michael Vorburger
              vorburger Michael Vorburger
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: