Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supply.interval is drifting #5533

Open
p6rt opened this issue Aug 9, 2016 · 5 comments
Open

Supply.interval is drifting #5533

p6rt opened this issue Aug 9, 2016 · 5 comments
Labels

Comments

@p6rt
Copy link

@p6rt p6rt commented Aug 9, 2016

Migrated from rt.perl.org#128878 (status was 'open')

Searchable as RT128878$

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 9, 2016

From @AlexDaniel

Code​:
Supply.interval(1).tap​: {say (now - BEGIN now) % 1}; sleep ∞

Result​:
0.0304637
0.03055483
0.0314534
0.0325942
0.03372027
0.0340993
0.0352113
0.036300
0.0373585
0.03846543
0.0395657
0.0406380
0.04169298
0.0428189
0.0439086

In this case it is about 1ms per second, which is probably very bad. Is there any reason for it to do so?
As a user, I expect it not to drift.

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 12, 2016

From @zoffixznet

On Tue Aug 09 14​:36​:10 2016, alex.jakimenko@​gmail.com wrote​:

Code​:
Supply.interval(1).tap​: {say (now - BEGIN now) % 1}; sleep ∞

Result​:
0.0304637
0.03055483
0.0314534
0.0325942
0.03372027
0.0340993
0.0352113
0.036300
0.0373585
0.03846543
0.0395657
0.0406380
0.04169298
0.0428189
0.0439086

In this case it is about 1ms per second, which is probably very bad.
Is there
any reason for it to do so?
As a user, I expect it not to drift.

Are you sure it's not just an artifact of your measurement method? I'm not even sure what it's measuring.

Compare these​:

  perl6 -e 'for ^Inf { sleep .1; say (now - BEGIN now) % 1 }'

Shows your "drift" that wobbles between 0.1 and 0.9 seconds.

  perl6 -e 'for ^Inf { sleep .1; say now - BEGIN now }'

Shows all the values incrementing by .1 seconds, no drifts, as is proper. The occasional extra .01 seconds is expected, as we sleep for 'at least' .1 seconds and can't be super exact.

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 12, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 12, 2016

From @AlexDaniel

You can do it without % 1, sure. It is there to make it easier to see the
drift with your eyes, but you can see it without it.

The occasional extra .01 seconds is expected, as we sleep for 'at least'
.1 seconds and can't be super exact.

Sure, but there is no 「sleep」 in Supply.interval(1) example (except for the
one that sleeps forever).

My point is that Supply.interval() drifts. Yes, by a small amount of 1 ms
each tick, but drifts nonetheless.

I am not sure what TimToady meant here​:
http://irclog.perlgeek.de/perl6/2016-08-09#i_12994683 but it sounds like
there must be some Supply feature that does not drift. If it is not
Supply.interval(), then what is it?

On Fri, Aug 12, 2016 at 6​:11 AM, Zoffix Znet via RT <
perl6-bugs-followup@​perl.org> wrote​:

On Tue Aug 09 14​:36​:10 2016, alex.jakimenko@​gmail.com wrote​:

Code​:
Supply.interval(1).tap​: {say (now - BEGIN now) % 1}; sleep ∞

Result​:
0.0304637
0.03055483
0.0314534
0.0325942
0.03372027
0.0340993
0.0352113
0.036300
0.0373585
0.03846543
0.0395657
0.0406380
0.04169298
0.0428189
0.0439086

In this case it is about 1ms per second, which is probably very bad.
Is there
any reason for it to do so?
As a user, I expect it not to drift.

Are you sure it's not just an artifact of your measurement method? I'm not
even sure what it's measuring.

Compare these​:

perl6 \-e 'for ^Inf \{ sleep \.1; say \(now \- BEGIN now\) % 1 \}'

Shows your "drift" that wobbles between 0.1 and 0.9 seconds.

perl6 \-e 'for ^Inf \{ sleep \.1; say now \- BEGIN now \}'

Shows all the values incrementing by .1 seconds, no drifts, as is proper.
The occasional extra .01 seconds is expected, as we sleep for 'at least' .1
seconds and can't be super exact.

@p6rt
Copy link
Author

@p6rt p6rt commented Aug 12, 2016

From @zoffixznet

On Thu Aug 11 21​:14​:41 2016, alex.jakimenko@​gmail.com wrote​:

Sure, but there is no 「sleep」 in Supply.interval(1) example [...]
My point is that Supply.interval() drifts. Yes, by a small amount of 1
ms
each tick, but drifts nonetheless.

I'm not familiar with the internals, but I'd suspect that drift in .interval() is for the same reasons there's drift in sleep().

It emits in intervals of at least X seconds, which I'd expect it to do, rather than to keep true to some arbitrary starting point, frequently emitting in smaller-than-X-seconds intervals just to compensate.

@p6rt p6rt added the conc label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.