<html>
    <head>
      <base href="http://icedtea.classpath.org/bugzilla/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Improve HarvesterHelper.collectAndSaveThreadData()"
   href="http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=2040">2040</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Improve HarvesterHelper.collectAndSaveThreadData()
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Thermostat
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>hg
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86_64
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P5
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Thermostat
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassigned@icedtea.classpath.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sgehwolf@redhat.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>thermostat@icedtea.classpath.org
          </td>
        </tr>

        <tr>
          <th>Blocks</th>
          <td>2038
          </td>
        </tr></table>
      <p>
        <div>
        <pre>HarvesterHelper.collectAndSaveThreadData() calls the following in a loop (n ==
number of threads of a JVM):
 - ThreadHeaderHelper.checkAndSaveThreadHeader(): performs 1 query + 1 add
 - ThreadStateHelper.saveThreadState(): performs 1 query + 1 add or update
 - ThreadContentionHelper.saveContentionSample(): performs 1 add.

Thus, 2 + 2 + 1 = O(5n) DB ops (reads and/or writes). This way the # of queries
depend on the # of threads.

A few avenues worth exploring are:
 1.) Remove query part. Agent doing querying is bad practice.
 2.) If 1 is not possible refactor the query to fetch all thread headers for
all
     threads in one query. This might need projection support.
 3.) Consider implementing API for bulk writes. It's worth saving a network
round-trip. I.e. send a list (cardinality n) of thread headers/contention
samples to get inserted.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>