Inside Your Treo: Notifications, Background Apps & Your Blazing Fast Treo!
Special thanks to Rob Jonson of Hobbyist Software for contributing this article.
One of the standard objections to the Palm operating system is that it isn’t multi-tasking.
That’s sort-of true, but you wouldn’t know it when you were surfing the web whilst listening to an mp3 and using another application in the background to make your volume keys act as scroll keys.
This article will explain the basics about how that all works, and how you can use Palm Internals to see how much this background activity is slowing down your Treo - and what you can do about it!
So how does stuff work in the background?
Palm OS has two main ways of making stuff happen in the background. The first is specially designed for sound. It lets Pocket Tunes and Aero Player run merrily in the background. It actually doesn’t have to be used for sound - in fact, I think it’s used for checking email by at least one application.
We’re going to ignore the sound thread method though because the vast majority of applications that work in the background use notifications. The Notification system lets applications register with the operating system for things they care about.
One of the notifications that Butler registers for is ‘hapl’ also known as sysNotifyAppLaunchingEvent. This is the notification for when an application is about to be launched. Whenever the system is about to launch an application, it first ‘notifies’ Butler that it is about to. Butler can then do anything it needs to (like keeping a list of recently opened applications).
To the user, it seems as if this is happening magically in the background, but actually, while this notification is being processed by Butler, the system waits, so there is a tiny and hopefully unnoticeable delay.
There are lots of different notifications that applications can register for. You’ll be amazed at how many are live on your Treo. You can see them all by downloading the free Palm Internals, letting it scan your treo and tapping on the ‘Notif.’ button.
My Treo 650 lists 220 notifications that are live! Part of the list is shown to the right.
For many of the standard notifications, Palm Internals gives an explanation, like ‘hots’ which is sent when a hotsync starts. I’ve made a list at the bottom of this article of some of the others. There is some great programmer humour in some of these!
Now, every time one of these happens, each registered application is called and given a chance to do something. Most of the registrations are actually for system processes like the bluetooth manager, the GSM library or the SMS application. (if you want to see the whole list, use menu/Full Notif).
Most notifications happen fairly infrequently (how often to you actually switch apps or insert an sd card), so it doesn’t really matter whether the application responding takes a thousandth of a second, or a tenth of a second. Even an extra tenth of a second (that would be REALLY SLOW) isn’t going to make a difference to how fast the treo feels. One notification is different though!
‘HEDE’ - Take Heed!
This is the notification of notifications! Palm has this warning for developers:
“Be very careful about registering for this; you can easily impact performance (in a bad way!)”
This notification is sent for every single event that the treo handles. This doesn’t mean much until you know how many events are sent! When you launch an application, the following events get sent:
- sysPenDown
- sysAppStop
- frmLoad
- frmOpen
- sysWinEnter
- sysPenUp
Whenever you press a key, at least two events are sent (one for the key down, one for the key up).
This means that when you launch an application, Butler is called 6 times! When you press a key, Butler is called twice. Butler has to finish it’s work before the application you are trying to launch gets a look in!
Unfortunately, HEDE is the only way that developers can get notifications of key presses, so quite a few apps register for it. As you can see though, it’s vitally important that if an application registers for HEDE, it makes every effort to be as efficient as possible.
The slow way and the fast way.
There are two ways that an application can register for a notification. Normally, the slow way is the best!
The Slow Way
When an application registers the slow way, it just tells the system what it’s creator id is. When the notification is triggered, the following happens:
1. The system goes looking for the app that matches the creator id
2. The system loads the application into cache (if necessary)
3. The system calls the application’s main function
4. The application recognises that this is a notification launch and calls the function that does the actual work
The great advantage of this method is that the system worries about 1 & 2. It means that the application doesn’t even have to know about caching and the weird stuff that the new palms get up to!
For almost all notifications, the slow way is the best way.
The Fast Way
When an application registers the fast way, it just tells the where the function is that needs to do the work. When the notification is triggered, the following happens:
1. The system calls the function that does the actual work
For HEDE, this is almost certainly the right thing to do. It is about 15 times faster than the slow way.
WARNING: The fast way has many pitfalls! The main one relates to the cache system in newer palm devices. In the old days, you could tell the operating system where your function was and expect it to still be there when it was needed. Now days, if you’re not very careful, the operating system can sweep your function out of the cache. The next time that the notification calls your function, it might actually be trying to run a bitmap, or your latest email. The odds are that it isn’t going to work! Your Treo will crash unexpectedly and with a quite unhelpful error log. My next article will explain how to use Reset Doctor to investigate which applications might be causing this.
Benchmarking
Now you know what is going on, you can check which applications are registering for HEDE. Using Palm Internals’ speed checker, you can even do a speed test to do a very rough check on the speed impact.
Simply select Menu/More/Speed Test, sit back for a moment and you’ll get a result. What Palm Internals does is simulate 10,000 key presses and see how long it takes. This isn’t like ‘real life’ because it isn’t testing how quickly the notification handles all the other types of events that get sent with HEDE, but it’s not a bad proxy.
My result is:
“Time in tics 4562, time in secs 45″ (there are 100 tics in a second).
I can see from my notification list above that Butler and ScreenShot5 are registered for HEDE. You’ll see that Butler has m68k… after it. This means that it is registered the fast way. ScreenShot5 is registered the slow way. If I disable ScreenShot5, my result is:
“Time in tics 393, time in secs 4″
That’s a big difference! All I need to do now is get my thumb-typing rate up to 10,000 chars/minute to take advantage of the benefit! If I disable Butler, I get
“Time in tics 111, time in secs 1 ”
That’s a much smaller difference - which is because I take pride in keeping Butler fast!
I’ve done a little testing on some common applications. On my Treo 650, they add the following amounts to the speed test:
Keep Your Perspective!
We all love to optimise - but remember it matters not one jot how slow the test is.
The only important thing is whether your treo feels slow. If you have a lot of apps registering for HEDE the slow way, it might be a problem. One or two probably won’t be noticeable.
I keep Butler, Initiate and ScreenShot5 enabled all the time. I could significantly improve my test score by disabling ScreenShot5, but my Treo 650 seems perfectly speedy and I like the app! If it saves me 15 seconds from having to open it, enable it and disable it whenever I want to use it, then that’s worth a lot more than the odd hundredth of a second that I can’t even notice!
My next article will be on the cache and how registering for notifications the fast way can cause random instability!
If there are other ‘Inside your Treo’ topics that you’d like me to cover, please let me know at the Hobbyist Software forum.
Related Links
Filed under: Editorials








What a great article! Very useful for me… I understood what happens a lot better. Thanks, Rob Jonson.
Will Palm Internals work with 700p? I’d hate to think the only fast software is Rob’s. It could be true, but I hate to think it. ;p
Great Article, thank you very much.
it really usefull. little question -
Where can i get a full list of notifications meaning on Palm ?
Rob, very nice article. I learned a few things. Your efforts are very appreciated - I look forward to another article from you!
very interesting, i may have to invest in PalmInternals…great job, Rob!
It is a balance. I agree that optimising for the sake of it is pointless, but PalmInternals is a very good way to keep tabs on your apps. Most apps using “slow hede” can be replaced now with perfectly stable ones which use “fast hede” or hvch, which is often sufficient and causes much less of a performance hit.
And if you’re a gamer, or like to run emulators or other ‘taxing’ apps, a few “slow hede” apps running can have a major effect, and you might not even realise. I just assumed that Bike or Die was supposed to run in slow motion, but it turned out that it was just being slowed down by other hede-using apps on my Treo. I smoked ‘em out using PalmInternals. That was a couple of years ago though, and things have got much better since.
A lot of apps now have “exclusion lists” as well, meaning that you can disable them for CPU-intensive apps. That way you can have your cake and eat it too.
It looks like the newest version of TreoSelecText uses “fast hede” btw. Personally I use YAHM and TreoKeyHack for that and the KeyCaps functionality.
suemarino: I ran it on my 700p and it seems to work fine.
I experienced similar impact with lightwav V1.7.1
lightwav + butler 45 secs
butler 8 secs.
Hi Folks,
glad you enjoyed the article. There is another on the way!
Couple of answers to questions:
Yes - Palminternals will run on the 700p (and it’s free)
as Rollo says, with ‘hede’ I don’t think the slow method is ever ok. With most other notifications, it is often better.
Finally, for the list of notifications - I don’t know if they are published on the web, but you can register as a developer and get them in the palm sdk (all free)
Great article - and I’m especially looking forward to the next one - my new Verizon 700p crashes 2-3 times a week (was 2-3 times a day until I removed the GoodLink client).
Thanks John and Rob.
I turned off Screenshots after reading this. And wow am I faster! I love Screenshots and I’ll re-enable it when needed, but it’s quite the background hog.
Suemarino - what is screenshots? Can you post a link to it? Doing a search turns up every page that HAS a screenshot of something.
Rob,
After running palm internals Initiate is showing up under hede. Should a launcher be there or is it the voice launching feature that needs this?
Also I have noticed another program showing up under hede that I don’t recognize. It is listed as “??? 0000 F30004B0 ???” Any suggestions as to what this program is?
I experienced similar impact with lightwav V1.7.1
lightwav + butler 45 secs
butler 8 secs.
kronhead said:
“Suemarino - what is screenshots? Can you post a link to it? Doing a search turns up every page that HAS a screenshot of something.”
kronhead, if you use the custom google-search at the top of this page to search for “Screenshot5″ (as labeled in the article…) you will find the application.
Informative yet covers a truly geeky subject without scaring off the villagers.
What a great article this is!
Kudos, Rob.