-
-
Notifications
You must be signed in to change notification settings - Fork 148
IdGen configuration of sequences exhausted within timeslot #24
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
Conversation
|
@RobThree Did you had any chance to look at this one? Do you have any opinions? (I'm just wondering if there is anything I can change or if you believe the idea itself is flawed). |
|
Hmm, this issue has escaped my attention. Sorry about that. Have you seen #21 ? I'm not a big fan of spinlocking. I don't think the idea is flawed and spinlocks do have their use but I'm not sure I agree with the implementation. |
|
Thanks for getting back to this! Thanks in any case! |
|
Just, out of curiosity: how often do you (expect to) run into a sequenceoverflow and can't you mitigate it by adjusting the MaskConfig? If you're running into a sequenceoverflow that is kind of a sign you need more bits for the sequence. Yes, spinwaiting is an option, and I'll consider how to implement it, but the better option, in my humble opinion, is to 'sacrifice' one or a few generator bits (whenever possible ofcourse). Each bit added to the sequence part doubles the amount of id's you can generate within a tick at the cost of halving the number of generators. Do you really need 1024 generators? Adding one or a few bits to the sequence part (again, whenever possible) means you don't even have to (spin)wait and waste precious CPU cycles and just generate another id. Again, just asking, curiosity. |
|
Correct - proper bits allocation is allways a key. Generally: Spinning has the advantage of not seeing the errors later down the road in the production, but of course there can be scenarios where it can silently cripple the calling code. So I fully understand your hesitance. If it would be one or the other, then exceptions are likely better ('fail fast'). I'm maybe thinking about injectable logic handling the sequnces overflow (then by default the code can throw allways, but one would have an option to wait but lets say throw if blocking longer or more often). I'm really not sure :-) The more I think about it, the more I start to think we should just wrap the try method in our code and move enumerating and waiting there :-) |
I was thinking something similar. I'm thinking along the lines of an
If you're in a hurry then go ahead. But if you're not, then let me think about this for a bit longer and I'm sure we can work something out. |
…eSource and new MockAutoIncrementingIntervalTimeSource to new namespace. Added spinwait to configuration. Added a bunch of constructor overloads. Upped versions.
|
Hi @jakrivan , I have implemented the spinwaiting (see dd03e48) but took a little bit of a different approach.
Besides that I also added the spinwait option to the configuration package (so now you can add a I have published a new release and NuGet package. I hope you don't mind I haven't used your PR. |
|
Thanks @RobThree for the prompt implementation and release of this! I appreciate your cooperation and efforts! And definitely no hard feelings about not using this PR ;-) |
Enable consumers to configure whether they want to receive exceptions on exhausted Ids or be blocked until new timeslot is available