[jboss-jira] [JBoss JIRA] (AS7-3789) Hornetq adds up to 4s to boot of as7 full configuration.

Tomaz Cerar (JIRA) jira-events at lists.jboss.org
Thu Feb 16 08:26:36 EST 2012


    [ https://issues.jboss.org/browse/AS7-3789?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12667076#comment-12667076 ] 

Tomaz Cerar commented on AS7-3789:
----------------------------------

What is currently happening in the code is that it gets all NetworkInterfaces and then iterates trough them until it finds appropriate one and uses its hardware address.

this is the code of org.hornetq.utils.UUIDGenerator cleaned up for easier reading and without reflection)

{code:java}
       Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
            while (en.hasMoreElements()) {
                NetworkInterface nint = en.nextElement();

                if (nint.isVirtual())continue;
                if (!nint.isLoopback()) { 
                    byte[] address = nint.getHardwareAddress();
                    if (address != null && address.length == 6) {

                        byte[] paddedAddress = UUIDGenerator.getZeroPaddedSixBytes(address);

                        if (UUIDGenerator.isBlackList(address)) {
                            continue;
                        }

                        if (paddedAddress != null) {
                            if (UUIDGenerator.log.isDebugEnabled()) {
                                UUIDGenerator.log.debug("using hardware address " + UUIDGenerator.asString(paddedAddress));
                            }
                            return paddedAddress;
                        }
                    }
                }
            }
{code}
problem on windows7 is that because of ipv6 for every nic you have you get 4 entries in return of NetworkInterface.getNetworkInterfaces();
in my case there are 12 network interfaces(vmware,vpn, bluetooth,wlan,lan,..) that ipconfig /all returns. times 4 and you get 48 interfaces. 
the problematic then is call isLoopback(native call) that takes 50-150ms for each call, in general you have to check 10-15 interfaces before you find right one and that sums to quite bit of time...
It could also happen that you have to check all of them and that would take even more time and time performance of the function is deterministic :(


                
> Hornetq adds up to 4s to boot of as7 full configuration.
> --------------------------------------------------------
>
>                 Key: AS7-3789
>                 URL: https://issues.jboss.org/browse/AS7-3789
>             Project: Application Server 7
>          Issue Type: Enhancement
>          Components: Server
>    Affects Versions: 7.1.0.CR1, 7.1.0.CR1b, 7.1.0.Final
>         Environment: Windows 7, 64bit
>            Reporter: Tomaz Cerar
>            Assignee: Jason Greene
>            Priority: Critical
>              Labels: bootstrap, hornetQ
>         Attachments: hornetq-hotspot.jpg
>
>
> when starting as7 with full configuration 
> standalone.bat -c standalone-full.xml
> boot time can be up to 8 seconds or more depending on system configuration.
> Problematic part of code in hornetq was identified to be inside UUIDGenerator where it tries to obtain hardware address (mac) that it then uses for generating uuid.
> When i was trying to fix this problem I found out that only proper solution would be to replace org.hornetq.tools.UUID for java.util.UUID as code for UUID generation inside hornetq is quite old and is actually an old version of "Java UUID Generator" project http://wiki.fasterxml.com/JugHome as it quite old version it did not use java.util.UUID for generating uuids but it's own algorithm.
> The only potential concern I see is that hornetq uses UUID type 1(time + mac) but java.util.UUID uses type 4 (random).
> Java's implementation of type 4 UUID uses  SecureRandom for generating uuids which uses hardware signature(not just mac) for random.
> So it would be safe to replace org.hornetq.tools.UUID with java's but this is quite a modification in hornetq code that I rather not provide my patch for it :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list