Created
December 20, 2015 20:24
-
-
Save ashic/28d5f1d5ab1e3f0af716 to your computer and use it in GitHub Desktop.
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
| 1. Large array (yes, allocate. unmanaged mem can work even better, but ok with managed). | |
| 2. Have a "marker" for each writer and each reader. | |
| 3. Treat array as a circular buffer. Writers write messages and progress write marker. Up to the point where array size isn't filled. | |
| 4. Readers read till there are messages. | |
| 5. Have a reader for each handler. Each handler reads all written messages, but processes those that match criterion (type code, clr type, whatever). | |
| 6. Array entries can be cache aligned (i.e. struct with layout padding to 64B). | |
| Easiest to get running is single producer, multi consumer. Should get 100s of millions per sec on moderately powerfull hardware. | |
| 1PMC can be done pretty much lock free. For multi producers, there are ways to make it lock free (i.e. allocate sections of stretches for | |
| each writer to deal with contention). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment