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

Worker-record queue #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Worker-record queue #6

wants to merge 5 commits into from

Conversation

ulatekh
Copy link

@ulatekh ulatekh commented Feb 11, 2018

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.

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.
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.
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.
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.

1 participant