• ::math::random creates a high load average

    From Cecil Westerhof@21:1/5 to All on Sat Mar 12 11:37:21 2022
    I have a program where I 'roll' dice like:
    lappend diceRoll [expr {[::math::random 1 7] + [::math::random 1 7]}]

    I do this on Debian 11. It seems that it does increases load the
    average quit a lot. Can this be true?

    --
    Cecil Westerhof
    Senior Software Engineer
    LinkedIn: http://www.linkedin.com/in/cecilwesterhof

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Cecil Westerhof on Sat Mar 12 14:41:19 2022
    Cecil Westerhof <[email protected]> wrote:
    I have a program where I 'roll' dice like:
    lappend diceRoll [expr {[::math::random 1 7] + [::math::random 1 7]}]

    I do this on Debian 11. It seems that it does increases load the
    average quit a lot. Can this be true?

    That single statement in isolation (how you have presented the question
    to us here) should be imperceptable in the load average, which implies
    you have left off a critical bit of context, such as: "you run the
    above statement in a loop for 1 million iterations".

    This statement below will also increase the "load average" quite a lot:

    while {true} {}

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cecil Westerhof@21:1/5 to Rich on Sat Mar 12 18:35:55 2022
    Rich <[email protected]d> writes:

    Cecil Westerhof <[email protected]> wrote:
    I have a program where I 'roll' dice like:
    lappend diceRoll [expr {[::math::random 1 7] + [::math::random 1 7]}]

    I do this on Debian 11. It seems that it does increases load the
    average quit a lot. Can this be true?

    That single statement in isolation (how you have presented the question
    to us here) should be imperceptable in the load average, which implies
    you have left off a critical bit of context, such as: "you run the
    above statement in a loop for 1 million iterations".

    I should have been a bit more clear.

    It is done in two loops. The inner loop has 7 iterations and the outer
    loop has 25 million iterations. So in total 175 million times.

    I mend the Linux load average. That is:
    the average number of processes that are either in a runnable or
    uninterruptable state

    So I would not expect it to have more as a change of one on the load
    average and it was a lot more.


    I tried it again. Now the load average goes up by about 1.5. Higher as expected, but not to worry about I think.

    Previous it was repeatable, but probably there was something other
    running that got interference from my program.
    Something to look into later.

    --
    Cecil Westerhof
    Senior Software Engineer
    LinkedIn: http://www.linkedin.com/in/cecilwesterhof

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)