tips on how to incur just 1 STW GC/day — low-latency java

Big eq trading desks in Citi and other banks claim they incur a single full-GC “penalty” a day in most jvm instances (where an instance is typically a node in a scalable grid). Here are some techniques.

0) “pre-allocate” long-living objects. Probably allocate a large array of primitive objects. Each “primitive object” could be a byteArray of fixed size. No POJO no java beans.
)) don’t let GC do the clean-up; reuse the memory pre-allocated. Reuse by dropping in new data. Circular array of fixed-size byteArray is one of my ideas.

2) avoid promoting objects beyond the nursery/eden — see other posts in this blog.

3) run 64bit and allocate enough heap (typically 10G) to last a day.
)) Each jvm instance presumably serves only US, or only Hongkong…, so it could shutdown nightly.
)) If an instance must run 24×7, then keep it simple and small.
)) If we still need more heap, split to 2 jvm instances.

)) avoid distributed cache and latency. Barc DMA guys also avoide distributed caching.
)) How do you size heap? See post on heap sizing

5) During a scheduled quiet period, trigger a full GC throughout the entire (huge) heap, which could actually take 30 minutes. Just call Runtime.gc(). If this doesn’t trigger GC, then tweak -XdisableExplicitGC


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s