Starting With Multi Core Processing

Hello All,

After enjoying a time developing an application for use on several platforms I found that on one, the Raspberry PI, it suffered from a lack of horsepower when doing its main job of receiving data on a serial port and then showing it on screen.

It has a lag on the screen which is quite obviously to do with the redraw time and the processor being busy reading lots of data on the serial port.

The obvious thing to try is to put the most intensive task, reading the serial port, in its own bubble and put a second of its little processors to work.

This is not a Raspberry PI related issue, but some background should be useful.

I have never thought of using multiple cores previously as I have always been spoiled by my i7 17’ MacBookPro with loads of RAM and an SSD.
This area is entirely new to me so I looked for some help, finding this immediately:-
Xojo Dev Link

I downloaded the example code and built it, tested it as explained, loaded the four example text files and counted the words, sequential was 19.92 seconds, threaded was 20.3 seconds and processes was 1.01 seconds.
That I found astonishing and was looking forward to getting started understanding how it all works.

At this point I noticed something which seemed incorrect, although the processes option was super fast it actually produced no results, the word count column was just zero.

As this particular area is completely new to me I thought it might be better to ask if someone else might try the sample from the link above and check if they get the same result.

Tested in 15.4.1, 16.1 and more recent builds also, Mac 10.10.5

Regards

Mark

Not sure about the sample but the fact that it’s not returning any results is probably the reason it’s so fast. :slight_smile:
Using multiple helpers/workers/agents is not too complicated. I found that most time was going into organizing the launching of the helpers, how to communicate with them and route to the proper methods to process the results.
Paul Lefebvre’s Webinar on Threads covered this topic as well: https://www.youtube.com/watch?v=nkdS0Pw88Os

If the processes count is returning immediately, it would imply it is not actually running. You need to build the WordCounter console app and put it next to the app in order for the code find and run it by default. I get 19s in sequential and 9s for Processes.

Ok I tried this again.

I compiled both projects, in a new folder, copied both built files and libs next to the text files and I still get 0 count.
I tried moving the built gui file next to the console file with same results, I moved the console and lib folder next to the gui file and still a zero count.

I can not think of another way I can place the files that I have not tried.

by accident I launched the console and it throws an exception:-

Exception Message:
Exception Error Number: 0
An exception of class OutOfBoundsException was not handled. The application must shut down.logout

[Process completed]

so as it stands I am unable to get the example working as expected!

Any more ideas folks?

There was an error in the old example project at the link above (a wrong path type was passed to the shell), see <https://xojo.com/issue/36528>. Try with the example project included with release 2016r1 and it should work.

hi richard, thanks for that, I will try it out.

Ok Richard, finally got to it, its 8 seconds with multi processing so just under half the time when other methods used!

Thank You all for the replies.