[squeak-dev] #wait is slow
marcel.taeumel at hpi.de
Fri Jul 2 14:03:13 UTC 2021
> [...] both #waitExactly and #waitPrecisely would just sound "better" than normal #wait [...]
Ah, that's right. We wouldn't want to make everybody start using #waitExactly. Then it's maybe better to encode the "trade-off" directly in the message name. The method's comment should then reveal why it is there and that the normal use should be #wait. :-)
Am 02.07.2021 15:58:17 schrieb christoph.thiede at student.hpi.uni-potsdam.de <christoph.thiede at student.hpi.uni-potsdam.de>:
to me as a non-domain expert for this stuff, both #waitExactly and #waitPrecisely would just sound "better" than normal #wait (similar to names such as "PluggableTextMorph*Plus*" or "JPEGReadWriter2"). #busyWait, on the other hand, is something I would have considered a pretty popular term - it alerts me directly that this will be a busy and resource-intensive operation. But maybe that's just my impression. :-)
> Hmm... #busyWait would eat up more CPU cycles to gain accuracy. What about #waitPrecisely? Then you would not reveal that little implementation detail. And clients could make the decision between #wait and #waitPrecisely depending on whether they need accuracy, not whether they have CPU cycles to spare. Or #waitExactly? There must be some good name out there. :-)
> Am 01.07.2021 19:18:36 schrieb Thiede, Christoph :
> Hi all,
> I just made an interesting observation:
> [1000 timesRepeat: [0.001 seconds wait]] timeToRun. "-->Â 2612"
> I think the reason for this might be that Delay >> #schedule uses a critical section that is also accessed by theÂ TimerEventLoop processÂ with the highest priority in the system, so the synchronization overhead would be the bottleneck in this case.
> Instead,Â if you need to produce many short delays anyway (for instance, to simulate a running process, just like me right new), you can use a busy-wait instead:
> Duration >>Â busyWait
> | proceedTime |
> proceedTime := Time utcMicrosecondClock + self asMicroSeconds.
> [Time utcMicrosecondClock >= proceedTime] whileFalse
> [1000 timesRepeat: [0.001 seconds busyWait]] timeToRun "--> 1000"
> Much faster.
> Could we need this in the Trunk, too?
> -------------- next part --------------
> An HTML attachment was scrubbed...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev