-
Notifications
You must be signed in to change notification settings - Fork 7
Benchmarks
Viktor Nikolaiev edited this page Jul 21, 2024
·
8 revisions
To better understand the performance characteristics of Rill, a series of benchmarks were performed on a MacBook Pro M2 Max. Each benchmark is performed against a channel of 100k integers, at different levels of concurrency (1,2,4,8), and with varying amounts of work per iteration:
- A busy loop was used to simulate a CPU-bound workload
- time.Sleep was used to simulate an I/O-bound workload
Additionally, there are two benchmarks that serve as baselines:
- ErrGroup + SetLimit, where a new goroutine is spawned for each channel item
- ErrGroup with fixed number of goroutines (worker pool)
Method | Conc. | 1μs busy loop | 10μs busy loop | 1μs sleep | 10μs sleep | Allocs/op | B/op |
---|---|---|---|---|---|---|---|
ErrGroupWithSetLimit | 1 | 218531833 ns/op | 1146390499 ns/op | 481882764 ns/op | 1569552834 ns/op | 200001 | 5600136 |
ErrGroupWithSetLimit | 2 | 124182653 ns/op | 590644854 ns/op | 293238573 ns/op | 766368792 ns/op | 200007 | 5602990 |
ErrGroupWithSetLimit | 4 | 116164097 ns/op | 347600042 ns/op | 134030745 ns/op | 394443472 ns/op | 200010 | 5605173 |
ErrGroupWithSetLimit | 8 | 116755486 ns/op | 251444742 ns/op | 76061694 ns/op | 218647817 ns/op | 200000 | 5600053 |
ErrGroupWithWorkerPool | 1 | 157628440 ns/op | 1070065542 ns/op | 389682959 ns/op | 1505031126 ns/op | 0 | 41 |
ErrGroupWithWorkerPool | 2 | 98502243 ns/op | 645473250 ns/op | 240243217 ns/op | 740995583 ns/op | 0 | 32 |
ErrGroupWithWorkerPool | 4 | 70661732 ns/op | 369048014 ns/op | 135748313 ns/op | 368215347 ns/op | 0 | 24 |
ErrGroupWithWorkerPool | 8 | 85432523 ns/op | 275167875 ns/op | 70875400 ns/op | 186602958 ns/op | 0 | 29 |
ForEach | 1 | 159580077 ns/op | 1072244042 ns/op | 392763861 ns/op | 1489722917 ns/op | 0 | 68 |
ForEach | 2 | 99347489 ns/op | 644313146 ns/op | 240087758 ns/op | 741440334 ns/op | 0 | 80 |
ForEach | 4 | 71316752 ns/op | 364494652 ns/op | 134345094 ns/op | 369602903 ns/op | 0 | 64 |
ForEach | 8 | 84495190 ns/op | 276267854 ns/op | 68944641 ns/op | 186505736 ns/op | 0 | 29 |
MapAndDrain | 1 | 156800661 ns/op | 1091518834 ns/op | 415814028 ns/op | 1500481500 ns/op | 0 | 27 |
MapAndDrain | 2 | 117838088 ns/op | 659681292 ns/op | 256209625 ns/op | 743612938 ns/op | 0 | 32 |
MapAndDrain | 4 | 96687226 ns/op | 384215639 ns/op | 136647854 ns/op | 370182875 ns/op | 0 | 32 |
MapAndDrain | 8 | 87198372 ns/op | 334040458 ns/op | 79791104 ns/op | 187653424 ns/op | 0 | 34 |
Reduce | 1 | 159801369 ns/op | 1070754041 ns/op | 394507583 ns/op | 1505162625 ns/op | 0 | 27 |
Reduce | 2 | 99016781 ns/op | 641583958 ns/op | 243294933 ns/op | 738433208 ns/op | 0 | 64 |
Reduce | 4 | 71186005 ns/op | 363286431 ns/op | 135991266 ns/op | 370837847 ns/op | 0 | 12 |
Reduce | 8 | 87029161 ns/op | 275286636 ns/op | 69897620 ns/op | 187040451 ns/op | 0 | 16 |