MATLAB: Slow plotting performance starting from Matlab R2014b

graphicsMATLABperformanceplotr2014br2014bgraphicsr2015a

I observed considerably worse performance of Matlab plot functions with versions R2014b and R2015a compared to earlier versions. Some of my interactive plots became almost unusable. For example, for one of my plots with 6 subplots and about 1000 data points each, the update of the plot is rather fast (<100ms) but then it takes about 30s until the plot is responsive and the command line is free. Using tic/toc and profiler I was not able to figure out where Matlab spends the time. It seems to be a problem related to the new graphics engine introduced in R2014b.
A small example (extreme case with many data points) shows how much slower plotting performs with R2014b/R2015a compared to R2013b in the case of many data points:
xx=randn( 1e7,1);
figure(1)
tic;
plot( xx, 'x');
drawnow;
toc
System 1:
  • CPU: Intel Core i7-3930K
  • GPU: Nvidia GeForce GTX580
  • RAM: 64GB
  • OS: Windows 7 Enterprise 64bit
  • Matlab 64bit
  • All drivers are up to date.
R2013b: Elapsed time is 2.207543 seconds.
R2014b: Elapsed time is 37.758890 seconds.
R2015a: Elapsed time is 35.490439 seconds.
System 2:
  • CPU: Intel Core i5-2500K
  • GPU: Intel HD Graphics 3000
  • RAM: 32GB
  • OS: Windows 7 Enterprise 64bit
  • Matlab 64bit
  • All drivers are up to date.
R2013b: Elapsed time is 2.402014 seconds.
R2014b: Elapsed time is 62.260723 seconds.
For the R2014b/R2015a version there is in addition this function execution time a time interval of several tens of seconds after plotting until Matlab is responsive. This time interval is negligible for the R2013b version.
Furthermore, I observed huge differences in memory consumption of Matlab. After executing the commands above, the Windows task manger shows following memory consumption values. Maybe this is related to the slow plotting performance.
R2013b: ~600 MB
R2014b: ~12 GB
R2015a: ~11 GB
Does anyone observe a similar behavior and know how to solve this problem?

Best Answer

The difference between the two versions is really a bit too complex to capture in a single number. I've been going into some of the details on the MATLAB Graphics blog.
My guess from your example is that what you're seeing is marker drawing performance. I don't think that I've covered that one well in the blog. The short version is that all of the graphics functions now share a single marker drawing implementation. This new version is faster than some of the old ones (e.g. the scatter example in this post ), but slower than the fastest of the old ones (which is the one you'd be getting here with plot). We're still working on tuning this up, and you should see some improvements as each new release comes out.
The one special case in marker drawing which is important to know about is that the '.' marker translates directly to an OpenGL primitive, and is much faster (and uses less memory) than all of the others which require a lot of shimming.
Related Question