public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcj/11780] New: Method.invoke() is very slow and leaks memory
@ 2003-08-03  6:39 bryce at mckinlay dot net dot nz
  2003-08-03 14:00 ` [Bug libgcj/11780] " pinskia at physics dot uc dot edu
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: bryce at mckinlay dot net dot nz @ 2003-08-03  6:39 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11780

           Summary: Method.invoke() is very slow and leaks memory
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bryce at mckinlay dot net dot nz
                CC: gcc-bugs at gcc dot gnu dot org

Good performance from Method.invoke() is very important for many reflective applications.

In previous versions of libgcj security checks were not perfomed, and our performance was only a 
little worse than the JRE. A recent patch added security checks and now:

- Method.invoke is now ~10 x slower than the JRE
- Method.invoke leaks memory every time it is called

Clearly there are some simple optimizations that can be made - security check is not needed if 
method is public or accessibility flag is true. Ideally however the security check implementation 
itself should be made much faster.

Test case w/ timers follows.


import java.lang.reflect.*;

public class RefTest2
{
  static int i = 0;
  public int increment(int value)
  {
    return ++i;
  }

  public static void main(String[] args) 
    throws Exception
  {
    Method method = RefTest2.class.getMethod ("increment", 
      new Class [] { int.class });
    Object[] arg = new Object[1];
    Object value = new Integer(0);
  
    RefTest2 testObj = new RefTest2();

    while (true)
    {
      long startTime = System.currentTimeMillis();
      for (int i = 0; i < 1000000; i++)
      {
	arg[0] = value;
	value = method.invoke(testObj, arg);
      }
      System.out.println (System.currentTimeMillis() - startTime + " ms");
    }
  }
}


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/11780] Method.invoke() is very slow and leaks memory
  2003-08-03  6:39 [Bug libgcj/11780] New: Method.invoke() is very slow and leaks memory bryce at mckinlay dot net dot nz
@ 2003-08-03 14:00 ` pinskia at physics dot uc dot edu
  2003-08-03 21:12 ` bryce at mckinlay dot net dot nz
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-03 14:00 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11780


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-03 14:00:28
               date|                            |


------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-03 14:00 -------
I can confirm the slowness on the mainline (20030802) on powerpc-apple-darwin6.6 but 
I do not see any leaks.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/11780] Method.invoke() is very slow and leaks memory
  2003-08-03  6:39 [Bug libgcj/11780] New: Method.invoke() is very slow and leaks memory bryce at mckinlay dot net dot nz
  2003-08-03 14:00 ` [Bug libgcj/11780] " pinskia at physics dot uc dot edu
@ 2003-08-03 21:12 ` bryce at mckinlay dot net dot nz
  2003-08-03 21:16 ` pinskia at physics dot uc dot edu
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bryce at mckinlay dot net dot nz @ 2003-08-03 21:12 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11780



------- Additional Comments From bryce at mckinlay dot net dot nz  2003-08-03 21:12 -------
Interesting - the test case consumes all available memory on my 512MB RHL 9 x86 after around 
20M calls. Perhaps the leak is in system-dependent unwinder code.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/11780] Method.invoke() is very slow and leaks memory
  2003-08-03  6:39 [Bug libgcj/11780] New: Method.invoke() is very slow and leaks memory bryce at mckinlay dot net dot nz
  2003-08-03 14:00 ` [Bug libgcj/11780] " pinskia at physics dot uc dot edu
  2003-08-03 21:12 ` bryce at mckinlay dot net dot nz
@ 2003-08-03 21:16 ` pinskia at physics dot uc dot edu
  2003-08-23  1:08 ` dhazeghi at yahoo dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-03 21:16 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11780



------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-03 21:16 -------
I see the memory leak on i686-pc-linuc-gnu also.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/11780] Method.invoke() is very slow and leaks memory
  2003-08-03  6:39 [Bug libgcj/11780] New: Method.invoke() is very slow and leaks memory bryce at mckinlay dot net dot nz
                   ` (2 preceding siblings ...)
  2003-08-03 21:16 ` pinskia at physics dot uc dot edu
@ 2003-08-23  1:08 ` dhazeghi at yahoo dot com
  2003-10-25  9:39 ` cvs-commit at gcc dot gnu dot org
  2004-01-01  1:24 ` [Bug libgcj/11780] Method.invoke() is very slow pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23  1:08 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11780


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |---


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/11780] Method.invoke() is very slow and leaks memory
  2003-08-03  6:39 [Bug libgcj/11780] New: Method.invoke() is very slow and leaks memory bryce at mckinlay dot net dot nz
                   ` (3 preceding siblings ...)
  2003-08-23  1:08 ` dhazeghi at yahoo dot com
@ 2003-10-25  9:39 ` cvs-commit at gcc dot gnu dot org
  2004-01-01  1:24 ` [Bug libgcj/11780] Method.invoke() is very slow pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-10-25  9:39 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11780



------- Additional Comments From cvs-commit at gcc dot gnu dot org  2003-10-25 06:49 -------
Subject: Bug 11780

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bryce@gcc.gnu.org	2003-10-25 06:49:20

Modified files:
	libjava        : ChangeLog 
	libjava/java/lang/reflect: natMethod.cc natField.cc 

Log message:
	PR libgcj/11780:
	* java/lang/reflect/natMethod.cc (invoke): Look up caller and
	perform accessibility check only if target is non-public and
	accessible flag is not set.
	* java/lang/reflect/natField.cc (getAddr): Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.2295&r2=1.2296
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/lang/reflect/natMethod.cc.diff?cvsroot=gcc&r1=1.33&r2=1.34
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/lang/reflect/natField.cc.diff?cvsroot=gcc&r1=1.14&r2=1.15


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgcj/11780] Method.invoke() is very slow
  2003-08-03  6:39 [Bug libgcj/11780] New: Method.invoke() is very slow and leaks memory bryce at mckinlay dot net dot nz
                   ` (4 preceding siblings ...)
  2003-10-25  9:39 ` cvs-commit at gcc dot gnu dot org
@ 2004-01-01  1:24 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-01  1:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-01 01:24 -------
It still is slow:
tin:~/src/gnu/gcctest>gij RefTest2
1574 ms
1596 ms
tin:~/src/gnu/gcctest>java RefTest2
335 ms
271 ms

But this no longer leaks so update summary.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2003-08-03 14:00:28         |2004-01-01 01:24:31
               date|                            |
            Summary|Method.invoke() is very slow|Method.invoke() is very slow
                   |and leaks memory            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11780


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-01-01  1:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-03  6:39 [Bug libgcj/11780] New: Method.invoke() is very slow and leaks memory bryce at mckinlay dot net dot nz
2003-08-03 14:00 ` [Bug libgcj/11780] " pinskia at physics dot uc dot edu
2003-08-03 21:12 ` bryce at mckinlay dot net dot nz
2003-08-03 21:16 ` pinskia at physics dot uc dot edu
2003-08-23  1:08 ` dhazeghi at yahoo dot com
2003-10-25  9:39 ` cvs-commit at gcc dot gnu dot org
2004-01-01  1:24 ` [Bug libgcj/11780] Method.invoke() is very slow pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).