MATLAB: Do I see a degradation in the performance of MATLAB when I set the DISPLAY environment variable on the LINUX machine to a remote terminal in MATLAB 7.7 (R2008b)

MATLAB

I have a deployed application running on Machine A. I have a remote terminal Machine B. The environment variable DISPLAY setting seems to affect the performance of the MATLAB routine as follows:
DISPLAY pointing to Machine B:
average time per MATLAB function call: 0.0878654 s
DISPLAY pointing to Machine A :
average time per MATLAB function call: 0.000422319 s
I would like to know what causes such a difference in performace?

Best Answer

This is expected behavior. There will be a performance degradation in MATLAB when the DISPLAY environment variable is set to a remote location.
MATLAB accesses the X-Server event queue multiple times internally for every MATLAB function call if the DISPLAY is set. If the X-server is located remotely, this may add up to a lag when the MATLAB routine is called several times because each time, MATLAB accesses the X-server multiple times.
To workaround this issue, set the DISPLAY environment variable to a non-existent machine. In that case, MATLAB switches to an 'UserEventQueue' (local). The 'UserEventQueue' was created for the express purpose of providing a thread safe message queue in the case where X11 is unavailable on Unix.