-
Notifications
You must be signed in to change notification settings - Fork 38
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
improvement(gossip,tar): Work towards improving thread management #145
Conversation
5fa4230
to
f321947
Compare
fcf40c7
to
f321947
Compare
f321947
to
d87361e
Compare
* [ThreadPoolTask] Rename `done` field to `avaialable`, for better clarity in the contexts it's used. * [ThreadPoolTask] Add `awaitAndAcquireFirstAvailableTask` & `blockUntilCompletion` functions, remove `queue` function, replace usages of `queue` and code which would now duplicate the aforementioned additions. * [ThreadPoolTask] Add `result` field for signalling the result of the callback. * [gossip] Make use of `ThreadPoolTask` instead of manually implementing the VerifyMessageTask Task interface details. * [gossip] Add `GOSSIP_VERIFY_PACKET_PARALLEL_TASKS` constant, and use it instead of hardcoding the tasks allocated in `verifyPackets`. * [gossip] Make `verifyPackets` and `processMessages` accept an a shared allocator, and make `run` provide a thread-safe allocator which will only be contended by a maximum of the avilable tasks plus the number of messages processed at the same time. * [tar] Panic on some invalid but possible invariants. * Constify more things that don't need to be mutable.
d87361e
to
3b7b21b
Compare
* Rename `SOCKET_TIMEOUT` to `SOCKET_TIMEOUT_US`, to signify its magnitude is in microseconds. * Remove `recvMmsg` and simplify the timeout logic to simply setting it directly before the loop, and finishing the batch on the first `error.WouldBlock` when the batch isn't empty. * Use `packet_batch` as an actual arraylist instead of as a weird slice.
Re-implement the logic of `run` as a function that returns the handles which can then be joined by the caller. Most usage sites require a bit of thought with respect to the order of operations, so `GossipService.run` remains as a wrapper around the new logic. This also makes it take a `message_allocator`.
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.
looking like a really solid pr nice work - just a few small things
socket_utils comparative benchmarkI conducted many more runs than presented here, but those presented are representative of the general trends I observed, where performance is either equivalent or minimally better, excluding outliers where variance exceeded more than 100 in either (which occurred twice with the old code, and once with the new code). Side note: brief testing indicated that ReleaseFast demonstrates near identical trends. Before socket_utils changes:
After socket_utils changes:
|
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.
lgtm
Starts work towards #119 & #120.
More details in the commits.