public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* FW: Garbage collection issues in GCJ
@ 2011-01-17 13:09 Ben Keppler
  2011-01-17 17:32 ` David Daney
  0 siblings, 1 reply; 8+ messages in thread
From: Ben Keppler @ 2011-01-17 13:09 UTC (permalink / raw)
  To: java

We are using gcj for a time sensitive application.  One of the requirements of the application is that messages be transmitted within a 60ms timeframe.  Unfortunately, the Boehm GC used in gcj is not generational and thus every collection is of the "stop the world" variety.  We are observing (using "GC_PRINT_STATS") regular collections that stop the world for periods in the 400ms range.  This is a problem for us.

The comments I have found on the "incremental" setting for the Boehm GC indicate that it doesn't work with gcj, so that would not appear to be an option.  My question is, are there other GC options (perhaps a generational garbage collector) available for gcj?  My research has revealed none other than TinyGC, an option that would exacerbate rather than relieve our problems.  Alternatively, are there settings on the Boehm GC that might relieve our problems?  I would appreciate any information you could provide.


Ben Keppler, Software Engineer
Trident Micro Systems
E-mail: bkeppler@tridentms.com
Voice: 828.684.7474 xt. 2002
Fax: 828.684.7874


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

* Re: FW: Garbage collection issues in GCJ
  2011-01-17 13:09 FW: Garbage collection issues in GCJ Ben Keppler
@ 2011-01-17 17:32 ` David Daney
  2011-01-17 18:57   ` Ben Keppler
  0 siblings, 1 reply; 8+ messages in thread
From: David Daney @ 2011-01-17 17:32 UTC (permalink / raw)
  To: Ben Keppler; +Cc: java

On 01/17/2011 05:08 AM, Ben Keppler wrote:

> We are using gcj for a time sensitive application.  One of the
> requirements of the application is that messages be transmitted
> within a 60ms timeframe.  Unfortunately, the Boehm GC used in gcj is
> not generational and thus every collection is of the "stop the
> world" variety.  We are observing (using "GC_PRINT_STATS") regular
> collections that stop the world for periods in the 400ms range.
> This is a problem for us.
>
> The comments I have found on the "incremental" setting for the
> Boehm GC indicate that it doesn't work with gcj, so that would not
> appear to be an option.  My question is, are there other GC options
> (perhaps a generational garbage collector) available for gcj?  My
> research has revealed none other than TinyGC, an option that would
> exacerbate rather than relieve our problems.  Alternatively, are
> there settings on the Boehm GC that might relieve our problems?  I
> would appreciate any information you could provide.

1) GCJ's libjava is not really suited for realtime applications.

2) Setting the GCFreeSpaceDivisor (by calling
_Jv_SetGCFreeSpaceDivisor()) to a low value (try 5) may result in
shorter, but more frequent, GC intervals.  Limiting the total heap
size will also reduce the amount of work done by the GC during each
collection.

David Daney

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

* RE: FW: Garbage collection issues in GCJ
  2011-01-17 17:32 ` David Daney
@ 2011-01-17 18:57   ` Ben Keppler
  2011-01-22 21:53     ` Florian Weimer
  0 siblings, 1 reply; 8+ messages in thread
From: Ben Keppler @ 2011-01-17 18:57 UTC (permalink / raw)
  To: David Daney; +Cc: java

Hi David,

Thanks for your response.  We have been unable to find documentation
detailing how to change the GC configuration including knobs for setting
the max heap size.  Could you direct us to documentation on how to do
that?  Also, are there alternatives to making a native call to
_Jv_SetGCFreeSpaceDivisor() (e.g. set an environment variable or compile
with a symbol defined in the appropriate way)?  It would be preferable
if we didn't have to implement a tight coupling to GCJ in that fashion.

Thanks for your help.

Ben Keppler, Software Engineer
E-mail: bkeppler@tridentms.com * Voice: 828.684.7474 * Fax:
8282.684.7874

-----Original Message-----
From: David Daney [mailto:ddaney@caviumnetworks.com] 
Sent: Monday, January 17, 2011 12:32 PM
To: Ben Keppler
Cc: java@gcc.gnu.org
Subject: Re: FW: Garbage collection issues in GCJ

On 01/17/2011 05:08 AM, Ben Keppler wrote:

> We are using gcj for a time sensitive application.  One of the
> requirements of the application is that messages be transmitted
> within a 60ms timeframe.  Unfortunately, the Boehm GC used in gcj is
> not generational and thus every collection is of the "stop the
> world" variety.  We are observing (using "GC_PRINT_STATS") regular
> collections that stop the world for periods in the 400ms range.
> This is a problem for us.
>
> The comments I have found on the "incremental" setting for the
> Boehm GC indicate that it doesn't work with gcj, so that would not
> appear to be an option.  My question is, are there other GC options
> (perhaps a generational garbage collector) available for gcj?  My
> research has revealed none other than TinyGC, an option that would
> exacerbate rather than relieve our problems.  Alternatively, are
> there settings on the Boehm GC that might relieve our problems?  I
> would appreciate any information you could provide.

1) GCJ's libjava is not really suited for realtime applications.

2) Setting the GCFreeSpaceDivisor (by calling
_Jv_SetGCFreeSpaceDivisor()) to a low value (try 5) may result in
shorter, but more frequent, GC intervals.  Limiting the total heap
size will also reduce the amount of work done by the GC during each
collection.

David Daney

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

* Re: FW: Garbage collection issues in GCJ
  2011-01-17 18:57   ` Ben Keppler
@ 2011-01-22 21:53     ` Florian Weimer
  2011-01-23 19:12       ` Boehm, Hans
  2011-01-24 17:45       ` David Daney
  0 siblings, 2 replies; 8+ messages in thread
From: Florian Weimer @ 2011-01-22 21:53 UTC (permalink / raw)
  To: Ben Keppler; +Cc: David Daney, java

* Ben Keppler:

> Thanks for your response.  We have been unable to find documentation
> detailing how to change the GC configuration including knobs for setting
> the max heap size.

GCJ allocates as much memory as your application needs.  I think what
David meant was that you should change your application to put less
data into the Java heap (either by using the C heap, or by splitting
it into multiple processes).

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

* RE: FW: Garbage collection issues in GCJ
  2011-01-22 21:53     ` Florian Weimer
@ 2011-01-23 19:12       ` Boehm, Hans
  2011-01-24 17:45       ` David Daney
  1 sibling, 0 replies; 8+ messages in thread
From: Boehm, Hans @ 2011-01-23 19:12 UTC (permalink / raw)
  To: Florian Weimer, Ben Keppler; +Cc: David Daney, java

> From: Florian Weimer
> 
> * Ben Keppler:
> 
> > Thanks for your response.  We have been unable to find documentation
> > detailing how to change the GC configuration including knobs for
> setting
> > the max heap size.
> 
> GCJ allocates as much memory as your application needs.  I think what
> David meant was that you should change your application to put less
> data into the Java heap (either by using the C heap, or by splitting
> it into multiple processes).

But some knobs are normally available via environment variables.
See

http://gcc.gnu.org/viewcvs/trunk/boehm-gc/doc/README.environment?revision=138078&view=markup

You can impose a maximum heap size if you insist.

Hans

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

* Re: FW: Garbage collection issues in GCJ
  2011-01-22 21:53     ` Florian Weimer
  2011-01-23 19:12       ` Boehm, Hans
@ 2011-01-24 17:45       ` David Daney
  2011-01-24 17:59         ` Ben Keppler
  1 sibling, 1 reply; 8+ messages in thread
From: David Daney @ 2011-01-24 17:45 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Ben Keppler, java

On 01/22/2011 01:53 PM, Florian Weimer wrote:
> * Ben Keppler:
>
>> Thanks for your response.  We have been unable to find documentation
>> detailing how to change the GC configuration including knobs for setting
>> the max heap size.
>
> GCJ allocates as much memory as your application needs.  I think what
> David meant was that you should change your application to put less
> data into the Java heap (either by using the C heap, or by splitting
> it into multiple processes).
>

No, that is not what I meant at all.

At some point in any non-trivial program's execution, there will be a 
memory allocation request that cannot be met from the existing pools of 
free memory.  At this point the runtime memory allocator must make a 
decision.  Should it run a garbage collection cycle to try to free up 
some existing memory, or should it get more memory from the operating 
system.

My suggestion was to adjust the policy parameters such that it chooses 
the garbage collection option more often.  This results in a smaller 
total memory footprint, and thus faster garbage collection cycles.  The 
trade off is that you end up doing more garbage collection and less real 
work.  This may be acceptable though, if latency is important.

David Daney

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

* RE: FW: Garbage collection issues in GCJ
  2011-01-24 17:45       ` David Daney
@ 2011-01-24 17:59         ` Ben Keppler
  2011-01-24 18:45           ` Hans Boehm
  0 siblings, 1 reply; 8+ messages in thread
From: Ben Keppler @ 2011-01-24 17:59 UTC (permalink / raw)
  To: David Daney, Florian Weimer; +Cc: java

Hi David,

I understood your meaning to be what you reiterated in response to
Florian.  In fact, in our testing with the Sun JVM, we obtained the
performance characteristics we wanted by turning on the incremental GC
and limiting the size of the eden space so that garbage collections take
as little time as possible.  Because we are on a single-core system
without hyperthreading, even non-world-stopping garbage collections must
be limited in duration.

As far as I can tell, the only possible option with GCJ and the Boehm GC
is limiting the total size of the heap to reduce the pause.  However, I
don't think even that is going to be adequate.  If GCJ were up on the
latest version of Boehm GC and the incremental mode worked, that might
solve our problem.  At this point I think we may be forced into using
the JVM.

Ben Keppler, Software Engineer
Trident Micro Systems
E-mail: bkeppler@tridentms.com * Voice: 828.684.7474 * Fax:
8282.684.7874

-----Original Message-----
From: David Daney [mailto:ddaney@caviumnetworks.com] 
Sent: Monday, January 24, 2011 12:45 PM
To: Florian Weimer
Cc: Ben Keppler; java@gcc.gnu.org
Subject: Re: FW: Garbage collection issues in GCJ

On 01/22/2011 01:53 PM, Florian Weimer wrote:
> * Ben Keppler:
>
>> Thanks for your response.  We have been unable to find documentation
>> detailing how to change the GC configuration including knobs for
setting
>> the max heap size.
>
> GCJ allocates as much memory as your application needs.  I think what
> David meant was that you should change your application to put less
> data into the Java heap (either by using the C heap, or by splitting
> it into multiple processes).
>

No, that is not what I meant at all.

At some point in any non-trivial program's execution, there will be a 
memory allocation request that cannot be met from the existing pools of 
free memory.  At this point the runtime memory allocator must make a 
decision.  Should it run a garbage collection cycle to try to free up 
some existing memory, or should it get more memory from the operating 
system.

My suggestion was to adjust the policy parameters such that it chooses 
the garbage collection option more often.  This results in a smaller 
total memory footprint, and thus faster garbage collection cycles.  The 
trade off is that you end up doing more garbage collection and less real

work.  This may be acceptable though, if latency is important.

David Daney

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

* RE: FW: Garbage collection issues in GCJ
  2011-01-24 17:59         ` Ben Keppler
@ 2011-01-24 18:45           ` Hans Boehm
  0 siblings, 0 replies; 8+ messages in thread
From: Hans Boehm @ 2011-01-24 18:45 UTC (permalink / raw)
  To: Ben Keppler; +Cc: David Daney, Florian Weimer, java

The major mechanism for limiting GC pauses is incremental GC.
I suspect that the GC used in GCJ generally supports that.  But it
requires the client code to follow some rules, and I think that
part was never fully debugged for GCJ.  The main issue here is that
the collector tracks modified pages by catching write faults, but
operating systems like Linux don't make this possible if the fault
occurs inside a system call.  Thus we need to make sure that system
calls don't write to parts of the heap that the GC must track.

Depending on the heap size, it may sometimes be possible to keep
GC pauses acceptable by just making the GC faaster, e.g. by
making more of the heap pointer-free.

GC pauses are often not that sensitive to the overall heap size,
since the sweep phase of the collector always runs incrementally,
and the cost of the mark phase depends mostly on the amount
of live data.  I would be surprised if limiting the heap size
solved the problem.

The collector itself does support abortable collections, i.e. a
mechanism for aborting a collection if the application finds that
it needs to get control back.  But that essentially discards the
work done so far, and I think not too many people have found it
useful.  This does not currently have GCJ support, but that might
be relatively eaasy to add.

Hans

On Mon, 24 Jan 2011, Ben Keppler wrote:

> Hi David,
>
> I understood your meaning to be what you reiterated in response to
> Florian.  In fact, in our testing with the Sun JVM, we obtained the
> performance characteristics we wanted by turning on the incremental GC
> and limiting the size of the eden space so that garbage collections take
> as little time as possible.  Because we are on a single-core system
> without hyperthreading, even non-world-stopping garbage collections must
> be limited in duration.
>
> As far as I can tell, the only possible option with GCJ and the Boehm GC
> is limiting the total size of the heap to reduce the pause.  However, I
> don't think even that is going to be adequate.  If GCJ were up on the
> latest version of Boehm GC and the incremental mode worked, that might
> solve our problem.  At this point I think we may be forced into using
> the JVM.
>
> Ben Keppler, Software Engineer
> Trident Micro Systems
> E-mail: bkeppler@tridentms.com * Voice: 828.684.7474 * Fax:
> 8282.684.7874
>
> -----Original Message-----
> From: David Daney [mailto:ddaney@caviumnetworks.com]
> Sent: Monday, January 24, 2011 12:45 PM
> To: Florian Weimer
> Cc: Ben Keppler; java@gcc.gnu.org
> Subject: Re: FW: Garbage collection issues in GCJ
>
> On 01/22/2011 01:53 PM, Florian Weimer wrote:
>> * Ben Keppler:
>>
>>> Thanks for your response.  We have been unable to find documentation
>>> detailing how to change the GC configuration including knobs for
> setting
>>> the max heap size.
>>
>> GCJ allocates as much memory as your application needs.  I think what
>> David meant was that you should change your application to put less
>> data into the Java heap (either by using the C heap, or by splitting
>> it into multiple processes).
>>
>
> No, that is not what I meant at all.
>
> At some point in any non-trivial program's execution, there will be a
> memory allocation request that cannot be met from the existing pools of
> free memory.  At this point the runtime memory allocator must make a
> decision.  Should it run a garbage collection cycle to try to free up
> some existing memory, or should it get more memory from the operating
> system.
>
> My suggestion was to adjust the policy parameters such that it chooses
> the garbage collection option more often.  This results in a smaller
> total memory footprint, and thus faster garbage collection cycles.  The
> trade off is that you end up doing more garbage collection and less real
>
> work.  This may be acceptable though, if latency is important.
>
> David Daney
>

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

end of thread, other threads:[~2011-01-24 18:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-17 13:09 FW: Garbage collection issues in GCJ Ben Keppler
2011-01-17 17:32 ` David Daney
2011-01-17 18:57   ` Ben Keppler
2011-01-22 21:53     ` Florian Weimer
2011-01-23 19:12       ` Boehm, Hans
2011-01-24 17:45       ` David Daney
2011-01-24 17:59         ` Ben Keppler
2011-01-24 18:45           ` Hans Boehm

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).