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
| 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.
Should be (duration + 1) to take into account jitter from hrtime microseconds.
There was a problem hiding this comment.
That's because hrtime is not stable enough for us :-\
noamshemesh
left a comment
There was a problem hiding this comment.
In general, I want to understand if we really need this. These operations are slower than only 3 straightforward sets, 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.
I'm not sure using process.hrtime is the best approach either. By definition it related to arbitrary time in the past.
| 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.
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.