[kepler-dev] URLs in MoMLParser

Christopher Brooks cxh at eecs.berkeley.edu
Sat May 14 11:00:36 PDT 2011


Findbugs reports potential performance problems with the URLs in MoMLParser:

 > Dm: The equals and hashCode methods of URL are blocking (DMI_BLOCKING_METHODS_ON_URL)
 >
 > The equals and hashCode method of URL perform domain name resolution,
 > this can result in a big performance hit. See
 > http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html
 > for more information. Consider using java.net.URI instead.
 > Dm: Maps and sets of URLs can be performance hogs (DMI_COLLECTION_OF_URLS)
 >
 > This method or field is or uses a Map or Set of URLs. Since both the equals and
 > hashCode method of URL perform domain name resolution, this can result in a big
 > performance hit. See http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html
 > for more information. Consider using java.net.URI instead.

To see the FindBugs output for the ptII repository, see
http://chess.eecs.berkeley.edu/ptexternal/nightly/findbugs.htm

I checked the access logs on the Ptolemy web server and it looks
like the nightly build is only accessing the dtd once, which is during the
running of a test.  I'll see if I can track down which test.
The rest of the accesses from the nightly build are for tests that
specifically access a model on the Ptolemy web server.

I also experimented using dtruss on the Mac and tried creating URLs and
using equals() on them.  It looked like Java was only attempting to resolve
addresses when the URL included a network protocol such as http:.
When I created and compared file: URLs, then I did not see any kernel
calls to resolve names.

I also ran the tests in ptolemy/moml and ptolemy/actor/lib while sniffing my
network connection using Wireshark and saw no outgoing traffic.

So, I think the FindBugs URL warnings for MoMLParser may be safely ignored.
If we were going to rewrite MoMLParser, it would better to use URIs instead
of URLs.

_Christopher

-- 
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841      	                      (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670


More information about the Kepler-dev mailing list