-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix try_flush_interval < 1 and queued_chunk_flush_interval < 1 to work #568
Conversation
cc: @shyouhei |
e750aad
to
75d8582
Compare
@@ -98,7 +98,7 @@ class OutputThread | |||
def initialize(output) | |||
@output = output | |||
@finish = false | |||
@next_time = Engine.now + 1.0 | |||
@next_time = Time.now.to_f + 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just directly use Time.now + 1.0
. Time objects can be compared or subtracted as-is.
irb(main):001:0> next_time = Time.now + 1.0
=> 2015-03-28 11:24:03 +0900
irb(main):002:0> next_wait = next_time - Time.now
=> 0.719691
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float + float is faster than time + float, and time < float results in error
irb(main):001:0> Time.now < Time.now.to_f
ArgumentError: comparison of Time with 1427512006.7472174 failed
from (irb):1:in `<'
but I think we can change it to time object here. let me try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made change like this to use time object > https://gist.github.com/sonots/3cd09b3022460ec1aac8
But, test did not pass. I felt it makes code complicated.
Also, note that float + float is faster than time + float.
My opinion is to use float rather than time object. Any opinions? > ALL
PS. Test passed with this additional change, though > https://gist.github.com/sonots/3cd09b3022460ec1aac8#comment-1422381
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I now feel that changing to Time objects here is kinda overkill to this original issue. It is a good thing to have, but we can live without them.
@repeatedly ping |
👍 LGTM |
I am going to merge this if there is no objection because this is critical for us. |
fix try_flush_interval < 1 and queued_chunk_flush_interval < 1 to work
Merged! |
fix try_flush_interval < 1 and queued_chunk_flush_interval < 1 to work
cherry-picked to v0.10 |
I hope code itself is no problem. |
Thank you. In case you plan to refactor, I recommend you to just use |
We were supposed to support
try_flush_interval < 1
andqueue_chunk_flush_interval < 1
, but the interval to calltry_flush
was still minimum 1 sec becauseEngine.now
isTime.now.to_i
.Illustration: The problem of the old logic:
@next_time
can be like1427488240.1
whenqueued_chunk_flush_interval 0.1
.But,
time
exceeds the@next_time
only when it became1427488241
(1 sec passed) becauseEngine.now
is integer.