[pypy-dev] [Fwd: Re: Fan Programing Language]

Antonio Cuni anto.cuni at gmail.com
Tue Apr 22 22:56:55 CEST 2008


Hi Niko,
hi all,

there is an interesting thread going on on the jvm-languages mailing 
list; among the other things, I discovered that the JVM can handle the 
exception much faster if you override the fillInStack method to do 
nothing instead of building the traceback.

I think that since we don't rely on jvm tracebacks for exceptions, 
overriding such a method in all our exception classes might lead to some 
speedup.

Note that hotspot is smart enough to optimize well the case in which you 
raise a prebuilt exception, but in all cases in which you have to 
dynamically construct a new exception (e.g., OperationError) it can't.

ciao,
Anto

-------- Original Message --------
Subject: [jvm-l] Re: Fan Programing Language
Date: Tue, 22 Apr 2008 15:05:04 -0400
From: John Cowan <johnwcowan at gmail.com>
Reply-To: jvm-languages at googlegroups.com
To: jvm-languages at googlegroups.com
References: 
<bfb6e3b0-8e81-4e38-95ea-2ce1187558fc at u69g2000hse.googlegroups.com> 
<200804221911.40276.jon at ffconsultancy.com> <480E31B8.5090504 at gmail.com> 
<200804221941.11608.jon at ffconsultancy.com>


On Tue, Apr 22, 2008 at 2:41 PM, Jon Harrop <jon at ffconsultancy.com> wrote:

>  > 2) you are allocating a new exception every time; the optimization
>  > described here [1] works only if the exception is pre-allocated.
>  > [1] http://blogs.sun.com/jrose/entry/longjumps_considered_inexpensive
>
>  I think that is not thread safe. Specifically, when the branch conveys
>  information (passed as arguments using a tail call, or embedded in the
>  exception) then you must use a locally allocated exception, right?

Yes, you must.   However, what makes allocating an exception expensive
is the fillInStack method, which has to walk the JVM stack.  If you
override that in your exception class with a do-nothing method, then
locally allocating exceptions is very cheap.

-- 
GMail doesn't have rotating .sigs, but you can see mine at
http://www.ccil.org/~cowan/signatures

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google 
Groups "JVM Languages" group.
To post to this group, send email to jvm-languages at googlegroups.com
To unsubscribe from this group, send email to 
jvm-languages-unsubscribe at googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---





More information about the Pypy-dev mailing list