I’ve been playing around with Workers and doing a test of the new Worker class. On a 2015 MacBook Pro that’s been Bootcamped the same file set takes considerably less time in Windows than on Mac. I don’t have the exact numbers in front of me at the moment but it was considerable.
Is the updated FolderItem for APFS that much slower? Is this an Apple issue or a Xojo implementation issue?
There are definitely parts of it that are far slower. For me the biggest problem was the Swap Folderitem function in order to do a safe save. Write to a temporary file and once verified swap the temporary file with the real one. That was an order of magnitude slower on APFS.
Also dealing with folderitem objects is very different. They no longer still point to the same file if you rename any other folder in the path. They really are just a dumb path now. This caused me no end of frustration to figure out why things were sometimes broken after the update.
I haven’t noticed that otherwise just handling files without those things are any slower, or enough slower to actually notice. There are almost certainly other implementation differences we can blame between windows and the Mac. Do you have the same problems when running not as a worker? Is it worse in debug mode where the worker is running as a thread and not as a separate process?
I once wrote functions like ReadFileMBS and WriteFileMBS for my plugins to speed up a few of my apps. For reading thousands of text files and writing thousands of small html files, it’s much faster.
Not to mention ReadFileMBS() is just so dang convenient for one-line reading of a text file into a string variable. Sure, I could write functions for some things in MBS. But why??
So I’ve done some more testing on this and results are…confusing. All I did was modify the default Worker project. I added a thread option and the ability to use a BinaryStream and Picture.FromData instead of Picture.Open. My test has 1071 png and jpg files to resize. Before each run I restarted the app and deleted the Resized Images folder. MBP is Bootcamped to run on the exact same hardware.
I don’t think Workers are working (pun intended) as expected. I would expect the Workers to be considerably faster than using a thread and I’m not seeing it even though the fans on my MBP are running full blast with workers.
I’d love for others to examine Workers in greater detail to either confirm or dispute my results.
The worker is a console app.
So desktop app uses CoreGraphics for working with graphics, while Console uses a library called GD, which does a bit different things.
And I wonder whether Mac side does more on the pictures, e.g. color space correction.
I noticed a few years back that console framework graphics were significantly slower than desktop framework graphics.
We solved this by ditching Xojo pictures and using MBS & Einhuger plugins instead.
See the following for more info:
• MBS: PictureMBS / JPEGImporterMBS / PNGReaderMBS / TiffPictureMBS
• Einhuger: PictureEffectsRaw
I did a comparison test with the worker settings of 3 cores and max 50% and time went from 274 to 545 seconds. It still kills me that the thread is faster than the Worker. I’ll have to try with the MBS classes to see how those affect this test.
I’m still think that Workers aren’t working like they’re supposed to.
More testing results. My conclusion is that the Picture Resize example is simply a bad example. Why? Because if you increase the number of pictures that the worker handles for each job to 20 you get a significant performance increase (at least for MacOS).
Mac Standard Picture.Open: To 196 from 274 seconds.
Mac Binary Stream: To 176 from 182
Windows Standard Picture.Open: No difference
Windows Binary Stream: No difference
This says to me that your Worker needs to be doing something really time consuming (i.e. not quick and quit) because there is a cost to starting and stopping a worker process.