JDK-4205305 : (1.1) Performance problem due to GC heap compaction fix (4065018)
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.1.8
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 1999-01-23
  • Updated: 1999-07-20
  • Resolved: 1999-07-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.1.8 1.1.8Fixed
Related Reports
Relates :  
Description
When allocating a large Java object using the Invocation API, gc kicks in a lot more frequently than before the fix for 4065018 was integrated in 1.1.8 (build F).  This can have a severe impact on performance.  For example, tests so far have revealed that instantiating a number of large Java objects can take over 200 times as long as with using build E.  This performance degradation has only been observed when using the Invocation API (i.e. not when using the java command).

Here's a test case:

public class BigObject {

    public BigObject() {
        System.out.println("Hello from BigObject.<init>");
        StringBuffer[] s = new StringBuffer[1000];
        for (int i = 0; i < s.length; i++)
            s[i] = new StringBuffer(1024);
        Runtime rt = Runtime.getRuntime(); 
        System.out.println("Free mem = " + rt.freeMemory());
        System.out.println("Tot mem  = " + rt.totalMemory());
    }

    public static void main(String args[]) {
        new BigObject(); 
    }

}

/* CreateBigObject.c   Stuart Lawrence
   Creates JVM and instantiates a large Java object.
 */

#include <jni.h>

int main() {
    JNIEnv *env;
    JavaVM *jvm;
    JDK1_1InitArgs vm_args;
    jint res;
    jclass cls;
    jmethodID cid;
    char classpath[1024];
    jobject ajobj;

    vm_args.version = 0x00010001;
    JNI_GetDefaultJavaVMInitArgs(&vm_args);

    /* Assume BigObject.class is located in . */
    sprintf(classpath, "%s%s", vm_args.classpath, ":.");
    vm_args.classpath = classpath;

    /* Enable GC messages */
    vm_args.enableVerboseGC = 1;

    /* Create the Java VM */
    res = JNI_CreateJavaVM(&jvm,&env,&vm_args);
    if (res < 0) {
        fprintf(stderr, "Can't create Java VM\n");
        return 1;
    }
    cls = (*env)->FindClass(env, "BigObject");
    if (cls == 0) {
        fprintf(stderr, "Can't find BigObject class\n");
        return 1;
    }
    cid = (*env)->GetMethodID(env, cls, "<init>", "()V");
    if (cid == 0) {
        fprintf(stderr, "Can't find BigObject.<init>\n");
        return 1;
    }

    ajobj = (*env)->NewObject(env, cls, cid);
    if (NULL == ajobj)
    {
        fprintf(stdout, "Failed to create object.");
    }

    /* release the object */
    (*env)->DeleteLocalRef(env, ajobj);

    fprintf(stdout, "Finished\n");

    (*jvm)->DestroyJavaVM(jvm);
    return 0;

}

and here's the script I used to run the test:

echo Start `date`
export LD_LIBRARY_PATH=/export/ws/118F/build/lib/sparc/green_threads
cc -I/export/ws/118F/build/include    -I/export/ws/118F/src/solaris/java/include    -L/export/ws/118F/build/lib/sparc/green_threads    -ljava CreateBigObject.c
a.out
echo End   `date`

Compare the number of gc messages with 118E.

stuart.lawrence@eng 1999-01-22

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.1.8 FIXED IN: 1.1.8 INTEGRATED IN: 1.1.8 VERIFIED IN: 1.1.8
14-06-2004

SUGGESTED FIX This suggested fix has been code reviewed by Sheng Liang. sccs diffs -bitwc /home/carolyn/bld/515224/JDK118/src/share/java/util/globals.c ------- globals.c ------- *** /tmp/d0JbeG6 Mon Jan 25 11:14:07 1999 --- /home/carolyn/bld/515224/JDK118/src/share/java/util/globals.c Mon Jan 25 09:59:42 1999 *************** *** 1,5 **** /* ! * %W% %E% * * Copyright 1995-1998 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. --- 1,5 ---- /* ! * @(#)globals.c 1.27 99/01/11 * * Copyright 1995-1998 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. *************** *** 33,39 **** bool_t classgc; int verifyclasses; bool_t debugging; ! heapoptions heapopts; typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args); --- 33,42 ---- bool_t classgc; int verifyclasses; bool_t debugging; ! heapoptions heapopts = {MINHEAPFREEPERCENT, ! MAXHEAPFREEPERCENT, ! MINHEAPEXPANSION, ! MAXHEAPEXPANSION}; typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args); carolyn.lowenthal@Eng 1999-01-25
25-01-1999

EVALUATION cannot verify the bug, no regression test case provided. tao.zhang@eng 1999-03-01 Globals used by heap compaction must be initialized with default values in case the Invocation API is used. carolyn.lowenthal@Eng 1999-01-25 ----------------------------------------------------------------------- This bug was verified as fixed via manual testing using jdk118l. al.smith@eng 1999-03-30
25-01-1999