As an example, the default options use 12 sequence bits, allowing 4096 IDs to be generated during a 1 millisecond tick. On a fast enough machine that can actually generate these IDs in less than 1 millisecond, you'd then expect to be able to generate IDs continuously at a rate of 4096 per millisecond, spinwaiting until the start of the next tick after each overflow. However, in reality, I can only generate roughly 320 IDs per millisecond continuously.
A more durable solution is probably to switch to longer ticks, perhaps 10 ms, where the context switching matters less, but that would of course be on consumers. (Changing the default would be breaking.) But maybe the IdGen documentation could at least describe the performance penalty of short ticks together with spinwaiting.
| Method | Job | InvocationCount | UnrollFactor | N | Mean | Error | StdDev | Median |
|------------------------ |----------- |---------------- |------------- |------ |------------------:|-----------------:|------------------:|------------------:|
| SystemThreadingSpinWait | DefaultJob | Default | 16 | 4096 | 30.01 ns | 1.225 ns | 3.434 ns | 29.24 ns |
| ManualSpinWait | DefaultJob | Default | 16 | 4096 | 30.62 ns | 0.645 ns | 1.227 ns | 30.54 ns |
| IdGeneratorCreateId | Job-TRHHUL | 1 | 1 | 4096 | 298,785.71 ns | 1,712.429 ns | 1,518.024 ns | 298,200.00 ns |
| SystemThreadingSpinWait | DefaultJob | Default | 16 | 4097 | 15,446,881.15 ns | 67,378.315 ns | 63,025.718 ns | 15,455,123.44 ns |
| ManualSpinWait | DefaultJob | Default | 16 | 4097 | 1,000,269.71 ns | 108.778 ns | 96.429 ns | 1,000,239.94 ns |
| IdGeneratorCreateId | Job-TRHHUL | 1 | 1 | 4097 | 10,610,806.00 ns | 1,889,663.490 ns | 5,571,715.435 ns | 13,349,950.00 ns |
| SystemThreadingSpinWait | DefaultJob | Default | 16 | 40960 | 136,070,392.11 ns | 2,665,274.841 ns | 2,962,445.923 ns | 136,095,775.00 ns |
| ManualSpinWait | DefaultJob | Default | 16 | 40960 | 9,000,772.81 ns | 141.551 ns | 132.407 ns | 9,000,756.25 ns |
| IdGeneratorCreateId | Job-TRHHUL | 1 | 1 | 40960 | 128,078,597.00 ns | 4,144,345.151 ns | 12,219,695.183 ns | 135,176,300.00 ns |