[Cuis-dev] BaseImageTests for 5302

Juan Vuletich JuanVuletich at zoho.com
Thu Jun 23 17:48:48 PDT 2022


On 6/23/2022 6:57 PM, ken.dickey--- via Cuis-dev wrote:
> On 2022-06-23 08:31, Juan Vuletich wrote:
> ..
>> Nope. #valueWithin:onTimeout: should work correctly if processes are
>> preempted. It actually uses process preemption to do its job (see the
>> implementation).
>>
>> The only (non-) problem here is that on the Sipeed Lichee RV,
>> #valueWithin:onTimeout: takes a bit longer to do its job. I just want
>> to give it this little extra time. That's why I'm asking you for an
>> appropriate timeout value.
>
> In a workspace [LicheeRV Dock]:
>
>  [1000 milliseconds asDelay wait] valueWithin: 100 milliSeconds 
> onTimeout: [] ]
>    durationToRun.
>   -> 0:00:00:00:102   [102 milliseconds]
>
>  [ [ [5 seconds asDelay wait] valueWithin:100 milliseconds onTimeout: 
> [] ]
>    valueWithIn: 500 milliseconds onTimeOut: [] ] durationToRun.
>   -> 0:00:00:00:104   [104 milliseconds]
>
> The preemptions can only happen during #durationToRun, right?  Between 
> getting the start time, running the block, and getting the end time.

No. Preemption can happen almost anytime. For instance, for sure 
preemption will occur inside #valueWithin:onTimeout:, as I said before. 
Without preemption, there would be no way to stop the delay before it ends!

> This is why running the tests uninterruptedly (e.g. Cmd-t in a 
> browser) pass and running in background fails.

Ok. I see now. It looks like in slow hardware Morphic takes all CPU and 
doesn't leave enough time to run the tests quickly. Please try this 
version of the test:

testValueWithinTimingBasic
     "Test timing of valueWithin:onTimeout:"
     | time |
     [
         time := [
             [1000 milliSeconds asDelay wait]
                 valueWithin: 100 milliSeconds onTimeout: []
         ] durationToRun.
         self assert: time < 200 milliSeconds.
     ] forkAt: Processor userInterruptPriority.

I believe this could do the trick. And actually that something like 110 
or 120 milliseconds could be enough, never requiring 200 milliseconds.

> I think that giving extra time for #durationToRun in background is 
> testing the wrong thing.
>
> $0.02,
> -KenD

BTW, can you post the results you get on `0 tinyBenchmarks`? I'd like to 
add them to the comment in the method.

Thanks,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
https://independent.academia.edu/JuanVuletich
https://www.researchgate.net/profile/Juan-Vuletich
https://patents.justia.com/inventor/juan-manuel-vuletich
https://twitter.com/JuanVuletich



More information about the Cuis-dev mailing list