Tuesday Nov 04, 2014

SD Card Speed vs. Java SE Embedded Startup Times on Raspberry Pi

A friend/customer asked a question about the startup times of Java SE Embedded running on a certain flash-based embedded system. There were two initial questions that I had:

  1. Did Java startup time depend much on SD card speed?
  2. Did Java startup time depend much on the "compact profile" used, and related options.

I didn't have access to his system, so I decided to first experiment on something I could get my hands on - a Raspberry Pi B+. I also picked up some micro SD cards for testing.

If tl;dr, scroll to Final Results.

Micro SD Card Info

  • Micro Center 4GB Class 4 ($4). Whenever I've wanted the slowest possible flash memory, generic Micro Center flash cards have never disappointed me.
  • Toshiba 8GB 8GB Class 10, UHS-I (30mb/s).
  • SanDisk 8GB Class 4.

I benchmarked the random IO speed of these thread cards running on the Raspberry Pi (2014-09-09-wheezy-raspbian), using the iozone program (iozone -e -I -a -s 50M -r 4k -r 512k -i 0 -i 1 -i 2). Note that the "-I" option tries to bypass the linux buffer cache, which should more closely mimic doing "cold start" runs.

This produced a lot of data (see appendix at end), but here's a subset:

Iozone random (K/s) 4K read 4K write 512K read 512k write
MC Class 4 2655 4 6523 540
Tosh Class 10 3717 25 18003 1313
SanDisk Class 4 4923 707 18480 2106

The linux page size while reading a memory-mapped file (libjvm.so, for example) is 4K, so the numbers that should affect startup time the most are random 4K reads.

The Class 4 SanDisk seems to be the winner in 4K random reads.

Compact Profile Info

Compact Profiles are a feature added in JDK SE Embedded 8 which allow smaller subsets of a full JRE to be installed on an embedded system.  There are several things that get tuned when selecting the compact profile and optional features including:

  • What Java APIs are supported. Compact1 has the smallest subset of Java, Compact2 adds JDBC, RMI, etc., Compact 3 adds Security, Management, and Instrumentation. The "full" SE API includes AWT, SWING, CORBA, etc.
  • JVM builds - "minimal" has only one GC (serial) and no servicability features, "client" corresponds to the normal JRE client JVM.
  • Debug support - does the JVM support the JVMTI interface, and do the jar files contain debug info.
  • Compression - are the jar files compressed or not.

For this experiment I used the jrecreate tool to create 4 configurations using Java SE Embedded 8.0. Note that you can't use the current 8u6 release because it doesn't support Raspberry Pi boards.

  • Compact 1 (cp1): 10.8 MB
  • Compact 2 (cp2): 15.1 MB
  • Compact 2 with debug info (cp2.debug): 20.7MB
  • Compact 2 with debug info an uncompressed jar files (cp2.debug.big): 35.4MB

Two sub-questions are:

  1. Does the Java startup time vary with Java distribution size?
  2. Does the Java startup time go up or down with uncompressed jar files? Is there an SD card slow enough that the CPU time saved by not having to decompress the files is outweighed by the extra IO time?

Final Results

To test startup time I ran the "startup.helloworld" sub-test from specjvm2008 10 times for each configuration and took the average "user time" (on a pretty quiet raspberry pi, no X, etc.).

So the faster SD card does speed up Java startup by 7-8%. There is little difference between cp1 and cp2, but the extra debug info in cp2.debug does become a drag. The big surprise to me is that using uncompressed jar files speeds up startup time by 4-5% even on the slowest SD card.

Another way to view it is to compare startup times of other profiles to the cp1 profile, and startup times of other SD cards to the Microcenter SD cards:

This experiment didn't cover a very broad range of Micro SD cards (there are more expensive cards available with higher advertised performance, but they tend to be optimized for large sequential read/writes). But it looks there's an easy 10%+ variance in Java startup times depending on SD card speed and JRE configuration.


There are a lot of posts about SD card speed and Raspberry Pi performance (boot times, etc). See http://elinux.org/RPi_SD_cards#SD_card_performance, http://www.raspberrypi.org/forums/viewtopic.php?f=2&t=4076, http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=54169,  etc.

Full iozone data:

$ iozone -e -I -a -s 50M -r 4k -r 512k -i 0 -i 1 -i 2

Iozone: KB reclen write rewrite read reread Random read Random write
Toshiba: 51200 4 982 1010 5110 5112 3717 25

51200 512 8047 8595 18165 18167 18003 1313
MC Class 4 51200 4 770 804 3140 3141 2655 4

51200 512 3665 3887 16536 16926 6523 540
Sandisk Class 4 51200 4 1292 1542 5073 5064 4923 707

51200 512 3889 4878 18623 18619 18480 2106

JRECreate Options:

$ jrecreate.sh --dest cp1 -p compact1
$ jrecreate.sh --dest cp2 -p compact2
$ jrecreate.sh --dest cp2.debug -p compact2 -g -k
$ jrecreate.sh --dest cp2.debug.big --no-compression -p compact2 -g -k

 Startup time data (averaged)

cp1 cp2 cp2.debug cp2.debug.big
MC Class 4 12.303 12.3 12.392 11.947
Tosh Class 10 12.138 12.21 12.369 11.838
Sandisk Class 4 11.359 11.366 11.504 11.039

Wednesday Jan 25, 2012

2012 FIRST Robotics Competition Season Underway

At this very moment, somewhere around the world, some students are staring at a Java stack trace for a robot. They have three more weeks to finish developing their code, even though the robot isn't done, a motor is fried, and the drive team ate all of the snacks while waiting for the bug to get fixed...

[Read More]

Tuesday Mar 29, 2011

Upcoming FIRST events - San Jose and Boston

Just a reminder that the San Jose and Boston FIRST Robotics Regional competitions are this weekend and next. These are free, cool events near Oracle campuses where you can learn more about FIRST, the FIRST Robotics Competition, Java + FIRST, and FIRST @ Oracle.

 I'll be visiting the local Java teams in Boston.

Date Event Venue Location
Apr 2 Silicon Valley Regional San Jose State U. San Jose, CA
Apr 9
Boston Regional
Agannis Arena (Boston U.)
Boston, MA

There are more details at FIRST Robotics @ Oracle , especially the Event tips page.

Monday Feb 21, 2011

New SunSPOTs have arrived - faster, and with more memory!

The new batch of SunSPOTs are available to purchase at the Oracle Store! The changes are not just to the box color, but include a major upgrade to the Sun SPOT Hardware. The new "rev 8" Sun SPOTs includes:

  • 400 MHz ARM 926ej-S Processor
  • 8Mbytes Flash Memory
  • 1Mbytes SRAM Memory

The new demo board includes changes such as:

  • IR emitter/detector
  • Speaker
  • RGB color sensor
  • Updated accelerometer

Check out SunSPOTWorld.com for updated information.

Tuesday Oct 05, 2010

Sun SPOT Hands-on labs posted

David Simmons has posted the presentations and exercises from the hands-on labs given at JavaOne 2010 and 2008 (among other places) to sunspotworld.com. Look for the "Learning" tab on the left.

 ps. Thanks for the spelling corrections...

Thursday Sep 16, 2010

Room changes for JavaOne talks

It looks like JavaOne is fine-tuning room allocation for various sessions. I suggest preregistering for sessions you are sure to attend (you may get room change notifications), and double-checking on-site.

My two talks have moved three times so far! Shameless plug with new room assignments:

Java in the 2010 FIRST Robotic Competition

Java Native Access: More Java, Less Native


[Read More]

Thursday Sep 02, 2010

Sun SPOTs at JavaOne/Oracle OpenWorld

Between JavaOne and Oracle OpenWorld, and between the Sun SPOT team, other Oracle speakers, and Sun SPOT users, there will be two technical sessions, one hands-on lab, two BOFs, and a demo booth about Sun SPOT technology. So if you are coming to JavaOne or Oracle OpenWorld, come check out some of the sessions.

If you're a college student 18 or older you can attend for free! Space permitting that is - see this page for more details.
  • Session ID:     S318467 Data Springs: The Internet of Things, Wireless Sensor Networks, and Sun SPOTs
  • Session ID:     S314730 Sun SPOT Sensor Network Application Architecture Lab
  • Session ID:     S313933 Using Sun SPOTs in Educational Game Development
  • Session ID:     S313506 Making JavaFX Applications Look and Feel Real
  • Session ID:     S313194 Automatizing Your House with JavaFX and Open Source Hardware
  • Sun SPOT Demos and chatting: Mason Street Tent, Academic booth
Read the full blog entry for session details. There are also two tangential talks - "Java in the 2010 FIRST Robotic Competition" (which uses a version of the Sun SPOT SDK), and "Java Native Access: More Java, Less Native". See my previous blog entry for details.[Read More]

Cool Tech Sessions at JavaOne 2010

There are two great sessions at JavaOne that I can recommend - well because I'm giving them.

 NOTE: Rooms keep changing. Check schedule at the show, or better yet, pre-register!

 The first is related to FIRST...

Java in the 2010 FIRST Robotic Competition

Learn how Java was ported to run on the FIRST Robotics Competition platform, and hear about the experiences of hundreds of high school teams using Java for the first time in the 2010 competition season. The FIRST Robotics Competition is one of the largest high school robotics competitions, with more than 77,000 students and volunteers. This session covers:

  • What is the FIRST Robotics Competition
  • Experiences with Java in the 2010 competition season
  • APIs for programming the robots through the CompactRIO controller
    • WPIlib (image processing, servos, sensors, control loops, CAN interface)
    • Java Platform, Micro Edition (Java ME), information module profile
    • Squawk Java virtual machine
  • NetBeans integration
  • How Java was ported to National Instrument's CompactRIO controller
Speaker(s):     Eric Arseneau, Asset Science, Brad Miller, WPI, Professor, Derek White, Oracle
Session ID:     S314633
Schedule:     Tuesday, September 21, 11:30AM | Hilton San Francisco, Golden Gate 1 (was Yosemite B and Golden Gate 4/5)

The second session is related to FIRST in that it talks about the techniques that we used to interface both the Squawk JVM to VxWorks OS as well as the WPILib library to the FPGA code in robot controller. But these techniques can be used in Java SE and Java ME applications (in some cases) instead of using the traditional JNI in C code approach.

Java Native Access: More Java, Less Native

Developing embedded applications for Java often involves interacting with existing libraries, from common standards such as POSIX to custom FPGA libraries. Java Native Access (JNA) is an open source library that enables developers to access native code in shared libraries without needing to write more native code in Java Native Interface. Targeted at Java developers who need to call existing native code, this session will show how to use JNA and its recent improvements. Key points to be addressed include:

  • Java and native code: importing vs. outsourcing
  • How to declare imports of native code in JNA and how to use them
  • Cook book examples
  • New features (more platforms, Java ME and CLDC support)
Speaker:     Derek White, Oracle
Session ID:     S314579
Schedule:     Wednesday, September 22, 4:45PM | Hilton San Francisco, Golden Gate 8 (was Yosemite C)

By the way, I just learned that college students (18 and older) can attend JavaOne for free! Check out this page for details.

OK, these aren't the only cool tech sessions at JavaOne. See see my next blog for a list of all of the Sun SPOT sessions, labs, BOFs, and demos.

Wednesday May 05, 2010

Review of Java for the FIRST Robotics Competition


Java Usage

The 2010 FRC season has just completed, which included Java as a programming option for the first time. We don't have full statistics of which teams used which languages, but we conducted surveys at several regional competitions (where “we” mostly means National Instruments and my trusty assistant).

The sample data shows about 16% of the teams used Java to program their robots. There was a lot of regional variation, from 0% Java use at the Dallas and Detroit regionals to 37-40% at the Boston and Manchester regionals. But that same 16% Java average held true for teams at the Championship competition. Extrapolating from that sample, world-wide there should be about 288 teams that used Java this year.

The middle of the US is looking pretty empty! We should get complete data after FIRST conducts its “kit of parts” survey.

Java Results

The Java teams did well. Some Java teams won their regional competitions, and Java teams were in the 2nd place and runner up positions at the world championship! In fact, the number of Java teams in the Quarter finals through to the Championship matches roughly tracked the percentage of teams in Atlanta running Java.

We received feedback from in-person surveys and on support forums. Teams were very happy to be able to use Java because it was either taught in their high school or was well understood by the mentors. They also liked the NetBeans development environment and having a “safe” programming language.

But it wasn't all “teflon wheels and traction control” (a FIRST phrase synonymous with “good”, which I just made up). There were definitely areas that teams wanted improved. Some common issues:

  • Needed more documentation:
    • “Big picture” overview of a robot (IterativeRobot)
    • Cookbook recipes – how to setup and use a gyroscope (for example), and how to use the data
  • Image processing was too slow. Careful tuning of the camera, robot code, and the Dashboard running on the laptop was required to get reasonable performance. This should have been pre-tuned, and the systems should have more “performance headroom”.
  • More diagnostics. Many, many, many robot failures look like either “watchdog” or communication errors, when in fact they may be wiring, low voltage, hardware, networking, USB, field system, or software failures.
    • Need to log more data to detect or rule out error scenarios.
    • Need to present data in a way that makes diagnosis easier
  • Installation/version match issues
    • Built-in installation sanity checks were added, but more can be done
  • Bugs in WPILib and Java IO
  • Late CAN bus implementation

I spent several days at regionals and at the Championship helping Java teams with issues. The most frustrating case was a Java team with intermittent field communication errors, but we couldn't narrow the issue down to hardware, software/Java, networking, or field issues. Another team had some robot logic issues I was able to help with, and several teams had issues that were resolved with wiring or component swaps. I was relieved that the Java system itself didn't seem to be the cause of serious problems.

Beyond looking for teams that needed help, I really enjoyed learning what teams were doing with their robots. One industrious team programmed their robot three times, once in C++, Java, and Labview, and developed an Eclipse module for Java on FRC. Another team experimented with porting several Java libraries to the robot including a JavaScript interpreter. A couple of teams switched from Java to C++ because the CAN interface for Java wasn't complete, but another team simply reimplemented all of the Java CAN interfaces themselves!


The first year of Java for FRC went well. Not without a hitch, but not bad. We'll be working with WPI to improve the system for 2011, especially in the areas of diagnostics and performance. And I'd like to see the use of Java for FRC world-wide match the 30% use that we saw in New England.

I'll add in the usual disclaimers here – speaking for myself, not for Oracle, Sun Labs, WPI, or FIRST. Any erroneous data would be due to me.

Wednesday Apr 28, 2010

“It's Not About the Robots”

Dean Kamen, serial inventor and founder of FIRST (For Inspiration and Recognition of Science and Technology), often says this phrase at regional and championship FIRST Robotics Competitions.

What is it about?

This is my first year with skin in the game – not with a team, but as part of the group at Oracle and WPI porting and supporting Java for the robotics competition.

As I looked over my photos of regional competitions and the world championship in Atlanta I found some shots that exemplified FIRST to me.

The Green Reapers call a time-out in the final rounds of the WPI Regional. Something has gone horribly wrong, and they have to make it right (in front of the whole audience).

This worked at back at school...

No, there shouldn't be any parts left over...
 It takes a village to raise a robot

You can't always get what you want. Or what you need. But you go on anyway.

I guess what impresses me is that after teams learn that a plan for “the coolest robot ever” is just science fiction until it is built and tested, after learning that creating a robot is so complicated that teamwork isn't just nice but a requirement, or kids that never held a screwdriver before can make something unique and amazing, after learning that the math and science they've been learning isn't just useful, but it's kind of fun, after they have a shiny new robot in a picture with the school principle, then they go to competitions. Then they realize that haven't built a robot so much as they've built a “Murphy's Law” detector. And they have to deal with it. And they do.

If this experience doesn't help develop a world-class, science and technology literate workforce I don't know what will.

The most iconic scene that I photographed was team 51 waiting to compete at the world championship, when something happened that required them to swap out the main computer of their robot. Like a NASCAR pit crew, the team jumped to perform this lobotomy while on the floor of the Georgia Dome. Unlike most competitive sports, other teams swarmed around to help them. In this picture, team 40 gets ready to help by re-installing a fresh image to the robot's computer.

Team 40 used Java on their robot, which may explain the gratuitous Oracle logo :-)

The FIRST Competitions teach the kids to bring everything they have – their creativity, knowledge, skill, problem solving, energy, commitment. Then share it – that's how big problems get solved. And if they bring all of that to the competitions, they'll leave with more than they came with. And that's what it's about.


Apparently it's also about having fun. And hair. :-)

Thursday Feb 25, 2010

Dude, Where's my Lab?

Sun Microsystems Laboratories used to have a prominent link from www.sun.com.  Now that page redirects to www.oracle.com, which does not have such a link. But you can still find the Sun Labs page at research.sun.com.

Why do I bring this up? Well the headline article is "Java on FIRST!" of course, describing the deployment of the Squawk Java VM for embedded software development education.

Regional robotics competitions start in a week, and will run in different areas every weekend for the next 5 weeks. See usfirst.org for a complete schedule of events near you, as well as the FIRST Robotics @ Sun wiki (gotta rename that soon).

Friday Dec 04, 2009

Java SDK for FIRST Robotics Competition Released!

Over the last few months we've been working with WPI and 20 high school robotics teams getting the Java SDK for the FIRST Robotics Competition ready for the 2010 season. We've been getting great feedback from the teams including bugs and questions. We've also seen confirmation of the value that Java brings to some teams. One mentor said that they can usually only find a couple of student C++ programmers for the team, but for 2010 they have 10 Java programmers! Or was it 15?

This week FIRST announced a public release of the Java SDK. Here's the official word from Bill's Blog (the official FRC blog):

In addition, I’m very pleased to let you know that an early version of the FRC Java software is now available for download at http://first.wpi.edu/FRC/frcjava.html . I know we promised this for November, and I apologize for being a few days late, but I think you will be very happy with the results. Our hats off to the extraordinarily dedicated Java beta test teams and the developers for all their hard work! Veteran teams, I encourage you to open your doors to rookies in your area interested in getting an early look at Java and how it works with the robot. Remember they don’t have the advantage of having last year’s control system to experiment with.

This early-release SDK is only fully usable by FRC teams that have the cRIO hardware (veteran teams). Check the FIRST forums to read or request more information.

This Java SDK is based on the Squawk JVM and the Sun SPOT SDK. Rookie teams can get experience with the Netbeans IDE and Java ME APIs by using the Sun SPOT Emulator. See http://sunspotworld.com/frc for more information.

BTW, if you're an experienced Java programmer, don't sit around pouting about how you never get to program dangerous, high-speed, 120 pound robots. Consider being a programming mentor to a local FRC team! See our mentoring tips wiki as well as usfirst.org.

Wednesday Jun 10, 2009

FIRST @ JavaOne Wrap Up, videos, photos, and links...

I've finally caught my breath after JavaOne - we had a busy week. We were able to bring FIRST to a lot of technical people that had never heard of FIRST, and let people know that Java was coming.

JavaOne Pavilion... Technical Session and BOF...

James Gosling's Toy Show Keynote

Brad Miller and James Gosling talked about FIRST and Java in front of a live audience of thousands and webcast to many more. I helped with a demo along with Scott and Austin.

Duke's Choice Award... Thanks... More Information...  (Full Blog Entry)

[Read More]

Wednesday Jun 03, 2009

WPI Wins Duke's Choice Award for Java for FIRST Robotics Competition

Worcester Polytechnic Institute (WPI) won the 2009 Duke's Choice Award in the Category: Java Technology in Education for it's work bringing Java to the FIRST Robotics Competition.

This was worked started by WPI students Brian O'Keefe, Marouane Afiri, and Albedith Diaz for their "Major Qualifying Project". They ported the open source Squawk JVM to the compactRIO robot control system, and ported WPILib, the C++ robotics library used in the FIRST Robotics competition, to Java. They did a great job in in a very short time - they did the first port of Squawk to VxWorks (it was actually only the second port of Squawk to run "natively" on an OS), and were part of the initial proposal to the FIRST organization. I was very happy to be the team's "industry" advisor - this became my introduction into the world of FIRST robotics!

This work has been continued by the WPI Robotics Resource Center, assisted by the Squawk and Sun SPOT teams at Sun Microsystems Laboratories and other volunteers.

It's great to see WPI get recognized for the efforts to bring Java to the thousands of students developing robots for the FRC. Be on the lookout for robots in James Gosling's Toy Show keynote, and for the award presentation to Brad Miller of WPI!

Friday May 29, 2009

FIRST @ JavaOne

FIRST and the FIRST Robotics Competition will be part of several events at the JavaOne conference June1-5 at the Moscone Center in San Francisco. Many sessions are FREE to all, or FREE to students (registration required)

Monday, June 1 - S311736: "Lightning Talks, Part 4/FRC-FIRST Robotic Competition" 2:40 PM - 3:30 PM Esplanade 303

CommunityOne Registration
CommunityOne events are free to all. Register at http://www.cplan.com/communityone2009/w ... gistration

Pavilion - Java Playground
Will have representatives from FIRST, WPI, and several FRC teams. Robots will be demoed in the robot arena. Learn about FIRST, the FIRST Robotics Competition, and Java for FRC. Find out how to get involved!
Monday (June 1) 3:00 pm - 7:00 pm,
Tuesday 11:30 am - 7:30 pm
Wednesday 10:00 am - 4:30 pm
Thursday 10:00 am - 2:00 pm

Thursday, June 4 - TS-4945: FRC-FIRST Robotic Competition 2:50 PM - 3:50 PM Esplanade 305

1.The Java™ platform is an interesting vehicle for teaching kids about programming.
2. FIRST is an organization whose mission is to inspire young people to be science and technology leaders by engaging them in exciting mentor-based programs that build science, engineering, and technology skills; inspire innovation; and foster well-rounded life abilities such as self-confidence, communication, and leadership.
3. Robots are cool; robotic competitions are even cooler.
What happens when you mix these three things? You come up with a winning combination that lets kids and "adults" have a lot of fun.

Thursday, June 4 - BOF-4953 (Birds-Of-a-Feather) FRC-FIRST Robotic Competition 6:30 PM - 7:20 PM North Hall 124
What do robots and FIRST have to do with Java™ technology? Come to this session and see firsthand what Java technology is enabling kids to do today with some cool hardware. Get to play with big competition robots and their teams.

Friday, June 5 - James Gosling's Toy Show (general session) 8:30 am - 10:30 am

JavaOne Registration
The JavaOne Pavilion Pass, which includes General Sessions (and James Gosling's Toy Show) is free to all. Register at http://java.sun.com/javaone/2009/regist ... ilion_pass.

All sessions at JavaOne are free to students (under 18 requires chaperon). Register at http://java.sun.com/javaone/2009/regist ... d_students

Out of the fog... of bits, bytes, and really small Java Virtual Machines, by Derek White. The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.


« October 2016