Since 7.4 is released product, this is better addressed to the vwnc group.
I note that you can rewrite code of this form to be just
WindowingSystem isHeadless
which would avoid the ifDefinedDo: overhead, since WindowingSystem will always be there in a normal image (where the word normal here means that WindowingSystem has not been stripped). However, the canActivate cost would still be there. A better mechanism would be add a guard clause
WindowingSystem isActive ifTrue: [^false].
which should be fast once the windowing system is active. If we are running headless, then the canActivate variable in WindowingSystem will be false, so the test should again be fast. That would make the test only be slow in the interval where we are starting up with a GUI, but have not yet activated WindowingSystem.
At 09:50 AM 2/27/2006, Holger Kleinsorgen wrote:
>After migrating to VW 7.4, I noticed that some parts of our app were running unusually slow. The extra time was spent in #isHeadless, which was called in a method that itself was called very frequently. The headless check lookes like this:
>
> ...
> #{HeadlessImage}
> ifDefinedDo: [ : cl | cl default isHeadless ]
> elseDo: [ false ]
> ...
>
>In 7.2.1, #isHeadless just returns a Boolean variable. On my machine, the code above takes about 180 milliseconds for 1 million sends.
>In 7.4, #isHeadless sends "WindowingSystem canActivate not", which leads to a very costly computation of prerequisites using pragmas. It takes about 5 minutes for 1 million sends.
>Some kind of caching (either in isHeadless or in the prerequisites computation) would be relieving.
>
>Regards,
>Holger
--
Alan Knight [|], Cincom Smalltalk Development
[hidden email]
[hidden email]
http://www.cincom.com/smalltalk"The Static Typing Philosophy: Make it fast. Make it right. Make it run." - Niall Ross