Skip to content
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

Allow to set ZMQ HWM for Eye Streams #1895

Merged
merged 7 commits into from
Jun 2, 2020

Conversation

moiri
Copy link
Contributor

@moiri moiri commented May 29, 2020

Allow to change the socket option HWM for the eye data streams

  • during initialization by extending the notification eye_process.should_start with the field hwm
  • at runtime with a GUI text input (this will cause a ZMQ reconnection)
  • at runtime with the notification eye_stream.set_zmq_option.hwm (this will cause a ZMQ reconnection)

@papr
Copy link
Contributor

papr commented Jun 2, 2020

@moiri Hi, could you elaborate on the use case of these features? In which cases do you think is it necessary to change the zmq hwm from its default value to a custom one? And is it necessary to be able to do so dynamically? Or do you think it would be possible to hardcode a specific hwm that fits better than the default one?

@moiri
Copy link
Contributor Author

moiri commented Jun 2, 2020

@papr I have a scenario where I always need the latest data sample from the device. I prioritize latency over throughput, hence I don't want to fill up the buffer with "old" data which I first have to process before getting to the latest data sample. I would like to set the HWM to 1 (minimum). This may result in the loss of some data samples which is ok as long as I always get the latest sample.

Being able to set this dynamically is not necessary. For my purpose it would be sufficient to set it during initialization (i.e. with the notification eye_process.should_start and the field hwm).

Should I remove the dynamic parts (GUI and eye_stream.set_zmq_option.hwm notification)?

@papr
Copy link
Contributor

papr commented Jun 2, 2020

I am not sure if setting the HWM to 1 does what you intend. Looking at https://rfc.zeromq.org/spec/29/#the-pub-socket-type I see

For processing outgoing messages:
[...]

  • SHALL silently drop the message if the queue for a subscriber is full.

The queue in your case would have a length of 1 and would be full most of the time. If I understand the document correctly, you would be dropping newer data instead of replacing old data in the sending queue. This is not what you intended by setting the HWM to 1, correct?

@moiri
Copy link
Contributor Author

moiri commented Jun 2, 2020

You are correct, but I have not found any way to overwrite the existing data in the queue. I can deal with one old data sample way better than with 1000 old data samples (which is the default). So HWM = 1 is not ideal but it is good enough for me.

Copy link
Contributor

@papr papr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to reduce the PR to the minimal required amount of change to keep it as maintainable as possible. This means removing all possibilities to change the hwm dynamically. Additionally, I would like to give the variable a more explicit name.

You can apply the suggestions using the Github webinterface if you agree with the changes. I would appreciate it if you could give this an other test run after applying the changes in case I made a mistake while typing the suggestions.

pupil_src/launchables/eye.py Outdated Show resolved Hide resolved
pupil_src/launchables/eye.py Outdated Show resolved Hide resolved
pupil_src/launchables/eye.py Outdated Show resolved Hide resolved
pupil_src/launchables/eye.py Outdated Show resolved Hide resolved
pupil_src/launchables/eye.py Outdated Show resolved Hide resolved
pupil_src/launchables/eye.py Outdated Show resolved Hide resolved
pupil_src/main.py Outdated Show resolved Hide resolved
pupil_src/main.py Outdated Show resolved Hide resolved
pupil_src/shared_modules/zmq_tools.py Outdated Show resolved Hide resolved
moiri and others added 4 commits June 2, 2020 14:35
Co-authored-by: Pablo Prietz <pablo@prietz.org>
Co-authored-by: Pablo Prietz <pablo@prietz.org>
change the variable `hwm` to the more explicit `pub_socket_hwm`

Co-authored-by: Pablo Prietz <pablo@prietz.org>
remove dynamic pub_socket_hwm changes

Co-authored-by: Pablo Prietz <pablo@prietz.org>
@papr papr requested review from pfaion and romanroibu June 2, 2020 12:40
@papr papr changed the base branch from master to develop June 2, 2020 12:44
papr and others added 2 commits June 2, 2020 14:47
Remove unused attribute

Co-authored-by: Pablo Prietz <pablo@prietz.org>
@papr papr added API changes Indicates issues and prs that either change the zmq or plugin api, or the export format. type: enhancement labels Jun 2, 2020
@moiri
Copy link
Contributor Author

moiri commented Jun 2, 2020

Thanks for the suggestions and the fast replies!
I tested the changes and it works fine.

@papr papr merged commit 313cb57 into pupil-labs:develop Jun 2, 2020
@papr
Copy link
Contributor

papr commented Jun 2, 2020

@moiri Gratulations to your first Pupil project source code contribution! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API changes Indicates issues and prs that either change the zmq or plugin api, or the export format. type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants