-
Notifications
You must be signed in to change notification settings - Fork 242
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
RangeIntGenerator does not split Range properly #64
Comments
below commit is trying to fix it, could you verify it? |
I fixed your test in this commit: Niklas974@a4a6289 You used a separate RangeIntGenerator for each test, where as in productive use only one RangeIntGenerator is used for all the threads. |
That’s the way cosbench works, each worker will get its segment, when one hits its segment limit, it will wrap back. From: Niklas974 [mailto:notifications@github.com] I fixed your test in this commit: Niklas974/cosbench@a4a6289Niklas974@a4a6289 You used a separate RangeIntGenerator for each test, where as in productive use only one RangeIntGenerator is used for all the threads. — |
Yes, but with 5 workers on a range from 50 to 100, if each asks for 10 values, none of them should get values twice. |
will verify to decide if need enhancement. BTW, should consider how to clarify the difference between range and sequential selector. |
using atomic structure in Range selector is insufficient to avoid race condition, synchronization primitive will be added in object picker to coordinate container and object generators. |
see commit db46e03 |
The RangeIntGenerator is supposed to split the range in to su-ranges for every thread, and return different ints to different threads. So for a range of 100, used by 10 threads, the first thread should get ints 1-10, the second thread should get 11-20, etc…
As there is only one offset pointer (cursor) implemented, this can not work. If threads one, two, three ask in this order, thread one will get "1", thread two will get "12", thread 3 will get "23", etc…
I think the Class can not be implemented properly with the given signature of next(), as one can not be sure that the amount of threads won't change. If the amount of threads given by "int all" changes, all the splitting of the range breaks apart.
Also synchronizing does next() not give best performance. It would be better to use AtomicInt for the pointer (cursor).
The text was updated successfully, but these errors were encountered: