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

timer observable caps number of emissions on high frequency #50

Closed
wouterwln opened this issue Apr 2, 2024 · 3 comments
Closed

timer observable caps number of emissions on high frequency #50

wouterwln opened this issue Apr 2, 2024 · 3 comments

Comments

@wouterwln
Copy link
Member

wouterwln commented Apr 2, 2024

This is quite obvious because of processing power, but on my machine it caps at a suspiciously low frequency (+- 900 emissions/sec)
MWE:

using Rocket

struct CustomKeepActor <: Actor{Int}
    values::Vector{Float64}

    CustomKeepActor() = new(Vector{Float64}())
end

Rocket.on_next!(actor::CustomKeepActor, data::Int) = push!(actor.values, time())

actor = CustomKeepActor()
source = timer(0.1, 0.1)
sink = subscribe!(source, actor)

sleep(1)
# Random interval between two values
println(actor.values[200] - actor.values[199])

# average interval
println(sum(diff(actor.values))/ (length(actor.values)))
0.0012099742889404297
0.0011341167615997558

For me this works at around 900 emissions/sec, even though it should emit 10.000 times per second. I have also seen that even if we do more involved computation on subscription this emission rate does not change.

@bvdmitri
Copy link
Member

bvdmitri commented Apr 2, 2024

I investigate it a bit. It looks like the built-in julia Timer ignores the sub milliseconds interval and basically uses 1ms as its lowest period (or delay) possible

@less Timer(0.0001; interval = 0.0001)

has the following line

intervalms = ceil(UInt64, interval * 1000)

I think its a documentation issue from Julia side. It does not mention that sub-milliseconds intervals or delays are simply ignored.

P.S. That basically means that #49 had no influence.

@bauglir
Copy link

bauglir commented Apr 2, 2024

@bvdmitri
Copy link
Member

bvdmitri commented Apr 3, 2024

JuliaLang/julia#53934

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants