-
Notifications
You must be signed in to change notification settings - Fork 62
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
Use sorted set to limit with moving window #33
Use sorted set to limit with moving window #33
Conversation
I don't want to embed cpp here, is there any other option? BTW the CI failed for node 4 and 5 (I will change to 6 soon) |
I've pushed a commit to use EDIT: if this goes forward then I'll squash. |
7ca5a69
to
1d20bed
Compare
index.js
Outdated
function mget() { | ||
db.watch([count], function (err) { | ||
var now = Date.now() * 1000 + Math.floor(process.hrtime()[1] / 1000) % 1000; | ||
var start = now - duration * 1000; |
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.
Should be (duration + 1)
to take into account jitter from hrtime
microseconds.
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.
That's because hrtime
is not stable enough for us :-\
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.
In general, I want to understand if we really need this. These operations are slower than only 3 straightforward set
s, and I'm not sure what is the value.
Can you tell me more about the use case for this library that requires microseconds resolution?
index.js
Outdated
|
||
function mget() { | ||
db.watch([count], function (err) { | ||
var now = Date.now() * 1000 + Math.floor(process.hrtime()[1] / 1000) % 1000; |
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'm not sure using process.hrtime
is the best approach either. By definition it related to arbitrary time in the past.
index.js
Outdated
function mget() { | ||
db.watch([count], function (err) { | ||
var now = Date.now() * 1000 + Math.floor(process.hrtime()[1] / 1000) % 1000; | ||
var start = now - duration * 1000; |
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.
That's because hrtime
is not stable enough for us :-\
1d20bed
to
e8a76da
Compare
@noamshemesh sorry for the delay. Current implementation problems:
Given the above, and following the code, it can enter a loop The way I see, the current implementation lacks for atomicity and it is unstable in a high concurrent system. BTW, as stated here, tests fail randomly because of the above reasons. The proposed solution doesn't suffer the above problems. It is only a bit more |
@noamshemesh forgot to explain the need for microtime. BTW, pushed a commit with an alternative solution regarding the microtime. |
e8a76da
to
2f32b27
Compare
Ping @noamshemesh. |
Sorry, crazy days, will take a look on the next weekend
…On Thu, Feb 23, 2017, 13:42 João Barbosa ***@***.***> wrote:
Ping @noamshemesh <https://github.com/noamshemesh>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#33 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE4fwYY2PtWjqhEctiU2fzgmFe6cY5iJks5rfXCKgaJpZM4L5p0o>
.
|
Looks good, thanks. |
2f32b27
to
7d124ed
Compare
7d124ed
to
2a56a04
Compare
@noamshemesh done. BTW, if it would be awesome if you could create a release. |
Sure, I think I'll release a major version. what do you think?
…On Sun, Feb 26, 2017, 13:33 João Barbosa ***@***.***> wrote:
@noamshemesh <https://github.com/noamshemesh> done.
BTW, if it would be awesome if you could create a release.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#33 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE4fwa0gSNr6Cdx5KejAtYOAUUclttyOks5rgWMcgaJpZM4L5p0o>
.
|
LGTM |
Done. Thanks a lot! |
No description provided.