-
Notifications
You must be signed in to change notification settings - Fork 80
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
Prefilter polled queues #242
Conversation
199cc42
to
6596f01
Compare
6596f01
to
887f2b7
Compare
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.
A couple nitpicks but I'm not very knowledgeable with TT internals to comment on correctness.
e227c35
to
9dadb56
Compare
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.
Looks good except the comment.
tasktiger/worker.py
Outdated
@@ -23,6 +24,7 @@ | |||
from .timeouts import JobTimeoutException | |||
|
|||
LOCK_REDIS_KEY = "qslock" | |||
REDIS_GLOB_CHARACTER_PATTERN = re.compile(r"([?*\[\]])") |
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.
The relevant characters to be escaped are *
, ?
, [
, and \
(https://github.com/redis/redis/blob/155acef51ac7826ed294a4b61d891f1c7a9a40ac/src/util.c#L58). You additionally have ]
(which is fine but irrelevant), but you should also escape \
, so this should be re.compile(r"([?*\[\]\\])")
(or re.compile(r"([?*\[\\])")
).
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 don't know how I overlooked the \
character, thanks!
I am aware that it is not necessary to escape ]
, but to my knowledge Redis docs do not mention that fact and I prefer to avoid depending on undocumented behaviour.
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.
Which docs btw? I was trying to find Redis docs on globs but couldn't find any, so then I just looked at the source code.
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.
This has some examples https://redis.io/commands/keys/ but doesn't seem like a formal spec
This is a PoC for reducing the Redis load caused by each worker frequently polling the entire set of subqueues.
SSCAN lets us prefilter the queues we pull out of Redis, and seems pretty fast too: