-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
ZeroMQ seems to "wait" one second before receiving data. #4
Comments
Oh, i see, it is here:
/// Starts the periodic polling task if it was not started already and
/// if there are actually listeners on sockets
void _startPolling() {
if (_timer == null && _listening.isNotEmpty) {
_timer = Timer.periodic(const Duration(seconds: 1), (timer) => _poll());
}
}
this should be configurable imo. Is there a particular reason to limit it to 1 second? |
No there is no particular reason. I thought 1 second should be enough for most applications, but making it configurable seems to be the best option here. Since you already invested some time, do you want to open a PR and make it configurable? |
Will take a while but i can look into it :) |
On another note, I was thinking about using another thread just for the ZeroMQ poller. Then we could let it wait without delay and have messages coming in at the quickest rate possible. Though I don't know if that is a good idea. |
@enwi that sounds like a great idea. Can this be done with isolates? Do isolates behave the same on every platform? |
@Eerey It should be possible to do it with isolates as well. The main difference between |
I have implemented asynchronous polling on my fork. You can check it out on this PR. The main change is the ZPoller class and the original Timer implementation has been removed from ZContext. It works similar to other ZeroMQ implementations - the poller runs on another thread (Isolate in this case) and updates the main thread if there is data available. ZSockets are still updated through their Streams as soon as data is available. It works well on Linux and I will test it out on Windows soon when I get a chance. I'm fairly new to Dart, so let me know if you have any suggestions for improvements. |
Great job on using an isolate to solve this issue @ach-ee 👍 Also what is you opinion on this https://dart.dev/guides/libraries/create-library-packages#organizing-a-library-package? |
@ach-ee Do you have any updates on your changes regarding opening a new PR? |
@ach-ee I would also like to know if there are any updates on opening a PR for this! I also noticed you made a few other changes in your fork that would be great to include in this library👍🏼 |
Hey @stevenlayne12 sure there is some kind of workaround by changing the polling interval. Though this could lead to performance issues on some phones, but I am not sure. Just change the interval here: Line 68 in 26157a6
|
Okay awesome thanks @enwi ! As a separate point, I am trying to achieve low latency communication between flutter and python on linux (and optionally windows just for testing) and landed on using the PAIR socket type because I am looking for low latency bidirectional communication between those two stacks. Does this sound like the way to go? I only ask because I am not sure if this polling issue is partly due to the choice of socket in my case or not Nevertheless, I will give your suggestion a go! 👍 |
@stevenlayne12 the polling approach is currently not the best way to go @ach-ee started working on letting the ZeroMQ code run in another thread, which would be a lot better and have less latency, but I guess he stopped working on that. The code is still available on his GitHub though if you want to have a look. |
@canders-rf you can take a look at what @ach-ee did, which is currently in an unfinished state, but essentially the polling loop should be moved into a separate thread so that it can poll with blocking instead of right now where it would hang the whole app. |
Hi @enwi , What I'm curious is:
Really admire the work you're doing. Thanks in advance. |
Less than 1 second, maybe half of that or even 200 or 100 ms.
It is unfinished, because the main thread is not communicating with the receiving thread if recall correctly |
Hello there,
I'm testing this feature on windows.
When using a push/pull or pub/sub pattern there seems to be a one second delay on the pull/sub socket.
Is it built into ZeroMQ or can i configure this behaviour?
Best regards
The text was updated successfully, but these errors were encountered: