1 00:00:05,800 --> 00:00:08,560 I hope you enjoyed this section on concurrency. 2 00:00:08,830 --> 00:00:13,330 We will now be going over the solution to the assignment for this section. 3 00:00:13,420 --> 00:00:17,740 The question was using Rayon for this solution research. 4 00:00:17,770 --> 00:00:18,850 Rayon join. 5 00:00:19,180 --> 00:00:24,790 Once you have read into rayon, join in the Fibonacci join function of the provided source code. 6 00:00:24,790 --> 00:00:31,450 Create a solution that utilizes rayon join so that we can see a performance enhancement in our Fibonacci 7 00:00:31,450 --> 00:00:32,230 solution. 8 00:00:33,400 --> 00:00:42,340 So once you research rayon join, you took away some information where rayon join takes two closures 9 00:00:42,340 --> 00:00:45,940 and then possibly runs them in parallel. 10 00:00:45,940 --> 00:00:56,950 In this case, they will be ran in parallel and then join is going to return a pair of the results from 11 00:00:56,980 --> 00:00:58,390 those closures. 12 00:00:59,290 --> 00:01:05,860 So we know that we're going to get some values back from the two closures. 13 00:01:05,860 --> 00:01:14,260 So we'll create a tuple that is going to store values A and B and we're going to call Rayon join. 14 00:01:15,640 --> 00:01:19,030 And we know that Rayon join once two closures. 15 00:01:19,030 --> 00:01:25,540 So we'll give it this closure where we're going to call the Fibonacci recursive function. 16 00:01:25,540 --> 00:01:30,940 And in here we're going to pass in N minus one. 17 00:01:31,240 --> 00:01:40,030 And now we know that we need to pass in another closure and this time we will pass in N minus two. 18 00:01:41,620 --> 00:01:49,780 And then simply all we have to do is add A plus B, so now we can run this and we see that in our first 19 00:01:49,780 --> 00:02:00,190 iteration of fib recursive, which is the non parallel ized function, we see that Fibonacci recursive 20 00:02:00,190 --> 00:02:07,780 actually takes a decent bit of time to actually execute because what it's doing is it's creating our 21 00:02:07,780 --> 00:02:14,770 series of numbers for us and it happens to be pretty intensive computation. 22 00:02:14,770 --> 00:02:22,630 So we see we get a really large number here and it took us 18 and one half seconds, but when we ran 23 00:02:22,630 --> 00:02:30,970 it with Range join therefore introducing some parallelism, we were able to knock off a little over 24 00:02:30,970 --> 00:02:35,650 6 seconds and still generate the correct solution. 25 00:02:36,010 --> 00:02:44,230 So hopefully this is an eye opening assignment on how much time can be saved when you introduce some 26 00:02:44,230 --> 00:02:46,810 parallelism into your solutions. 27 00:02:46,810 --> 00:02:52,720 So I hope this assignment was fun for you and I will see you in the next section.