In the last article about Instruments we had a first look how to analyse an app where a beachball was visible. The example was quite boring, though. Today we are going to look at a better example.
So I had the idea to clean up some files on my main computer. I found a folder with Enron emails and thought that those would make a good test for archiving with Mail Archiver. I was quite dismayed to see the beachball for about half a minute after starting to archive. The time itself isn't really bad. The Enron emails are 500k and the email folder is on an external USB2 hard drive. But I really didn't expect to see the beachball.
Let's have a look what is happening.
In a first step I analysed everything with Instruments:
As explained in the first article about beachball analysis I then selected the red bar:
Now I drilled down until I was able to identify the culprit:
This was quite interesting. A while before I had Christian change the functions for FileListMBS not to show the beachball. I had done extensive testing with 100k emails on my main Fusion hard drive. I had confirmed that the beachball was gone. But now Instruments is showing me that the TrueItem function for a Folderitem still is making problems because the code is spending a whopping 77% of the time making the TrueItem.
A secondary problem is the constructor of the FileListMBS:
￼13% of 28 seconds isn't nothing.
What is the application doing?
As mentioned above I had Mail Archiver select the folder with 500k emails. The users expect a nice progress bar. Therefore, the application makes a list of Folderitems for all 500k items and in a second step reads the Folderitems.
How important is this to fix?
- Not every user has so many emails.
- Not all emails are on slow external hard drives.
- 28 seconds are small compared to the time that archiving 500k emails takes.
But: the beachball confuses users. I as developer know that the app does. The users only see the beachball.
Can I just get the folders instead of a full list of emails? What would happen to the progress bar in that case? The progress bar moves through all emails because some users have large (like GBs large) mbox files.
Or I'll just dump everything on Christian to fix.