From commits-return-24289-apmail-harmony-commits-archive=harmony.apache.org@harmony.apache.org Tue Jan 02 01:52:53 2007 Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 69836 invoked from network); 2 Jan 2007 01:52:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jan 2007 01:52:53 -0000 Received: (qmail 94334 invoked by uid 500); 2 Jan 2007 01:52:58 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 94238 invoked by uid 500); 2 Jan 2007 01:52:58 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 94228 invoked by uid 99); 2 Jan 2007 01:52:58 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 17:52:58 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 17:52:50 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 3A4961A981A; Mon, 1 Jan 2007 17:51:55 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r491735 - in /harmony/enhanced/tools/trunk/finalizer_probe: ./ Finx.java README.txt Date: Tue, 02 Jan 2007 01:51:55 -0000 To: commits@harmony.apache.org From: wjwashburn@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070102015155.3A4961A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: wjwashburn Date: Mon Jan 1 17:51:54 2007 New Revision: 491735 URL: http://svn.apache.org/viewvc?view=rev&rev=491735 Log: Harmony-2908 This is a simple probe for investigating how a given JVM handles finalizer() methods Added: harmony/enhanced/tools/trunk/finalizer_probe/ harmony/enhanced/tools/trunk/finalizer_probe/Finx.java harmony/enhanced/tools/trunk/finalizer_probe/README.txt Added: harmony/enhanced/tools/trunk/finalizer_probe/Finx.java URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/finalizer_probe/Finx.java?view=auto&rev=491735 ============================================================================== --- harmony/enhanced/tools/trunk/finalizer_probe/Finx.java (added) +++ harmony/enhanced/tools/trunk/finalizer_probe/Finx.java Mon Jan 1 17:51:54 2007 @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.*; + +class Finx { + static Finx ft; + static int finalCount = 0; + static int cmd = 0; + + public static void main(String args[]) + { + //cmd = 0 no finalizable object created, main() does cpu intensive task forever + + //cmd = 1 a bunch of object needing finalization are shoved onto finalize queue + // also, each finalizer runs only a short time + + //cmd = 2 same as cmd==1 except each finalizer runs cpu intensive task forever + + // you can process viewer to see what the JVM is doing w/ threads for cmd = 0, 1 and 2 + + if (args.length != 1) { + System.out.println("you need to supply one input arg, read the source to figure out what the arg does"); + return; + } + cmd = Integer.valueOf(args[0]); + + if (cmd > 0) // cause a bunch of objects to need finalization + { + // create 100K objects that will need finalization + for (int kk = 0; kk < 100 * 1000; kk++) + ft = new Finx(); + + //push a bunch (maybe not all) of the above objects onto the finalization queue + Object[] oa1 = new Object[1024]; + for (int xx = 0; xx < 1024; xx++) { + Object[] oa2 = new Object[1024]; + oa1[1] = oa2; + oa1 = oa2; + } + } + // this endless loop should keep the cpu 100% busy in user-level code + int kk = 0; + while(true) { + int ss = cpuIntensiveWorkload(); + System.out.println("##########################################main(), loop count = " + kk++); + } + } + + static int cpuIntensiveWorkload() + { + int yy, zz = 23; + for (int xx = 0; xx < 1000000; xx++) { + yy = xx * 117; + zz = yy + xx; + } + return zz; + } + + protected void finalize() + { + finalCount++; + int kk = 0; + while (true) { + int qq = cpuIntensiveWorkload(); + System.out.println("finalize()called for object number " + finalCount + " loop count = " + kk++); + if (cmd == 1) break; // cmd == 1 causes a short running finalizer + } + } +} + + + \ No newline at end of file Added: harmony/enhanced/tools/trunk/finalizer_probe/README.txt URL: http://svn.apache.org/viewvc/harmony/enhanced/tools/trunk/finalizer_probe/README.txt?view=auto&rev=491735 ============================================================================== --- harmony/enhanced/tools/trunk/finalizer_probe/README.txt (added) +++ harmony/enhanced/tools/trunk/finalizer_probe/README.txt Mon Jan 1 17:51:54 2007 @@ -0,0 +1,43 @@ + + +This is a very simple finalizer probe called Finx.java. Its intended use is for discovering the +behavior of finalizer threads of various JVM implementations. + +This probe is single threaded and has three different execution modes: "java Finx 0", +"java Finx 1" and "java Finx 2". By running each of the modes on WindowsXP and using +Microsoft's Process Viewer, one can learn what the different JVM threads are doing. + +Mode 0 +This mode intentionally does not create any finalizable objects. +The main() method simply runs a cpu intensive workload forever. +After every 1000000 loops main() will print a distinctive string that includes a loop count. +Use Mode 0 to establish a baseline for a give JVM. Let Mode 0 run for a few minutes, then use +Microsoft Process Viewer to learn things like how many OS threads the JVM is running, what +are each thread's priority level, what percent time is spent in user vs. supervisor mode. Also +it should be easy to determine which thread is running main() since main() will grab most +of the CPU time. + +Mode 1 +main() creates 100K finalizable objects that are intentionally shoved into a state where their +finalizer needs to be called. main() then proceeds to run the same cpu intensive workload as above. +The finalize() method will execute just one call of the same cpu intensive workload then returns. +This simulates a short running finalizer. finalize() prints a distinctive string to make it easy to +quickly read the output which is comingled with main(). Use Mode 1 to learn things like which thread(s) are +running the finalizers and how much CPU time is spent on finalizers vs. main(). The rate of progress +of finalizers vs. main() is easy to estimate. After each 1M CPU intensive loops, both main() and finalize() will +print a rolling count. Simply count the number of main() print outs vs. the number of finalize() print outs. + +Mode 2 +This mode is identical to Mode 1 except the finalize() method calls the cpu intensive workload endlessly. +Use this mode to determine JVM behavior when there are 100K finalizable objects and each object's finalization +takes forever. Investigate if a JVM will force a long running finalizer to abort. Does the JVM boost the +priority of the long running finalizer? Lower the priority? Add more finalization threads? + +SMP +All the above modes can be run on UP, 2-way, 4-way, etc machines to determine how a specific JVM handles +finalizer threads. Use this probe to answer questions like how many finalizer threads does a +JVM have on 2-way vs 4-way vs 8-way? + +OS +This probe was built on windowsXP. Its untested on Linux but it should simply work. Most likely +Linux will exhibit slightly different OS thread scheduling behavior than Windows.