Skip to content
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

WIP: rustc changes #489

Closed
wants to merge 25 commits into from
Closed

WIP: rustc changes #489

wants to merge 25 commits into from

Conversation

Zoxc
Copy link

@Zoxc Zoxc commented Dec 9, 2017

This has quite a few changes to rayon_core in order to make it suitable for parallelizing rustc. The primary new feature is that jobs are run inside fibers. This enables rayon to schedule jobs whose dependencies form a DAG. I'm just creating this PR for feedback from humans and bots alike.

@Zoxc
Copy link
Author

Zoxc commented Dec 9, 2017

Here are some benchmark results:

 name                                                                rayon-clean-bench.txt ns/iter  rayon-fiber-bench.txt ns/iter  diff ns/iter   diff %  speedup
 factorial::factorial_iterator                                       22,399,665                     22,321,592                          -78,073   -0.35%   x 1.00
 factorial::factorial_join                                           2,593,948                      2,803,390                           209,442    8.07%   x 0.93
 factorial::factorial_par_iter                                       2,575,755                      2,813,521                           237,766    9.23%   x 0.92
 factorial::factorial_recursion                                      4,047,136                      4,511,196                           464,060   11.47%   x 0.90
 fibonacci::fibonacci_iterative                                      20                             17                                       -3  -15.00%   x 1.18
 fibonacci::fibonacci_join_1_2                                       14,413,148                     18,402,901                        3,989,753   27.68%   x 0.78
 fibonacci::fibonacci_join_2_1                                       13,724,342                     15,385,930                        1,661,588   12.11%   x 0.89
 fibonacci::fibonacci_recursive                                      12,417,793                     13,154,612                          736,819    5.93%   x 0.94
 fibonacci::fibonacci_split_iterative                                65,798                         96,373                               30,575   46.47%   x 0.68
 fibonacci::fibonacci_split_recursive                                1,364,287                      1,201,926                          -162,361  -11.90%   x 1.14
 find::size1::parallel_find_common                                   11,752                         13,287                                1,535   13.06%   x 0.88
 find::size1::parallel_find_first                                    11,142                         12,052                                  910    8.17%   x 0.92
 find::size1::parallel_find_last                                     1,024,048                      1,105,404                            81,356    7.94%   x 0.93
 find::size1::parallel_find_middle                                   661,020                        812,754                             151,734   22.95%   x 0.81
 find::size1::parallel_find_missing                                  1,211,531                      1,273,480                            61,949    5.11%   x 0.95
 find::size1::serial_find_common                                     3,888                          4,213                                   325    8.36%   x 0.92
 find::size1::serial_find_first                                      1                              1                                         0    0.00%   x 1.00
 find::size1::serial_find_last                                       4,192,219                      4,404,414                           212,195    5.06%   x 0.95
 find::size1::serial_find_middle                                     2,788,343                      2,965,717                           177,374    6.36%   x 0.94
 find::size1::serial_find_missing                                    4,267,146                      4,505,280                           238,134    5.58%   x 0.95
 join_microbench::increment_all                                      62,929                         77,909                               14,980   23.80%   x 0.81
 join_microbench::increment_all_atomized                             692,990                        795,728                             102,738   14.83%   x 0.87
 join_microbench::increment_all_max                                  79,430                         93,632                               14,202   17.88%   x 0.85
 join_microbench::increment_all_min                                  31,314                         35,095                                3,781   12.07%   x 0.89
 join_microbench::increment_all_serialized                           20,860                         22,175                                1,315    6.30%   x 0.94
 join_microbench::join_recursively                                   280,197                        335,280                              55,083   19.66%   x 0.84
 life::bench::generations                                            80,677,390                     92,585,333                       11,907,943   14.76%   x 0.87
 life::bench::parallel_generations                                   50,212,588                     51,601,006                        1,388,418    2.77%   x 0.97
 map_collect::i_mod_10_to_i::with_collect                            8,804,383                      9,877,996                         1,073,613   12.19%   x 0.89
 map_collect::i_mod_10_to_i::with_fold                               1,198,361                      1,281,820                            83,459    6.96%   x 0.93
 map_collect::i_mod_10_to_i::with_fold_vec                           1,874,612                      1,606,393                          -268,219  -14.31%   x 1.17
 map_collect::i_mod_10_to_i::with_linked_list_collect                15,656,022                     16,990,066                        1,334,044    8.52%   x 0.92
 map_collect::i_mod_10_to_i::with_linked_list_collect_vec            7,222,886                      7,413,246                           190,360    2.64%   x 0.97
 map_collect::i_mod_10_to_i::with_linked_list_collect_vec_sized      8,791,816                      10,050,078                        1,258,262   14.31%   x 0.87
 map_collect::i_mod_10_to_i::with_linked_list_map_reduce_vec_sized   8,670,825                      9,800,625                         1,129,800   13.03%   x 0.88
 map_collect::i_mod_10_to_i::with_mutex                              82,165,323                     87,266,255                        5,100,932    6.21%   x 0.94
 map_collect::i_mod_10_to_i::with_mutex_vec                          11,772,623                     11,927,606                          154,983    1.32%   x 0.99
 map_collect::i_mod_10_to_i::with_vec_vec_sized                      8,185,819                      9,677,343                         1,491,524   18.22%   x 0.85
 map_collect::i_to_i::with_collect                                   21,009,605                     21,517,370                          507,765    2.42%   x 0.98
 map_collect::i_to_i::with_fold                                      55,762,739                     58,824,611                        3,061,872    5.49%   x 0.95
 map_collect::i_to_i::with_fold_vec                                  54,795,668                     57,526,303                        2,730,635    4.98%   x 0.95
 map_collect::i_to_i::with_linked_list_collect                       32,399,798                     35,519,465                        3,119,667    9.63%   x 0.91
 map_collect::i_to_i::with_linked_list_collect_vec                   35,026,166                     37,033,832                        2,007,666    5.73%   x 0.95
 map_collect::i_to_i::with_linked_list_collect_vec_sized             21,317,827                     21,791,599                          473,772    2.22%   x 0.98
 map_collect::i_to_i::with_linked_list_map_reduce_vec_sized          21,415,564                     21,135,965                         -279,599   -1.31%   x 1.01
 map_collect::i_to_i::with_mutex                                     173,135,133                    178,814,516                       5,679,383    3.28%   x 0.97
 map_collect::i_to_i::with_mutex_vec                                 68,614,977                     66,383,796                       -2,231,181   -3.25%   x 1.03
 map_collect::i_to_i::with_vec_vec_sized                             20,928,899                     20,583,744                         -345,155   -1.65%   x 1.02
 matmul::bench::bench_matmul_strassen                                5,754,189                      2,404,784                        -3,349,405  -58.21%   x 2.39
 mergesort::bench::merge_sort_par_bench                              4,603,375                      4,530,176                           -73,199   -1.59%   x 1.02
 mergesort::bench::merge_sort_seq_bench                              26,040,330                     27,682,972                        1,642,642    6.31%   x 0.94
 nbody::bench::nbody_par                                             2,500,819                      2,690,137                           189,318    7.57%   x 0.93
 nbody::bench::nbody_parreduce                                       6,904,012                      6,930,446                            26,434    0.38%   x 1.00
 nbody::bench::nbody_seq                                             19,758,148                     21,355,752                        1,597,604    8.09%   x 0.93
 pythagoras::euclid_faux_serial                                      29,489,079                     31,942,783                        2,453,704    8.32%   x 0.92
 pythagoras::euclid_parallel_full                                    14,493,752                     18,065,543                        3,571,791   24.64%   x 0.80
 pythagoras::euclid_parallel_one                                     3,137,466                      3,238,220                           100,754    3.21%   x 0.97
 pythagoras::euclid_parallel_outer                                   3,048,125                      3,168,201                           120,076    3.94%   x 0.96
 pythagoras::euclid_parallel_weightless                              3,141,039                      3,232,081                            91,042    2.90%   x 0.97
 pythagoras::euclid_serial                                           28,869,659                     30,557,169                        1,687,510    5.85%   x 0.94
 quicksort::bench::quick_sort_par_bench                              9,150,462                      8,909,284                          -241,178   -2.64%   x 1.03
 quicksort::bench::quick_sort_seq_bench                              41,964,119                     43,447,161                        1,483,042    3.53%   x 0.97
 quicksort::bench::quick_sort_splitter                               9,090,309                      9,194,936                           104,627    1.15%   x 0.99
 sieve::bench::sieve_chunks                                          5,888,551                      5,826,756                           -61,795   -1.05%   x 1.01
 sieve::bench::sieve_parallel                                        2,912,420                      2,852,207                           -60,213   -2.07%   x 1.02
 sieve::bench::sieve_serial                                          6,603,946                      6,585,137                           -18,809   -0.28%   x 1.00
 sort::demo_merge_sort_ascending                                     346,418 (1154 MB/s)            337,550 (1185 MB/s)                  -8,868   -2.56%   x 1.03
 sort::demo_merge_sort_big                                           9,027,915 (708 MB/s)           8,365,168 (765 MB/s)               -662,747   -7.34%   x 1.08
 sort::demo_merge_sort_descending                                    293,264 (1363 MB/s)            301,434 (1326 MB/s)                   8,170    2.79%   x 0.97
 sort::demo_merge_sort_mostly_ascending                              519,357 (770 MB/s)             489,804 (816 MB/s)                  -29,553   -5.69%   x 1.06
 sort::demo_merge_sort_mostly_descending                             535,500 (746 MB/s)             507,794 (787 MB/s)                  -27,706   -5.17%   x 1.05
 sort::demo_merge_sort_random                                        1,392,064 (287 MB/s)           1,342,388 (297 MB/s)                -49,676   -3.57%   x 1.04
 sort::demo_merge_sort_strings                                       4,108,726 (194 MB/s)           3,735,221 (214 MB/s)               -373,505   -9.09%   x 1.10
 sort::demo_quick_sort_big                                           6,643,136 (963 MB/s)           6,321,423 (1012 MB/s)              -321,713   -4.84%   x 1.05
 sort::demo_quick_sort_mostly_ascending                              16,407,375 (24 MB/s)           16,110,678 (24 MB/s)               -296,697   -1.81%   x 1.02
 sort::demo_quick_sort_mostly_descending                             15,823,042 (25 MB/s)           16,375,264 (24 MB/s)                552,222    3.49%   x 0.97
 sort::demo_quick_sort_random                                        1,171,152 (341 MB/s)           1,173,089 (340 MB/s)                  1,937    0.17%   x 1.00
 sort::demo_quick_sort_strings                                       3,483,373 (229 MB/s)           3,381,909 (236 MB/s)               -101,464   -2.91%   x 1.03
 sort::par_sort_ascending                                            91,996 (4348 MB/s)             105,506 (3791 MB/s)                  13,510   14.69%   x 0.87
 sort::par_sort_big                                                  7,433,543 (860 MB/s)           7,269,087 (880 MB/s)               -164,456   -2.21%   x 1.02
 sort::par_sort_descending                                           189,627 (2109 MB/s)            183,939 (2174 MB/s)                  -5,688   -3.00%   x 1.03
 sort::par_sort_expensive                                            17,041,704 (23 MB/s)           17,055,452 (23 MB/s)                 13,748    0.08%   x 1.00
 sort::par_sort_mostly_ascending                                     339,196 (1179 MB/s)            349,094 (1145 MB/s)                   9,898    2.92%   x 0.97
 sort::par_sort_mostly_descending                                    385,999 (1036 MB/s)            388,430 (1029 MB/s)                   2,431    0.63%   x 0.99
 sort::par_sort_random                                               539,798 (741 MB/s)             562,414 (711 MB/s)                   22,616    4.19%   x 0.96
 sort::par_sort_strings                                              1,336,527 (598 MB/s)           1,348,488 (593 MB/s)                 11,961    0.89%   x 0.99
 sort::par_sort_unstable_ascending                                   38,930 (10274 MB/s)            40,862 (9789 MB/s)                    1,932    4.96%   x 0.95
 sort::par_sort_unstable_big                                         4,687,638 (1365 MB/s)          4,546,214 (1407 MB/s)              -141,424   -3.02%   x 1.03
 sort::par_sort_unstable_descending                                  55,118 (7257 MB/s)             56,621 (7064 MB/s)                    1,503    2.73%   x 0.97
 sort::par_sort_unstable_expensive                                   38,770,996 (10 MB/s)           39,525,461 (10 MB/s)                754,465    1.95%   x 0.98
 sort::par_sort_unstable_mostly_ascending                            272,204 (1469 MB/s)            266,294 (1502 MB/s)                  -5,910   -2.17%   x 1.02
 sort::par_sort_unstable_mostly_descending                           256,747 (1557 MB/s)            250,801 (1594 MB/s)                  -5,946   -2.32%   x 1.02
 sort::par_sort_unstable_random                                      376,548 (1062 MB/s)            362,628 (1103 MB/s)                 -13,920   -3.70%   x 1.04
 sort::par_sort_unstable_strings                                     2,334,098 (342 MB/s)           2,266,669 (352 MB/s)                -67,429   -2.89%   x 1.03
 str_split::parallel_space_char                                      315,281                        297,834                             -17,447   -5.53%   x 1.06
 str_split::parallel_space_fn                                        285,633                        336,815                              51,182   17.92%   x 0.85
 str_split::serial_space_char                                        2,185,527                      2,148,662                           -36,865   -1.69%   x 1.02
 str_split::serial_space_fn                                          1,897,986                      1,801,643                           -96,343   -5.08%   x 1.05
 str_split::serial_space_str                                         3,110,390                      2,900,793                          -209,597   -6.74%   x 1.07
 tsp::bench::dj10                                                    22,208,159                     23,252,482                        1,044,323    4.70%   x 0.96
 vec_collect::vec_i::with_collect                                    9,615,565                      9,532,858                           -82,707   -0.86%   x 1.01
 vec_collect::vec_i::with_collect_into                               9,575,280                      9,668,126                            92,846    0.97%   x 0.99
 vec_collect::vec_i::with_collect_into_reused                        510,021                        556,534                              46,513    9.12%   x 0.92
 vec_collect::vec_i::with_fold                                       44,550,817                     42,705,589                       -1,845,228   -4.14%   x 1.04
 vec_collect::vec_i::with_linked_list_collect_vec                    20,623,276                     23,306,548                        2,683,272   13.01%   x 0.88
 vec_collect::vec_i::with_linked_list_collect_vec_sized              13,749,785                     16,340,827                        2,591,042   18.84%   x 0.84
 vec_collect::vec_i::with_linked_list_map_reduce_vec_sized           13,796,602                     13,805,630                            9,028    0.07%   x 1.00
 vec_collect::vec_i::with_vec_vec_sized                              13,960,442                     13,799,919                         -160,523   -1.15%   x 1.01
 vec_collect::vec_i_filtered::with_collect                           13,700,165                     13,953,192                          253,027    1.85%   x 0.98
 vec_collect::vec_i_filtered::with_fold                              42,542,227                     41,956,630                         -585,597   -1.38%   x 1.01
 vec_collect::vec_i_filtered::with_linked_list_collect_vec           20,716,772                     22,806,512                        2,089,740   10.09%   x 0.91
 vec_collect::vec_i_filtered::with_linked_list_collect_vec_sized     13,843,486                     16,307,074                        2,463,588   17.80%   x 0.85
 vec_collect::vec_i_filtered::with_linked_list_map_reduce_vec_sized  13,667,506                     13,903,161                          235,655    1.72%   x 0.98
 vec_collect::vec_i_filtered::with_vec_vec_sized                     13,896,766                     13,881,309                          -15,457   -0.11%   x 1.00

@cuviper
Copy link
Member

cuviper commented Dec 14, 2017

I think #492 broadcast can fill the same role as your main_handler, in a re-usable way. It may even remove the need for scoped thread pools, because the broadcast op doesn't have to be 'static. But maybe there's more to it... this PR is too huge for me to digest right now. 😄

@cuviper
Copy link
Member

cuviper commented Jul 13, 2018

I think this was superceded by #569, which we closed, so I'm closing this too.
Feel free to re-open if that's wrong, but you'll also need a rebase here.

@cuviper cuviper closed this Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants