Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7903746

jtreg tests run extremely slow on some environments due to hostname lookups

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • jtreg7.5
    • None
    • tools
    • None

    Description

      It has been reported that in certain environments, jtreg when launching a test there's a long delay before running the test code. This appears to be happening for every single test that gets launched in that test run.

      Thread dumps have shown the following relevant part:

      "DefaultTestRunner:Worker-0:0" #35 [34819] prio=4 os_prio=31 cpu=7.51ms elapsed=4.30s tid=0x000000012e99aa00 nid=34819 runnable [0x0000000171b26000]
         java.lang.Thread.State: RUNNABLE
      at java.net.Inet6AddressImpl.getHostByAddr(java.base@23-internal/Native Method)
      at java.net.InetAddress$PlatformResolver.lookupByAddress(java.base@23-internal/InetAddress.java:1235)
      at java.net.InetAddress.getHostFromNameService(java.base@23-internal/InetAddress.java:850)
      at java.net.InetAddress.getCanonicalHostName(java.base@23-internal/InetAddress.java:820)
      at com.sun.javatest.regtest.exec.RegressionScript.run(RegressionScript.java:133)
      at com.sun.javatest.Script.run(Script.java:431)
      at com.sun.javatest.DefaultTestRunner.runTest(DefaultTestRunner.java:183)
      at com.sun.javatest.DefaultTestRunner$1.run(DefaultTestRunner.java:76)

      It appears that for every test, the jtreg framework code tries to determine the hostname and that can lead to a name resolution which on some setups, like the one where this was causing an issue, can take a long time. The code in question resides at https://github.com/openjdk/jtreg/blob/master/src/share/classes/com/sun/javatest/regtest/exec/RegressionScript.java#L132 where we do:

      String hostname;
      try {
         hostname = InetAddress.getLocalHost().getCanonicalHostName();
      } catch (UnknownHostException e) {
         hostname = "127.0.0.1";
      }
      testResult.putProperty("hostname", hostname);

      I'm not too familiar with the jtreg code, but the only place where I have seen this hostname is in the .jtr file that gets generated for the tests:

      #-----testresult-----
      description=file\:/jdk/open/test/jdk/java/lang/FooBarTest.java
      elapsed=835 0\:00\:00.835
      end=Fri Jun 07 20\:31\:30 IST 2024
      environment=regtest
      execStatus=Passed. Execution successful
      harnessLoaderMode=Classpath Loader
      harnessVariety=Full Bundle
      hostname=foo-bar.example.com
      javatestOS=Mac OS X 14.5 (aarch64)

      Irrespective of where this gets used, I think one optimization that we can do in jtreg is to compute this hostname once for the entire jtreg launch instead of doing it every test that gets executed as part of that run. That should at least reduce the long delays that accumulate for each test execution.

      Attachments

        Issue Links

          Activity

            People

              jpai Jaikiran Pai
              jpai Jaikiran Pai
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: