Subjectively, when I use the Arduino monitor, there is a fairly long lag between sending a message to the board and a response printing to the monitor. Any idea what could be causing this, or how to fix this?
Same lag with both Arduinos? Or is the lag only with the Mega?
On the Arduino, loop() is called over and over, as fast as possible.
In Processing, draw() is called over and over, but NOT as fast as possible. The idea is that draw() is drawing stuff, so it need not be called any faster than the desired frame rate. The serialEvent() method, on the other hand, IS called whenever there is serial data.
So, for optimum speed reading and writing serial data from Processing, serial data should not be read/sent in draw(). It should be read in serialEvent(), and sent there if data is to be sent in response to serial input. If data is to be sent in response to key or mouse events, that happens in draw().