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

Multithreaded fan #21

Merged
merged 3 commits into from
Sep 26, 2024
Merged

Multithreaded fan #21

merged 3 commits into from
Sep 26, 2024

Conversation

JamesOHeaDLS
Copy link
Collaborator

Hi @GDYendell

I04 have been using this multithreaded-fan branch for the past week, and it has been running fine, no problems

Hopefully this branch can be merged in to master.

There is a question over where the number of threads is set, and what value it is currently set to?

Thanks,

James

@GDYendell GDYendell force-pushed the multithreaded-fan branch from 635142a to 772e0e6 Compare July 11, 2024 14:40
@GDYendell
Copy link
Collaborator

Rebased on master.

@garryod garryod requested a review from coretl July 15, 2024 12:56
@coretl coretl removed their request for review July 15, 2024 18:05
@GDYendell GDYendell requested review from ndevenish and ajgdls July 25, 2024 08:20
Copy link
Collaborator

@ajgdls ajgdls left a comment

Choose a reason for hiding this comment

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

A few magic numbers (8, 100 and 10000) which are used in multiple places so perhaps they should at least be #defined somewhere.

cpp/data/eigerfan/src/EigerFan.cpp Outdated Show resolved Hide resolved
cpp/data/eigerfan/src/EigerFan.cpp Show resolved Hide resolved
cpp/data/eigerfan/src/EigerFan.cpp Show resolved Hide resolved
cpp/data/eigerfan/src/EigerFan.cpp Outdated Show resolved Hide resolved
@JamesOHeaDLS
Copy link
Collaborator Author

I've been looking into some of the magic numbers and whether they can be taken from any of the following eigerfan command line options:

  -t [ --threads ] arg (=2)      Set the number of 0MQ threads for the 0MQ context
  -z [ --sockets ] arg (=1)      Set the number of zmq sockets to connect to the Eiger with

The number of sockets option is currently not used in the code

I believe the place where it should be used is when setting up the zmq context as part of EigerFan constructor.

 ctx_(config_.num_zmq_threads)

This context has a second optional argument of number of sockets which is never specified

inline explicit context_t (int io_threads_, int max_sockets_ = ZMQ_MAX_SOCKETS_DFLT)

so must always default to the zmq default of 1023

#define ZMQ_MAX_SOCKETS_DFLT 1023

(https://github.com/zeromq/libzmq/blob/master/include/zmq.h)?

The number of threads option is only used once, in the constructor where config is passed as an argument

EigerFan::EigerFan(EigerFanConfig config_)
: ctx_(config_.num_zmq_threads),
...

I'm wondering whether the number of threads given to the MultiPullBroker (currently hard-coded values) should match the number of zmq threads, or whether it should be treated completely independently (ie given its own argument or #define)?

Finally, there is an additional zmq context created with HandleRxSocket which is spawned by the run function. Should this take the same number of threads as the EigerFan zmq contexts, or should it also be treated independently?

@GDYendell
Copy link
Collaborator

GDYendell commented Aug 1, 2024

I am surprised that the command line sockets not used, but, if it doesn't do anything currently I think we should use it to pass into the broker constructor and leave ZMQ context sockets as the default.

number of threads given to the MultiPullBroker (currently hard-coded values) should match the number of zmq threads

I don't think there is any particular reason that it should be the same, but it is probably more reasonable than hard-coding one while the other is configurable.

@JamesOHeaDLS
Copy link
Collaborator Author

I am surprised that the command line sockets not used, but, if it doesn't do anything currently I think we should use it to pass into the broker constructor and leave ZMQ context sockets as the default.

Do you mean the broker constructor? This only has an argument for number of threads (rather than sockets)?

I don't think there is any particular reason that it should be the same, but it is probably more reasonable than hard-coding one while the other is configurable.

I think that's reasonable if we update the wording to say "the number of threads used for all zmq contexts". Alternatively a new command line option can be provided for this one thing, but it would probably always be the same value anyway

@GDYendell
Copy link
Collaborator

This only has an argument for number of threads (rather than sockets)?

Well the two are effectively equivalent, but perhaps it would better to have -t / --threads (passed to MultiPullBroker) and -z / --zmq-context-threads (passed to zmq context).

@MattTaylorDLS
Copy link

I'm sure that command line was used at some point! Maybe when I was playing around at the beginning with optimising performance? But can't remember now sorry

@GDYendell GDYendell added this to the 1.16.0 milestone Aug 12, 2024
* Repurpose now unused sockets as contextthreads
* Pass broker cmd line threads or the default
* Give HandleRxSocket an extra argument so can use context_threads
* Add hypen to variable for easier reading
* Clearer option description
* Remove duplicate EigerFan.h reference
* Rename num_zmq_threads to num_threads
@JamesOHeaDLS
Copy link
Collaborator Author

I think the remaining issues are the magic numbers for high water mark and socket linger timeout

I propose #defines for these? Does that sound ok?

* Removing redundunt lines. hwm is being set by RECEIVE_HWM
* Use SEND_HWM instead of local hwm
* Introduce LINGER_TIMEOUT constant, replace local linger variables
* Use a different, lower HWM for the worker threads
Copy link
Collaborator

@GDYendell GDYendell left a comment

Choose a reason for hiding this comment

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

I think this is good now.

@ndevenish if you have some time to have take a look at this that would be great, but otherwise I think we are just about ready to merge, @JamesOHeaDLS.

@JamesOHeaDLS JamesOHeaDLS merged commit 0af2633 into master Sep 26, 2024
13 checks passed
@JamesOHeaDLS JamesOHeaDLS deleted the multithreaded-fan branch September 26, 2024 09:38
@GDYendell GDYendell mentioned this pull request Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants