Improving s2a_fm Performance

Recently, a couple of s2a_fm users had asked about improving s2a_fm's CPU utilization performance. Here is a quick Scratch test program that monitors 3 analog input devices and a single digital input device.

Running this program using the current s2a_fm code, typical CPU utilization is shown in this task manager screenshot:
We can see that Scratch is taking up about 1% of the CPU and that s2a_fm is consuming about 40% of the CPU.

These measurements were taken using Ubuntu 15.10 64bit running on an Intel i5-2600k with 8 GB of RAM installed.

Running the same exact Scratch program on a prototype asyncio implementation of s2a_fm,  we get the following results:

The asyncio version dramatically reduced CPU utilization by a factor of 10! In addition, there appears to be an improvement in responsiveness. For example, when changing the value of the pot, there is less stutter and lag.

Because these results are so promising, I am about to embark on developing the next generation of s2a_fm, to be called s2aio.

Here are some of the design goals for the new version:
  • All existing s2a_fm Scratch programs should be able to be run on s2aio without modification including existing language translation support.
  • Provide Arduino auto port detection. s2aio will be using pymata-aio that has this capability already implemented.
  • Auto launch of Scratch 2 after invoking s2aio. This is already working for Linux, and hopefully will be available for Windows as well.
  • Simpler installation - single command to install s2aio, and all of its dependencies (pymata-aio, pyserial, aiohttp, etc.).
  • All documentation to appear on the project's Github Wiki page. The goal here is that the documentation can be easily translated using Google Chrome's translation facilities.
Please note that s2aio will require the use of Python 3.5 and will not be compatible with Python 2.7. 

Stay tuned for further updates. 

No comments:

Post a Comment