<!-- 
RSS generated by JIRA (8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d) at Wed Feb 07 20:08:50 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>OpenDaylight JIRA</title>
    <link>https://jira.opendaylight.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.20.10</version>
        <build-number>820010</build-number>
        <build-date>22-06-2022</build-date>
    </build-info>


<item>
            <title>[MDSAL-170] Populate _value in IpAddressBinary union lazily</title>
                <link>https://jira.opendaylight.org/browse/MDSAL-170</link>
                <project id="10137" key="MDSAL">mdsal</project>
                    <description>&lt;p&gt;The lispflowmapping project switched using YANG modeled binary representation for IP addresses &lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt; internally in the southbound plugin, where it is rarely necessary to have access to string representation of the addresses. I did some profling before and after the change, to assess the gains in performance. To my surprise, code using the union of binary IPv4 and IPv6 (i.e., IpAddressBinary) suffered a serious performance regression, instead of improving.&lt;/p&gt;

&lt;p&gt;For example, we switched this code:&lt;/p&gt;

&lt;p&gt;    public static IpAddress getIpAddressFromInetAddress(InetAddress address) &lt;/p&gt;
{
        return IetfInetUtil.INSTANCE.ipAddressFor(address);
    }

&lt;p&gt;to this:&lt;/p&gt;

&lt;p&gt;    public static IpAddressBinary getIpAddressBinaryFromInetAddress(InetAddress address) &lt;/p&gt;
{
        return IpAddressBinaryBuilder.getDefaultInstance(address.getAddress());
    }

&lt;p&gt;Using YourKit with sampling, for 20 minutes, the first takes ~2s total time, while the second takes ~150s. The reason for the regression is the constructor of the union generated code, which looks like this:&lt;/p&gt;

&lt;p&gt;    public IpAddressBinary(Ipv4AddressBinary _ipv4AddressBinary) &lt;/p&gt;
{
        super();
        this._ipv4AddressBinary = _ipv4AddressBinary;
        this._ipv6AddressBinary = null;
        this._value = BaseEncoding.base64().encode(_ipv4AddressBinary.getValue()).toCharArray();
    }

&lt;p&gt;    public IpAddressBinary(Ipv6AddressBinary _ipv6AddressBinary) &lt;/p&gt;
{
        super();
        this._ipv6AddressBinary = _ipv6AddressBinary;
        this._ipv4AddressBinary = null;
        this._value = BaseEncoding.base64().encode(_ipv6AddressBinary.getValue()).toCharArray();
    }

&lt;p&gt;Those 150s are spent in the encode() method. I assume this is part of the solution for &lt;a href=&quot;https://jira.opendaylight.org/browse/MDSAL-131&quot; title=&quot;toString() throws exception for &amp;#39;type binary&amp;#39; binding&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MDSAL-131&quot;&gt;&lt;del&gt;MDSAL-131&lt;/del&gt;&lt;/a&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt;, where I only reviewed the proposed solution patch for functionality, and not performance. Note that we don&apos;t have this issue with the base types Ipv4AddressBinary and Ipv6AddressBinary, their classes don&apos;t even contain an encode() method, only decode() for passing a string as an argument to the constructor.&lt;/p&gt;

&lt;p&gt;This defeats the purpose of using binary types in the first place. Is there a way to solve &lt;a href=&quot;https://jira.opendaylight.org/browse/MDSAL-131&quot; title=&quot;toString() throws exception for &amp;#39;type binary&amp;#39; binding&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MDSAL-131&quot;&gt;&lt;del&gt;MDSAL-131&lt;/del&gt;&lt;/a&gt; in a way that doesn&apos;t affect performance? I guess for the IPv4 and IPv6 binary base types the base64 encoding is only done when really necessary. Could that be done for the union too?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
-Lori&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt; &lt;a href=&quot;https://git.opendaylight.org/gerrit/gitweb?p=lispflowmapping.git;a=blob;f=mappingservice/lisp-proto/src/main/yang/odl-inet-binary-types.yang;h=9706197c7b2f4481396af002fffa1efe13ad3b09;hb=HEAD&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/gitweb?p=lispflowmapping.git;a=blob;f=mappingservice/lisp-proto/src/main/yang/odl-inet-binary-types.yang;h=9706197c7b2f4481396af002fffa1efe13ad3b09;hb=HEAD&lt;/a&gt;&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt; &lt;a href=&quot;https://bugs.opendaylight.org/show_bug.cgi?id=5446&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://bugs.opendaylight.org/show_bug.cgi?id=5446&lt;/a&gt;&lt;/p&gt;</description>
                <environment>&lt;p&gt;Operating System: All&lt;br/&gt;
Platform: All&lt;/p&gt;</environment>
        <key id="26992">MDSAL-170</key>
            <summary>Populate _value in IpAddressBinary union lazily</summary>
                <type id="10104" iconUrl="https://jira.opendaylight.org/secure/viewavatar?size=xsmall&amp;avatarId=10303&amp;avatarType=issuetype">Bug</type>
                                                <status id="10004" iconUrl="https://jira.opendaylight.org/images/icons/status_generic.gif" description="">Verified</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="rovarga">Robert Varga</assignee>
                                    <reporter username="ljakab">Lori Jakab</reporter>
                        <labels>
                    </labels>
                <created>Thu, 26 May 2016 11:56:09 +0000</created>
                <updated>Fri, 9 Mar 2018 18:00:15 +0000</updated>
                            <resolved>Wed, 1 Jun 2016 08:47:10 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="54331" author="rovarga" created="Sat, 28 May 2016 09:28:03 +0000"  >&lt;p&gt;Argh, union types again. The problem is implementation interplay between UnionTemplate.xtend and its superclass ClassTemplate.xtend around initialization of _value field.&lt;/p&gt;

&lt;p&gt;In normal classes this field is final, as it really holds the value. This is not the case for unions, as the value is actually held by one of the constituent fields.&lt;/p&gt;

&lt;p&gt;Unfortunately ClassTemplate&apos;s requirement to have _value initialized is forcing UnionTemplate to eagerly encode it &amp;#8211; which is done in the beautiful bottom part of UnionTemplate#unionConstructors().&lt;/p&gt;

&lt;p&gt;The interplay has also further bad effects, as union classes take _value into account in their toString(), hashCode() and equals() methods &amp;#8211; and they should not, as this information is already included via the constituent types.&lt;/p&gt;

&lt;p&gt;To fix this,  unions&apos; _value field must not be final, but rather default to null. It should be initialized on first access via getValue() by looking for the first non-null constituent and convering it to char[]. This means the conversion will be done lazily, fixing the performance issue observed. I am not sure how to do this cleanly.&lt;/p&gt;

&lt;p&gt;Also hashCode()/equals()/toString() must not touch the _value in any way, as that would either force its instantiation (shifting the performance problem) or lead to inconsistent results. This can be achieved by not adding &quot;value&quot; via GeneratedTOBuilder.add&lt;/p&gt;
{Equals,Hash,ToString}
&lt;p&gt;Property() if the target is an union.&lt;/p&gt;</comment>
                            <comment id="54332" author="rovarga" created="Sat, 28 May 2016 10:20:13 +0000"  >&lt;p&gt;Patch to remove _value from hashCode/equals/toString: &lt;a href=&quot;https://git.opendaylight.org/gerrit/39554&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/39554&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="54333" author="rovarga" created="Sat, 28 May 2016 13:26:39 +0000"  >&lt;p&gt;The patch above should address all concerns.&lt;/p&gt;</comment>
                            <comment id="54334" author="rovarga" created="Sat, 28 May 2016 14:03:36 +0000"  >&lt;p&gt;This is a major performance regression, Be-3 should not ship without a fix.&lt;/p&gt;</comment>
                            <comment id="54335" author="rovarga" created="Tue, 31 May 2016 16:01:07 +0000"  >&lt;p&gt;be: &lt;a href=&quot;https://git.opendaylight.org/gerrit/39657&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/39657&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="54336" author="ljakab" created="Wed, 1 Jun 2016 08:47:10 +0000"  >&lt;p&gt;Apart from checking the generated code, I did some profiling, and while getIpAddressFromInetAddress() still shows up in sampled output with the previously measured ~2 seconds, getIpAddressBinaryFromInetAddress() is completely missing from repeated sampled profiling sessions, which is what I was looking for &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.opendaylight.org/images/icons/emoticons/biggrin.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                            <customfield id="customfield_11400" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10208" key="com.atlassian.jira.plugin.system.customfieldtypes:textfield">
                        <customfieldname>External issue ID</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5970</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10201" key="com.atlassian.jira.plugin.system.customfieldtypes:url">
                        <customfieldname>External issue URL</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[https://bugs.opendaylight.org/show_bug.cgi?id=5970]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10206" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Issue Type</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10300"><![CDATA[Bug]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10204" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>ODL SR Target Milestone</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10341"><![CDATA[Beryllium-3]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10000" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|i02wqv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>