Open
Conversation
This performs much better than the stack of worker-records, while accomplishing the same goal. ringbuf_register() can still be called in this variant, i.e. it allows for both permanent registration of worker-records as well as temporary registration. I think the version-number in the first-used/free-worker indices are unnecessary if both indices are tracked; I also realize that the use of a first-used-worker index interferes with mixed permanent and temporary registration, but then the version-number in the worker-indices must be kept. Both variants will be tried in further commits.
worker-record registration.
becomes optional, i.e. it's OK if some other thread advances the index. This should be slightly faster, i.e. less reasons to retry. Also modified the stress-test to print the number of bytes transmitted, and the number of bytes each thread tried to transmit.
e87e03b to
c3f19e6
Compare
This makes externally-registered workers more resilient to crashed clients. Now ringbuf_get_sizes() and ringbuf_setup() take a separate count of "temporary" worker-records. These are allocated during a single acquire/produce, if no registered worker-record is provided.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This accomplishes the same thing that my worker-stack change tried to do, but far more efficiently, plus you can mix permanent and temporary worker-record registration. Also, according to my tests, there seems to be no change in performance.
There's a small bug-fix in the makefile. Without it, the test/stress executables can't be debugged. Trying to view variables in gdb usually results in "<optimized out>". My memory was that later flags provided to gcc override the settings in earlier flags, but that doesn't seem to be true any more. The fix was easy.
ringbuf_worker.registered is now a 64-bit field, but because that struct already had a 64-bit field, there wasn't any change in struct size. Besides, this keeps me from having to implement another compare-and-swap function.
ringbuf.first_free_worker doesn't have to be exact; the intention is to minimize the number of records that have to be searched when registering another worker. This is especially important when using lots of temporary worker-registrations.
I modified t_stress so that one of the worker-records is registered permanently, just to demonstrate that mixing permanent & temporary registration works. I also had it print the total number of bytes received, to make it easy to determine whether new features have performance implications.
The rest of the changes should be easy to understand.