Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

References to java programs coded using primitives only

I've heard of Java programs with strict latency requirements where "new" instructions are never -or very rarely- used (because no new=>no objects->no GC=>improved latency)... instead all business logic is handled using primitives.

I couldnt find references to this technique online though... any link to a webpage discussing this technique or snippets of code would be much appreciated.

like image 703
Eleco Avatar asked Nov 01 '10 15:11

Eleco


2 Answers

Update (March 2012): While there is no public announcement available, it appears Oracle has shut down their JavaRTS group.

The two topics you should look at are the Real-Time Specification for Java (JSR-1, JSR-282) and the Safety-Critical Specification for Java (JSR-302), (aonix page). RTSJ provides the resources for doing the type of careful memory management you are talking about in your question, though most of the users of RTSJ probably tolerate greater jitter than an "all-primitives" approach would (and, for that tolerance, they get the benefits of GC by using an RTGC). For some examples of the kinds of limited allocation (limiting when/where/how many times you can use new) search for "rtsj scoped memory rules", and here's an example academic paper on the topic. You should also look at "eventrons" as an example of trying to solve these high-frequency, low-latency constraints in Java in a (relatively) clean way.

For a specific new story on the use of JavaRTS in trading contexts, see here. For some instructions on how to get the most deterministic behavior out of JavaRTS in particular, see here.

Safety-Critical users are more likely to have these sorts of constraints, and SC-Java is (expected to be) partially a downscoped version of RTSJ. You can see some examples of what the expert group is looking at in Doug Locke's 2007 status slides from JTRES.

Several folks produce JVMs intended for use in this environment. Aonix/Atego's PERC; aicas' JamaicaVM; Apogee's Aphelion. The Sun/Oracle JavaRTS is targeted more towards larger applications that can tolerate (and benefit from) less stringent constraints.

While the "all-primitives" approach you cite is an extreme form of this type of programming, you are most likely to find resources around this topic at one of the above references.

For the "business logic in primitives?" naysayers above me, note that substantial amounts of IRS tax business logic is implemented in IBM assembler, and a number of "enterprise" layers like Java are being looked at to wrap (not replace!) that logic. Put that in your pipe and smoke it.

I can't cite any specifics here, but there are a number of defense applications using Java (usually a flavor of RTSJ) that have very tight constraints on memory allocation, and much of the code is statically-allocated, primitive focused. Signal processing, etc... I did a search for open source materials on systems I'm aware of, and these documents (see especially the references sections) point the way to some specific examples of these applications.

  • http://www.aicas.com/papers/scj.pdf
  • http://www.cs.purdue.edu/homes/jv/pubs/safecert09.pdf
  • AN/FPS-85 SpaceTrack Radar: http://unix.org.in/2010/10/sun-java-real-time-system-selected-for-space-surveillance-radar-java-technology-enables-real-time-behavior-and-throughputaviation/ and http://www.globalsecurity.org/space/systems/an-fps-85.htm
  • Army FCS: http://www.militaryaerospace.com/index/display/article-display/234337/articles/military-aerospace-electronics/volume-16/issue-8/news/aonix-hard-real-time-java-technology-useful-for-command-and-control.html
like image 190
andersoj Avatar answered Nov 18 '22 23:11

andersoj


I have worked on a number of such systems. You will need to worry about creating objects if you need sub millisecond latencies. It is possible to write an application which doesn't GC all day, just to avoid any GC delays.

However, 99%+ of applications don't need this extreme.

like image 38
Peter Lawrey Avatar answered Nov 19 '22 01:11

Peter Lawrey