Why Is Ruby Multithreading Slow?

Dathan Bennett
Apr 21, 2017 · 6 min read
Thread 1: 0
Thread 1: 1
Thread 1: 2
Thread 1: 3
...
Thread 2: 23
Thread 2: 24
Thread 2: 25
Thread 1: 22
Thread 2: 26Thread 1: 27
Thread 2: 29
Thread 1: 28
Thread 1: 31
Thread 1: 32
Thread 2: 0
Thread 2: 1
Thread 2: 2
Thread 2: 3
Thread 2: 4
Thread 1: 5
Thread 2: 6
Thread 2: 8
Thread 2: 9
Thread 2: 10
Thread 1: 7
Thread 1: 12
Thread 2: 11
Thread 2: 14
Thread 2: 2851
Thread 2: 2852
Thread 2: 2853
Thread 2: 2854
Thread 1: 2850
Thread 1: 2856
Thread 1: 2857
Thread 1: 2858
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
Thread 1: 2859
Thread 1: 2860
Thread 1: 2861
Thread 1: 2862
Thread 1: 2863
Thread 2: 2855
Thread 2: 2865
Thread 2: 2866
Thread 2: 2867
Thread 2: 2868
Thread 2: 2869
2888
2889
Thread 1: 2864
Thread 1: 2871
Thread 2: 40244
Thread 2: 40245
Thread 2: 40246
16642
Thread 2: 40247
Thread 2: 40248
Thread 2: 40249
16640
Thread 2: 40250
Thread 2: 40251
16638
Thread 2: 29149
Thread 2: 29150
Thread 2: 29151
Thread 2: 29152
4370000
4370000
Thread 2: 29153
4371000
Thread 2: 29154
4371000
100
Thread 1: 99801
100
Thread 2: 99802
100
Thread 1: 99803
100
Thread 2: 99804
100
Thread 1: 99805
100
Thread 2: 99806
100
Thread 2: 99808
99
Thread 1: 99807
100
Thread 2: 99809
99
Thread 1: 99810
100
Thread 2: 99811
100
...
Thread 1: 99989
10
Thread 1: 99990
9
Thread 1: 99991
8
Thread 1: 99992
7
Thread 1: 99993
6
Thread 2: 99988
5
Thread 2: 99995
4
Thread 2: 99996
3
Thread 2: 99997
2
Thread 2: 99998
1
Thread 1: 99994
0
Thread 2: 99999
0

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade