1 00:00:00,480 --> 00:00:03,480 foreign 2 00:00:08,220 --> 00:00:13,740 had a lovely lunch 3 00:00:11,219 --> 00:00:15,480 uh here we're about to hear from huon 4 00:00:13,740 --> 00:00:16,859 who has done work for some very big 5 00:00:15,480 --> 00:00:20,100 names including 6 00:00:16,859 --> 00:00:22,320 Apple Cyro and so on he's going to give 7 00:00:20,100 --> 00:00:24,320 us a talk about 8 00:00:22,320 --> 00:00:27,119 packaging with 9 00:00:24,320 --> 00:00:30,119 serverless for serverless because that 10 00:00:27,119 --> 00:00:32,279 must be easy right we've all done that 11 00:00:30,119 --> 00:00:33,430 all right if you're ready yeah take it 12 00:00:32,279 --> 00:00:36,479 away 13 00:00:33,430 --> 00:00:36,479 [Music] 14 00:00:39,540 --> 00:00:42,480 thank you 15 00:00:40,920 --> 00:00:44,760 you know that nightmare where you're 16 00:00:42,480 --> 00:00:46,440 standing in public speaking in public 17 00:00:44,760 --> 00:00:49,680 and you realize you're not wearing any 18 00:00:46,440 --> 00:00:51,180 clothes at EXO flare we were living in a 19 00:00:49,680 --> 00:00:53,579 bit of a nightmare it was taking 20 00:00:51,180 --> 00:00:56,039 embarrassingly in frustratingly long to 21 00:00:53,579 --> 00:00:57,600 build our artifacts for our AWS 22 00:00:56,039 --> 00:01:00,000 standards 23 00:00:57,600 --> 00:01:02,579 but we woke up and we put our pants on 24 00:01:00,000 --> 00:01:06,420 by adopting the pants build system we 25 00:01:02,579 --> 00:01:06,420 made that process effortless 26 00:01:06,960 --> 00:01:11,520 I'm hewan Wilson and this is Sterling 27 00:01:09,240 --> 00:01:13,740 our Corgi 28 00:01:11,520 --> 00:01:16,260 at the moment I'm working for exoflare 29 00:01:13,740 --> 00:01:18,840 which is a software company trying to 30 00:01:16,260 --> 00:01:21,960 make biosecurity easy so we're reducing 31 00:01:18,840 --> 00:01:24,780 the risk and prosperity of animal 32 00:01:21,960 --> 00:01:26,580 diseases that's what we're trying to do 33 00:01:24,780 --> 00:01:28,560 I'm mostly writing python as a back-end 34 00:01:26,580 --> 00:01:31,619 engineer but I'm also doing front end 35 00:01:28,560 --> 00:01:33,780 I'm doing uh data science and I'm doing 36 00:01:31,619 --> 00:01:36,060 devops 37 00:01:33,780 --> 00:01:37,799 that's a bit of a disclaimer I'm now a 38 00:01:36,060 --> 00:01:40,680 pants maintainer so this talk will be 39 00:01:37,799 --> 00:01:43,020 about this pants build system tool but 40 00:01:40,680 --> 00:01:45,060 when we were evaluating paths to work 41 00:01:43,020 --> 00:01:46,799 out what tools to use I had no 42 00:01:45,060 --> 00:01:49,439 connection to it as part of that 43 00:01:46,799 --> 00:01:51,420 adoption process I found enough bugs 44 00:01:49,439 --> 00:01:54,780 contributed enough fixes that I was 45 00:01:51,420 --> 00:01:57,299 nominated to become a maintainer as well 46 00:01:54,780 --> 00:01:59,700 for exoflare I've worked on compilers 47 00:01:57,299 --> 00:02:04,040 and developer tools at Mozilla and apple 48 00:01:59,700 --> 00:02:04,040 and machine learning at csiro 49 00:02:04,920 --> 00:02:09,899 over the next half an hour we'll remind 50 00:02:06,899 --> 00:02:12,239 ourselves what AWS Lambda and similar 51 00:02:09,899 --> 00:02:14,220 products are are 52 00:02:12,239 --> 00:02:16,200 and we'll work out way Python and 53 00:02:14,220 --> 00:02:17,640 interpreted language needs a build 54 00:02:16,200 --> 00:02:19,500 system 55 00:02:17,640 --> 00:02:21,780 then we'll look at the conventional 56 00:02:19,500 --> 00:02:23,459 wisdom for doing that build system which 57 00:02:21,780 --> 00:02:26,099 is using pip install and we'll see why 58 00:02:23,459 --> 00:02:29,340 it's slow and fiddly 59 00:02:26,099 --> 00:02:32,879 and then I'll talk about the solution we 60 00:02:29,340 --> 00:02:36,060 we really enjoy which is using pads 61 00:02:32,879 --> 00:02:38,099 sound good let's get into it 62 00:02:36,060 --> 00:02:39,660 functions as a service is a bit of a 63 00:02:38,099 --> 00:02:40,739 silly name but it seems to be the 64 00:02:39,660 --> 00:02:43,319 accepted 65 00:02:40,739 --> 00:02:45,540 category name for tools like AWS Lambda 66 00:02:43,319 --> 00:02:47,160 Google Cloud functions 67 00:02:45,540 --> 00:02:50,040 um whatever the other Cloud providers 68 00:02:47,160 --> 00:02:52,800 offer in this space 69 00:02:50,040 --> 00:02:54,120 at exoflare we mostly use AWS so I'm 70 00:02:52,800 --> 00:02:55,739 going to say Lambda throughout the talk 71 00:02:54,120 --> 00:02:57,239 but I think most of the lessons will 72 00:02:55,739 --> 00:02:59,640 apply to the different products I just 73 00:02:57,239 --> 00:03:01,680 can't speak to them personally 74 00:02:59,640 --> 00:03:03,780 so Lambda is effectively a snippet of 75 00:03:01,680 --> 00:03:06,180 code it could be a dozen lines it could 76 00:03:03,780 --> 00:03:07,379 be a dozen megabytes that you upload to 77 00:03:06,180 --> 00:03:09,060 the cloud provider and then they'll 78 00:03:07,379 --> 00:03:10,620 manage sort of invoking it for you and 79 00:03:09,060 --> 00:03:11,700 setting up the interpreters and all that 80 00:03:10,620 --> 00:03:13,920 stuff 81 00:03:11,700 --> 00:03:16,440 we use it for things like cron jobs so 82 00:03:13,920 --> 00:03:18,420 some cleanup that happens every hour 83 00:03:16,440 --> 00:03:19,800 we use it for some event processing and 84 00:03:18,420 --> 00:03:22,620 we use it for integrating with the cloud 85 00:03:19,800 --> 00:03:24,360 provider so when we do our deploy with a 86 00:03:22,620 --> 00:03:26,940 crowd formation we have some custom 87 00:03:24,360 --> 00:03:30,300 resources and AWS makes it easy to back 88 00:03:26,940 --> 00:03:32,760 those custom Resources with lambdas 89 00:03:30,300 --> 00:03:34,620 this talk is about serverless but it's 90 00:03:32,760 --> 00:03:36,300 not saying microservices save the world 91 00:03:34,620 --> 00:03:37,019 or that you should use serverless for 92 00:03:36,300 --> 00:03:39,480 everything 93 00:03:37,019 --> 00:03:41,819 we use Docker images for other things we 94 00:03:39,480 --> 00:03:45,599 only have a few Landers for different 95 00:03:41,819 --> 00:03:48,840 um different uh problems we solve 96 00:03:45,599 --> 00:03:51,180 this talk is about if you are using 97 00:03:48,840 --> 00:03:53,159 Lambda or other serverless offerings 98 00:03:51,180 --> 00:03:54,540 maybe you can learn from the suffering 99 00:03:53,159 --> 00:03:56,720 we went through and the solution we 100 00:03:54,540 --> 00:03:56,720 found 101 00:03:57,540 --> 00:04:00,959 let's make this concrete so here's an 102 00:03:59,459 --> 00:04:03,360 example of a Lambda 103 00:04:00,959 --> 00:04:06,180 the details don't matter too much but it 104 00:04:03,360 --> 00:04:07,860 takes in a bit of Json message then some 105 00:04:06,180 --> 00:04:11,340 string and then we'll return that string 106 00:04:07,860 --> 00:04:13,860 so message hello returns hello 107 00:04:11,340 --> 00:04:15,480 I personally don't like passing Jason 108 00:04:13,860 --> 00:04:17,820 myself I don't want to like check that 109 00:04:15,480 --> 00:04:19,680 the message key exists I don't want to 110 00:04:17,820 --> 00:04:22,680 check that the value is the string 111 00:04:19,680 --> 00:04:24,540 so we Define use one of these libraries 112 00:04:22,680 --> 00:04:27,120 a bit like pedantic that was referenced 113 00:04:24,540 --> 00:04:28,400 in earlier talks that lets us Define the 114 00:04:27,120 --> 00:04:31,440 structures 115 00:04:28,400 --> 00:04:32,880 more declaratively 116 00:04:31,440 --> 00:04:34,680 the last piece this is a Handler 117 00:04:32,880 --> 00:04:36,180 function so this is what AWS will invoke 118 00:04:34,680 --> 00:04:37,380 to actually get our Lander to do its 119 00:04:36,180 --> 00:04:39,000 thing 120 00:04:37,380 --> 00:04:41,639 the details of that don't matter too 121 00:04:39,000 --> 00:04:43,800 much but what does matter is that this 122 00:04:41,639 --> 00:04:45,360 message spec Library so the the thing 123 00:04:43,800 --> 00:04:47,880 I'm using for manipulating the Json 124 00:04:45,360 --> 00:04:49,139 that's an external Library it's from Pi 125 00:04:47,880 --> 00:04:50,759 Pi 126 00:04:49,139 --> 00:04:53,100 when we have an external Library we need 127 00:04:50,759 --> 00:04:55,440 to specify our dependency somehow so we 128 00:04:53,100 --> 00:04:57,840 could use pipeproject.tomel we could use 129 00:04:55,440 --> 00:04:58,919 a pip file but we'll keep it simple for 130 00:04:57,840 --> 00:05:01,139 these examples and just use 131 00:04:58,919 --> 00:05:03,139 requirements.txt 132 00:05:01,139 --> 00:05:05,220 so this defines our Lambda we've got 133 00:05:03,139 --> 00:05:06,419 requirements.txt with our message spec 134 00:05:05,220 --> 00:05:09,860 dependency 135 00:05:06,419 --> 00:05:09,860 and we've got our actual source code 136 00:05:10,259 --> 00:05:13,860 sounds pretty good and we can 137 00:05:11,940 --> 00:05:15,600 hypothetically get this into AWS somehow 138 00:05:13,860 --> 00:05:19,100 and invoke it and it would give the 139 00:05:15,600 --> 00:05:19,100 right behavior in theory 140 00:05:19,680 --> 00:05:24,840 but you'll notice that the the way to 141 00:05:22,500 --> 00:05:27,479 get into AWS is either a Docker image 142 00:05:24,840 --> 00:05:29,160 which has some downsides or zip files 143 00:05:27,479 --> 00:05:31,440 we use zip files so that's what I'm 144 00:05:29,160 --> 00:05:33,120 going to talk about in this talk 145 00:05:31,440 --> 00:05:35,940 the zip file has to have a particular 146 00:05:33,120 --> 00:05:37,620 format so the format has to be 147 00:05:35,940 --> 00:05:39,419 of course our source code has to be in 148 00:05:37,620 --> 00:05:42,900 there somehow so we've got Echo dot Pi 149 00:05:39,419 --> 00:05:44,400 in our echo.zip for our Echo Lambda 150 00:05:42,900 --> 00:05:46,620 and 151 00:05:44,400 --> 00:05:48,600 we have to include all of the source 152 00:05:46,620 --> 00:05:50,820 code of the dependencies so our 153 00:05:48,600 --> 00:05:51,960 echolanda uses the message spec 154 00:05:50,820 --> 00:05:53,699 dependency 155 00:05:51,960 --> 00:05:55,500 and thus we need to include its source 156 00:05:53,699 --> 00:05:57,120 code 157 00:05:55,500 --> 00:05:59,220 this is why we need a build system for 158 00:05:57,120 --> 00:06:01,340 python so what we had in our repository 159 00:05:59,220 --> 00:06:03,780 that was Echo dot pi and 160 00:06:01,340 --> 00:06:05,759 requirements.txt that's different to 161 00:06:03,780 --> 00:06:08,340 what goes in the zip file so we need 162 00:06:05,759 --> 00:06:12,360 some sort of a system for building a zip 163 00:06:08,340 --> 00:06:14,460 file that has the right format 164 00:06:12,360 --> 00:06:17,100 suppose we have a system then we get a 165 00:06:14,460 --> 00:06:19,440 zip file and we can upload that to AWS 166 00:06:17,100 --> 00:06:20,699 somehow so we could use the console we 167 00:06:19,440 --> 00:06:23,100 could use the command line interface we 168 00:06:20,699 --> 00:06:24,479 could use terraform we could use cdk 169 00:06:23,100 --> 00:06:27,000 there's all sorts of tools that will let 170 00:06:24,479 --> 00:06:29,039 us take code on our disk and put it into 171 00:06:27,000 --> 00:06:30,720 the into the cloud but that's not the 172 00:06:29,039 --> 00:06:32,699 focus of this talk the focus of this 173 00:06:30,720 --> 00:06:35,100 talk is turning our source code in our 174 00:06:32,699 --> 00:06:38,960 repository into a zip file ready to 175 00:06:35,100 --> 00:06:38,960 upload into the cloud provider 176 00:06:40,039 --> 00:06:45,360 if we look through the AWS documentation 177 00:06:42,660 --> 00:06:47,759 we can work out a system for doing this 178 00:06:45,360 --> 00:06:50,039 so this is a script up to still down 179 00:06:47,759 --> 00:06:53,100 first we go pip install our requirements 180 00:06:50,039 --> 00:06:54,720 into the the package folder then we can 181 00:06:53,100 --> 00:06:57,300 copy in our own source code so copy 182 00:06:54,720 --> 00:06:59,280 echo.pi into that folder and then at the 183 00:06:57,300 --> 00:07:01,020 end we zip it all up this gives us 184 00:06:59,280 --> 00:07:02,880 echo.zip 185 00:07:01,020 --> 00:07:05,100 if we were to look into this ZIP file 186 00:07:02,880 --> 00:07:08,520 just like with our normal computer 187 00:07:05,100 --> 00:07:10,979 investigation skills we could 188 00:07:08,520 --> 00:07:12,419 notice that it has basically the format 189 00:07:10,979 --> 00:07:14,220 that we were just discussing so we'll 190 00:07:12,419 --> 00:07:15,660 have our echo.pi in it and it will have 191 00:07:14,220 --> 00:07:18,600 the source code of the message spec 192 00:07:15,660 --> 00:07:21,300 dependency in it too 193 00:07:18,600 --> 00:07:23,819 that's uploaded to AWS let's invoke it 194 00:07:21,300 --> 00:07:25,860 and oh we get an error 195 00:07:23,819 --> 00:07:27,120 no module named massive respect dot 196 00:07:25,860 --> 00:07:28,740 underscore core 197 00:07:27,120 --> 00:07:30,479 that's a bit weird because when we look 198 00:07:28,740 --> 00:07:33,300 in the zip file there is a file that 199 00:07:30,479 --> 00:07:35,220 looks pretty related message back flash 200 00:07:33,300 --> 00:07:37,860 underscore core 201 00:07:35,220 --> 00:07:39,360 that that sounds like it matches up 202 00:07:37,860 --> 00:07:41,639 but a bit further in the file name it 203 00:07:39,360 --> 00:07:44,699 says Darwin Darwin's another name for 204 00:07:41,639 --> 00:07:46,440 the Mac OS operating system 205 00:07:44,699 --> 00:07:48,660 Lambda is running the Linux operating 206 00:07:46,440 --> 00:07:50,759 system so when I ran these commands this 207 00:07:48,660 --> 00:07:52,560 pip install the build script 208 00:07:50,759 --> 00:07:55,220 on my Mac machine 209 00:07:52,560 --> 00:07:57,660 it shows code that is specific to Mac 210 00:07:55,220 --> 00:07:59,759 and that won't work in Lambda 211 00:07:57,660 --> 00:08:01,560 understandably the Lambda python 212 00:07:59,759 --> 00:08:03,780 interpreter is ignoring this module 213 00:08:01,560 --> 00:08:07,520 doesn't want to try and run Mac specific 214 00:08:03,780 --> 00:08:07,520 code on the wrong operating system 215 00:08:08,160 --> 00:08:13,080 okay well we can fix this using Docker 216 00:08:11,099 --> 00:08:15,259 Docker for Mac makes it really easy to 217 00:08:13,080 --> 00:08:17,819 run Linux 218 00:08:15,259 --> 00:08:19,020 virtual machines commands on Linux while 219 00:08:17,819 --> 00:08:21,060 on Mac 220 00:08:19,020 --> 00:08:23,639 so we can go Docker run some arguments 221 00:08:21,060 --> 00:08:25,979 to get our source code in so choosing an 222 00:08:23,639 --> 00:08:29,520 image one provided by AWS seems pretty 223 00:08:25,979 --> 00:08:31,440 plausible use our script if we run this 224 00:08:29,520 --> 00:08:34,500 we get out another zip file we get our 225 00:08:31,440 --> 00:08:37,320 echo.zip version two I guess 226 00:08:34,500 --> 00:08:39,419 when we upload this to AWS and we invoke 227 00:08:37,320 --> 00:08:41,580 this we get 228 00:08:39,419 --> 00:08:43,140 the same error 229 00:08:41,580 --> 00:08:44,760 but we know where to look now message 230 00:08:43,140 --> 00:08:47,160 spec slash underscore call blah blah 231 00:08:44,760 --> 00:08:48,360 Linux so we've got the right operating 232 00:08:47,160 --> 00:08:51,660 system 233 00:08:48,360 --> 00:08:55,140 but it says Ah 64. that's a reference to 234 00:08:51,660 --> 00:08:57,200 the arm CPU architecture 235 00:08:55,140 --> 00:09:00,899 lambdas at least by default will run 236 00:08:57,200 --> 00:09:02,880 x8664 or Intel CPU so we've fixed our 237 00:09:00,899 --> 00:09:05,940 operating system mismatch 238 00:09:02,880 --> 00:09:08,279 but we still have a CPU mismatch 239 00:09:05,940 --> 00:09:10,440 the fix is easy enough we had yet 240 00:09:08,279 --> 00:09:13,200 another argument to our Docker command 241 00:09:10,440 --> 00:09:15,060 We Run The build we upload to AWS we 242 00:09:13,200 --> 00:09:16,860 invoke it and we're Victorious we 243 00:09:15,060 --> 00:09:19,019 finally have a working Lambda so we 244 00:09:16,860 --> 00:09:20,399 invoke it with message hello we get back 245 00:09:19,019 --> 00:09:22,980 hello 246 00:09:20,399 --> 00:09:24,600 very cool we now have somewhat of a 247 00:09:22,980 --> 00:09:26,040 build system we could probably make it a 248 00:09:24,600 --> 00:09:28,620 bit more General if we wanted to to 249 00:09:26,040 --> 00:09:30,240 actually be a system but we've got 250 00:09:28,620 --> 00:09:33,660 something that can produce functional 251 00:09:30,240 --> 00:09:35,399 zip files that work in Lambda 252 00:09:33,660 --> 00:09:36,600 unfortunately functional is just the 253 00:09:35,399 --> 00:09:39,120 minimum Bar for a build system 254 00:09:36,600 --> 00:09:42,300 performance is important too 255 00:09:39,120 --> 00:09:43,980 no one wants a slow build right 256 00:09:42,300 --> 00:09:46,260 this is the performance of the three 257 00:09:43,980 --> 00:09:48,060 different steps we ran so if you say 258 00:09:46,260 --> 00:09:50,760 that running natively on my Mac the very 259 00:09:48,060 --> 00:09:52,260 first thing we did I about half a second 260 00:09:50,760 --> 00:09:54,839 but it gave us a zip file that didn't 261 00:09:52,260 --> 00:09:57,420 work so it's just taunting us 262 00:09:54,839 --> 00:09:59,640 running on the arm docker took three 263 00:09:57,420 --> 00:10:01,560 times longer but again it's taunting us 264 00:09:59,640 --> 00:10:03,300 because the zip file doesn't work to 265 00:10:01,560 --> 00:10:04,740 actually get a working zip that gave us 266 00:10:03,300 --> 00:10:06,600 a working Lambda 267 00:10:04,740 --> 00:10:08,160 takes us five seconds 268 00:10:06,600 --> 00:10:10,620 this is because it's having to run a 269 00:10:08,160 --> 00:10:14,600 virtual machine that's emulating the CPU 270 00:10:10,620 --> 00:10:14,600 this comes with significant overhead 271 00:10:14,880 --> 00:10:20,839 five seconds would be tolerable if it 272 00:10:17,040 --> 00:10:20,839 was only five seconds but it gets worse 273 00:10:21,180 --> 00:10:24,720 imagine we're heading a second Lambda so 274 00:10:22,860 --> 00:10:26,700 a feature request has come in that we 275 00:10:24,720 --> 00:10:29,760 need to do some reporting that reporting 276 00:10:26,700 --> 00:10:31,620 is generating a plot so let's add we 277 00:10:29,760 --> 00:10:33,420 start with our echo.pi and we've got our 278 00:10:31,620 --> 00:10:36,060 requirement subtext let's add a new file 279 00:10:33,420 --> 00:10:37,980 plot.pi we're generating a plot so we'll 280 00:10:36,060 --> 00:10:40,200 import matplotlib 281 00:10:37,980 --> 00:10:44,100 another library from Pi Pi that is 282 00:10:40,200 --> 00:10:46,079 helpful for generating plots in the name 283 00:10:44,100 --> 00:10:47,640 it's from Pi Pi so we better add it as a 284 00:10:46,079 --> 00:10:48,720 requirement 285 00:10:47,640 --> 00:10:50,760 um 286 00:10:48,720 --> 00:10:52,860 so this is now our pair of lambdas we've 287 00:10:50,760 --> 00:10:55,440 got echo.pi for our Echo Lambda we've 288 00:10:52,860 --> 00:10:56,820 got plot.pi for our plot Lambda and 289 00:10:55,440 --> 00:10:58,500 we've got the requirements required for 290 00:10:56,820 --> 00:11:00,720 both of them 291 00:10:58,500 --> 00:11:03,180 we can tweak our build system to also be 292 00:11:00,720 --> 00:11:06,560 able to build the plot Lambda and look 293 00:11:03,180 --> 00:11:06,560 at its performance 294 00:11:06,660 --> 00:11:10,140 it's got far worse 295 00:11:08,339 --> 00:11:12,420 running natively on Macs that's as fast 296 00:11:10,140 --> 00:11:14,160 as we can go it takes about seven and a 297 00:11:12,420 --> 00:11:16,800 half seconds 298 00:11:14,160 --> 00:11:19,459 but to get a zip file that works because 299 00:11:16,800 --> 00:11:22,980 this plot Lambda has exactly the same 300 00:11:19,459 --> 00:11:24,959 platform dependent code issue 301 00:11:22,980 --> 00:11:27,240 to get a zip file that works it takes 302 00:11:24,959 --> 00:11:29,459 100 seconds 303 00:11:27,240 --> 00:11:32,040 that's a very long time and no one wants 304 00:11:29,459 --> 00:11:34,079 to wait for a build that long 305 00:11:32,040 --> 00:11:35,519 why is this one so much slower so our 306 00:11:34,079 --> 00:11:36,899 Echo Lander used to build in five 307 00:11:35,519 --> 00:11:40,200 seconds this one builds in 100 seconds 308 00:11:36,899 --> 00:11:42,420 well the plot Lambda is using matplotlib 309 00:11:40,200 --> 00:11:44,940 matplotlib refers to other labs 310 00:11:42,420 --> 00:11:46,740 libraries like numpy 311 00:11:44,940 --> 00:11:49,560 what this means is that the final zip 312 00:11:46,740 --> 00:11:51,899 package is almost 50 megabytes 313 00:11:49,560 --> 00:11:54,480 for the echolanda that we had before 314 00:11:51,899 --> 00:11:55,680 it was like 200 kilobytes that is a huge 315 00:11:54,480 --> 00:11:57,180 amount larger 316 00:11:55,680 --> 00:11:59,279 manipulating all that extra data is 317 00:11:57,180 --> 00:12:02,000 going to take extra time and we can see 318 00:11:59,279 --> 00:12:02,000 it on this graph 319 00:12:02,040 --> 00:12:05,220 this graph is nominally about the plot 320 00:12:03,959 --> 00:12:07,019 Lambda 321 00:12:05,220 --> 00:12:09,240 but it's actually 322 00:12:07,019 --> 00:12:11,279 by adding the new dependency to our 323 00:12:09,240 --> 00:12:13,980 requirements file we've made the 324 00:12:11,279 --> 00:12:16,260 echolanda really slow too 325 00:12:13,980 --> 00:12:18,300 when we build the echolanda we installed 326 00:12:16,260 --> 00:12:19,800 the requirements from this file so we 327 00:12:18,300 --> 00:12:21,240 installed message spec that's what the 328 00:12:19,800 --> 00:12:23,760 echolanda needs 329 00:12:21,240 --> 00:12:25,740 but we also install matplotlib 330 00:12:23,760 --> 00:12:27,720 even though the echo Lambda doesn't need 331 00:12:25,740 --> 00:12:30,180 map 332 00:12:27,720 --> 00:12:32,220 so we spend 100 seconds manipulating 333 00:12:30,180 --> 00:12:34,140 installing matplotlib 334 00:12:32,220 --> 00:12:37,200 for no reason 335 00:12:34,140 --> 00:12:39,480 not only that but the echolanda zip file 336 00:12:37,200 --> 00:12:41,279 went from 200 kilobytes to almost 50 337 00:12:39,480 --> 00:12:43,800 megabytes 338 00:12:41,279 --> 00:12:46,680 how large is it means slower uploads to 339 00:12:43,800 --> 00:12:48,420 AWS and it also means slower cold starts 340 00:12:46,680 --> 00:12:51,240 so when a Lambda starts for the first 341 00:12:48,420 --> 00:12:53,100 time it has to initialize their the 342 00:12:51,240 --> 00:12:56,339 system and that takes longer when you 343 00:12:53,100 --> 00:12:59,519 have a larger deployment package 344 00:12:56,339 --> 00:13:01,139 so preferably we're not we would prefer 345 00:12:59,519 --> 00:13:03,300 not to be spending 100 seconds building 346 00:13:01,139 --> 00:13:04,500 Echo pointlessly and we would probably 347 00:13:03,300 --> 00:13:07,500 also prefer not to be spending 100 348 00:13:04,500 --> 00:13:09,480 seconds building the plot Lambda 349 00:13:07,500 --> 00:13:11,639 we can solve one of those problems by 350 00:13:09,480 --> 00:13:14,339 splitting our requirements so on the 351 00:13:11,639 --> 00:13:17,339 left we've got our echolanda and we 352 00:13:14,339 --> 00:13:18,839 could have our Echo dot Pi file plus the 353 00:13:17,339 --> 00:13:20,579 requirements that that file made 354 00:13:18,839 --> 00:13:22,860 specifically 355 00:13:20,579 --> 00:13:24,360 and on the right we have our plot Lander 356 00:13:22,860 --> 00:13:25,920 and the requirements plot needs 357 00:13:24,360 --> 00:13:28,920 specifically 358 00:13:25,920 --> 00:13:30,839 if we do this now the echo Lambda will 359 00:13:28,920 --> 00:13:32,100 be back to building in five seconds 360 00:13:30,839 --> 00:13:33,839 the plot land will still take 100 361 00:13:32,100 --> 00:13:35,220 seconds to build but like at least with 362 00:13:33,839 --> 00:13:38,040 half the time that the total build 363 00:13:35,220 --> 00:13:40,200 process will take 364 00:13:38,040 --> 00:13:41,700 this can work 365 00:13:40,200 --> 00:13:43,560 but it gets harder as soon as we start 366 00:13:41,700 --> 00:13:45,959 trying to share code so imagine we 367 00:13:43,560 --> 00:13:47,579 wanted to do logging in the same way 368 00:13:45,959 --> 00:13:52,139 from both lambdas 369 00:13:47,579 --> 00:13:54,060 so we have some logs.pi utilities 370 00:13:52,139 --> 00:13:55,440 and in particular we want to do 371 00:13:54,060 --> 00:13:59,519 structured logging 372 00:13:55,440 --> 00:14:01,260 so log stop Pi Imports strap lock 373 00:13:59,519 --> 00:14:02,820 struck log is yet another library from 374 00:14:01,260 --> 00:14:04,380 Pi Pi 375 00:14:02,820 --> 00:14:05,459 so we better make sure it's installed in 376 00:14:04,380 --> 00:14:07,560 the lambdas 377 00:14:05,459 --> 00:14:09,839 if it's not included in the Lambda zip 378 00:14:07,560 --> 00:14:12,839 file then Echo dot Pi will import 379 00:14:09,839 --> 00:14:14,700 logs.pi logs.pi tries to import struck 380 00:14:12,839 --> 00:14:16,740 log struct log isn't available and the 381 00:14:14,700 --> 00:14:18,300 Lambda crashes 382 00:14:16,740 --> 00:14:21,180 one way to do this would be to remember 383 00:14:18,300 --> 00:14:23,220 which lambdas we need to which lambdas 384 00:14:21,180 --> 00:14:25,800 are using logs.pi and go and add it to 385 00:14:23,220 --> 00:14:28,079 all of those requirements 386 00:14:25,800 --> 00:14:30,779 but whenever we say remember and expect 387 00:14:28,079 --> 00:14:32,220 humans to do it that's always a losing 388 00:14:30,779 --> 00:14:33,600 proposition it's easy for us to forget 389 00:14:32,220 --> 00:14:35,639 to do something 390 00:14:33,600 --> 00:14:40,100 like if we hadn't added it to the echo 391 00:14:35,639 --> 00:14:40,100 requirements then Echo would crash 392 00:14:40,800 --> 00:14:44,519 this is fiddly this is annoying and it's 393 00:14:43,260 --> 00:14:46,199 still not solving the problem with the 394 00:14:44,519 --> 00:14:47,579 virtual machines 395 00:14:46,199 --> 00:14:49,199 there's other ways to solve this problem 396 00:14:47,579 --> 00:14:50,639 too like you could have sort of a shared 397 00:14:49,199 --> 00:14:52,860 set of requirements so you have your 398 00:14:50,639 --> 00:14:54,180 logs.pi with its own requirements and 399 00:14:52,860 --> 00:14:55,800 then when you build the echo land you 400 00:14:54,180 --> 00:14:58,800 install the shared requirements and the 401 00:14:55,800 --> 00:15:00,060 requirements specific to to Echo and 402 00:14:58,800 --> 00:15:02,760 that's basically what we were doing at 403 00:15:00,060 --> 00:15:06,380 exoflare but even that is fiddly and 404 00:15:02,760 --> 00:15:06,380 definitely doesn't spark Joy 405 00:15:06,779 --> 00:15:10,560 so we've looked through the conventional 406 00:15:08,519 --> 00:15:15,120 wisdom and we've looked at it in detail 407 00:15:10,560 --> 00:15:17,040 there's tools like AWS cdk offers sort 408 00:15:15,120 --> 00:15:19,320 of Packaging 409 00:15:17,040 --> 00:15:20,820 um for python where it can wrap up this 410 00:15:19,320 --> 00:15:22,380 process but under the hood it's 411 00:15:20,820 --> 00:15:23,880 basically doing the same thing last time 412 00:15:22,380 --> 00:15:25,920 I checked it was still using Docker to 413 00:15:23,880 --> 00:15:28,199 run pip install 414 00:15:25,920 --> 00:15:30,600 the impact of this is our cross-platform 415 00:15:28,199 --> 00:15:33,060 builds are really slow 416 00:15:30,600 --> 00:15:34,680 and when we have multiple lambdas with 417 00:15:33,060 --> 00:15:36,839 different dependencies 418 00:15:34,680 --> 00:15:39,000 we can either end up with unnecessarily 419 00:15:36,839 --> 00:15:40,740 slow builds and unnecessarily huge Zips 420 00:15:39,000 --> 00:15:42,000 if we include dependencies a Lambda 421 00:15:40,740 --> 00:15:44,339 doesn't need 422 00:15:42,000 --> 00:15:46,019 or we end up with a world of really 423 00:15:44,339 --> 00:15:48,000 fiddly dependency management and having 424 00:15:46,019 --> 00:15:49,680 to remember to update to updates 10 425 00:15:48,000 --> 00:15:51,720 different files whenever we make a 426 00:15:49,680 --> 00:15:53,519 change 427 00:15:51,720 --> 00:15:55,620 at EXO flight we were trying to optimize 428 00:15:53,519 --> 00:15:58,440 our build times with that fiddly 429 00:15:55,620 --> 00:15:59,519 approach but we still had so it took us 430 00:15:58,440 --> 00:16:02,339 three minutes to build our 431 00:15:59,519 --> 00:16:04,079 infrastructure before deploying and 432 00:16:02,339 --> 00:16:06,240 worth when we were trying to test it 433 00:16:04,079 --> 00:16:07,680 locally it'll take five minutes to test 434 00:16:06,240 --> 00:16:11,300 our infrastructure 435 00:16:07,680 --> 00:16:11,300 that is not very pleasant 436 00:16:11,579 --> 00:16:16,440 so we looked around for Solutions and we 437 00:16:14,100 --> 00:16:18,839 settled on the pants tool bills itself 438 00:16:16,440 --> 00:16:20,699 is the economic build system and that 439 00:16:18,839 --> 00:16:23,339 seems to be true so we use it for things 440 00:16:20,699 --> 00:16:25,740 like running tests running code linting 441 00:16:23,339 --> 00:16:28,380 running code formatting but most 442 00:16:25,740 --> 00:16:30,600 importantly building artifacts so pants 443 00:16:28,380 --> 00:16:33,120 is the build tool we use for turning our 444 00:16:30,600 --> 00:16:36,060 source code into zip files ready to 445 00:16:33,120 --> 00:16:38,160 upload to AWS 446 00:16:36,060 --> 00:16:39,360 as we're adopting pants and evaluating 447 00:16:38,160 --> 00:16:42,320 different tools we of course ask 448 00:16:39,360 --> 00:16:45,180 questions like what tools are available 449 00:16:42,320 --> 00:16:46,980 how do we use these tools and how do we 450 00:16:45,180 --> 00:16:48,959 adopt them incrementally to start seeing 451 00:16:46,980 --> 00:16:51,180 benefits earlier 452 00:16:48,959 --> 00:16:52,320 but we then asked Howard Sterling wear 453 00:16:51,180 --> 00:16:54,600 pants 454 00:16:52,320 --> 00:16:56,279 my wife thinks number three I reckon 455 00:16:54,600 --> 00:16:59,420 number seven but I'm told that those are 456 00:16:56,279 --> 00:16:59,420 overalls not the paths 457 00:17:04,319 --> 00:17:08,339 but more seriously we asked what 458 00:17:06,240 --> 00:17:10,199 performance Improvement would we see so 459 00:17:08,339 --> 00:17:11,819 this is the examples we had the example 460 00:17:10,199 --> 00:17:13,799 lambdas we had before 461 00:17:11,819 --> 00:17:15,720 it would take five seconds to build the 462 00:17:13,799 --> 00:17:18,000 echolanda using docker 463 00:17:15,720 --> 00:17:19,079 with pants takes two seconds that's a 464 00:17:18,000 --> 00:17:21,540 nice speed up 465 00:17:19,079 --> 00:17:23,400 but more significantly the plot Lambda 466 00:17:21,540 --> 00:17:24,480 will take 100 seconds to build with 467 00:17:23,400 --> 00:17:26,400 docker 468 00:17:24,480 --> 00:17:28,799 it now takes less than eight 469 00:17:26,400 --> 00:17:30,540 that's a huge speed up 470 00:17:28,799 --> 00:17:32,640 most of that hundred seconds is spent 471 00:17:30,540 --> 00:17:35,760 manipulating dependencies 472 00:17:32,640 --> 00:17:37,799 many playing Matlock modifying numpy 473 00:17:35,760 --> 00:17:39,299 pants is able to do this natively 474 00:17:37,799 --> 00:17:41,340 without having to run in a virtual 475 00:17:39,299 --> 00:17:44,220 machine and without having to run and 476 00:17:41,340 --> 00:17:46,020 without having to emulate the CPU 477 00:17:44,220 --> 00:17:47,700 so we're not having to we're able to run 478 00:17:46,020 --> 00:17:50,400 natively on Mac and see that really fast 479 00:17:47,700 --> 00:17:52,500 performance instead of having to um run 480 00:17:50,400 --> 00:17:54,240 virtual machines 481 00:17:52,500 --> 00:17:55,860 as I said this was mostly manipulating 482 00:17:54,240 --> 00:17:57,240 dependencies so let's look at that in a 483 00:17:55,860 --> 00:18:00,720 bit more detail 484 00:17:57,240 --> 00:18:03,660 here's the pipei page for message spec 485 00:18:00,720 --> 00:18:05,400 on the left there's a download files tab 486 00:18:03,660 --> 00:18:06,960 when you click on that you see a long 487 00:18:05,400 --> 00:18:08,580 list of files it starts with Source 488 00:18:06,960 --> 00:18:12,600 distribution and then there's a long 489 00:18:08,580 --> 00:18:15,000 list of Wheels dot WHL files 490 00:18:12,600 --> 00:18:17,640 when you run pip install these are the 491 00:18:15,000 --> 00:18:19,500 files that pip can choose from so when I 492 00:18:17,640 --> 00:18:21,419 ran a pip install on my Mac it would 493 00:18:19,500 --> 00:18:24,419 actually choose this wheel where it says 494 00:18:21,419 --> 00:18:26,460 something about Mac OS arm 64. 495 00:18:24,419 --> 00:18:27,720 this is 496 00:18:26,460 --> 00:18:29,760 this whale includes the 497 00:18:27,720 --> 00:18:31,740 platform-specific code that was causing 498 00:18:29,760 --> 00:18:33,179 problems at the very start so this is 499 00:18:31,740 --> 00:18:35,100 the this is where we're getting that 500 00:18:33,179 --> 00:18:37,799 Darwin file from 501 00:18:35,100 --> 00:18:39,600 the fix and what we need to be doing is 502 00:18:37,799 --> 00:18:42,000 actually choosing this wheel at the top 503 00:18:39,600 --> 00:18:45,120 so Lambda is running on Linux and 504 00:18:42,000 --> 00:18:47,940 running the x86 64 CPU 505 00:18:45,120 --> 00:18:49,679 so we need to choose the appropriate 506 00:18:47,940 --> 00:18:52,620 wheel the one that has the platform 507 00:18:49,679 --> 00:18:54,360 specific code for that platform 508 00:18:52,620 --> 00:18:56,820 as far as I know the only way to pick 509 00:18:54,360 --> 00:18:58,260 convince pip to choose a particular 510 00:18:56,820 --> 00:18:59,760 wheel is to be running on the matching 511 00:18:58,260 --> 00:19:01,080 platform that's why we had to have a 512 00:18:59,760 --> 00:19:02,880 virtual machine so that we can pretend 513 00:19:01,080 --> 00:19:07,260 to be Linux that's why we had to have 514 00:19:02,880 --> 00:19:09,960 the x8664 CPU emulation so that we can 515 00:19:07,260 --> 00:19:13,200 pretend to be matching that CPU 516 00:19:09,960 --> 00:19:15,539 the magic of pants via the related PEX 517 00:19:13,200 --> 00:19:16,799 project is that it understands the 518 00:19:15,539 --> 00:19:18,539 difference between the computer we're 519 00:19:16,799 --> 00:19:20,100 currently running on and the target 520 00:19:18,539 --> 00:19:22,679 environment 521 00:19:20,100 --> 00:19:25,559 so we're targeting Lambda that's Linux 522 00:19:22,679 --> 00:19:28,080 that's x8664. 523 00:19:25,559 --> 00:19:29,760 we can choose the appropriate zip and 524 00:19:28,080 --> 00:19:31,440 mash that up into the appropriate format 525 00:19:29,760 --> 00:19:34,140 even if we're not running on that 526 00:19:31,440 --> 00:19:36,299 platform so we can still run on Mac but 527 00:19:34,140 --> 00:19:38,100 we choose this ZIP and then 528 00:19:36,299 --> 00:19:39,660 turn it into the appropriate zip file 529 00:19:38,100 --> 00:19:41,520 for AWS 530 00:19:39,660 --> 00:19:43,200 this is why pants is able to run those 531 00:19:41,520 --> 00:19:44,400 builds so much faster because there's 532 00:19:43,200 --> 00:19:48,380 none of that overhead of virtual 533 00:19:44,400 --> 00:19:48,380 machines or CPU emulation 534 00:19:49,320 --> 00:19:53,940 sounds good how do we adopt pants let's 535 00:19:51,780 --> 00:19:55,440 go back to the the simplest version of 536 00:19:53,940 --> 00:19:57,419 the two lambdas that we had where we had 537 00:19:55,440 --> 00:19:59,460 our Echo dot pi and we had our plot.pi 538 00:19:57,419 --> 00:20:02,160 with our source code and then a single 539 00:19:59,460 --> 00:20:04,260 requirements file that contains all the 540 00:20:02,160 --> 00:20:06,600 requirements required 541 00:20:04,260 --> 00:20:08,820 to start using it we first add a pants 542 00:20:06,600 --> 00:20:10,200 dot tummel which specifies some Global 543 00:20:08,820 --> 00:20:11,700 configuration like with Japan's version 544 00:20:10,200 --> 00:20:13,980 we're using 545 00:20:11,700 --> 00:20:16,140 and we also add a build file 546 00:20:13,980 --> 00:20:18,120 the build file basically tells pants 547 00:20:16,140 --> 00:20:20,160 like here's my source code here's what 548 00:20:18,120 --> 00:20:21,780 you should be paying attention to 549 00:20:20,160 --> 00:20:23,700 so we need to say two things we say 550 00:20:21,780 --> 00:20:26,400 python requirements which will pick up 551 00:20:23,700 --> 00:20:28,500 our requirements.txt file and say python 552 00:20:26,400 --> 00:20:30,299 sources which will pick up the two dot 553 00:20:28,500 --> 00:20:31,799 Pi files 554 00:20:30,299 --> 00:20:33,720 once we've done this we've now told 555 00:20:31,799 --> 00:20:36,240 pants about our python code and in 556 00:20:33,720 --> 00:20:37,620 theory if we had any tests we could run 557 00:20:36,240 --> 00:20:39,240 those tests 558 00:20:37,620 --> 00:20:41,280 but we don't care about tests what we 559 00:20:39,240 --> 00:20:43,320 care about is building Landers 560 00:20:41,280 --> 00:20:45,120 to do that we activate the built-in 561 00:20:43,320 --> 00:20:47,160 Lambda back end 562 00:20:45,120 --> 00:20:48,780 and then we Define the two lambdas we 563 00:20:47,160 --> 00:20:52,679 want build 564 00:20:48,780 --> 00:20:54,000 so these the configuration is a little 565 00:20:52,679 --> 00:20:56,340 bit overwhelming here but like it's 566 00:20:54,000 --> 00:20:58,080 simple enough we say it's python AWS 567 00:20:56,340 --> 00:21:00,240 Lambda function we need to configure two 568 00:20:58,080 --> 00:21:02,220 things we need to give it a name so Echo 569 00:21:00,240 --> 00:21:04,620 for the echo Lambda and we also need to 570 00:21:02,220 --> 00:21:05,880 tell parents where to find the Handler 571 00:21:04,620 --> 00:21:07,799 function 572 00:21:05,880 --> 00:21:10,620 so to handle the function is in Echo dot 573 00:21:07,799 --> 00:21:12,299 pi and it's called Handler 574 00:21:10,620 --> 00:21:15,179 we need to do the same configuration for 575 00:21:12,299 --> 00:21:18,299 plot so we say call a plot find the 576 00:21:15,179 --> 00:21:20,700 Handler function in plot.pi please 577 00:21:18,299 --> 00:21:21,900 this is enough to Define our lambdas so 578 00:21:20,700 --> 00:21:23,039 we haven't had to write any shell 579 00:21:21,900 --> 00:21:26,100 scripts we haven't had to fiddle around 580 00:21:23,039 --> 00:21:27,600 with docker and this is indeed the Dozen 581 00:21:26,100 --> 00:21:29,760 lines of configuration that I was using 582 00:21:27,600 --> 00:21:31,679 to run those performance benchmarks we 583 00:21:29,760 --> 00:21:34,340 mentioned we saw before we're driven off 584 00:21:31,679 --> 00:21:34,340 this configuration 585 00:21:34,740 --> 00:21:39,240 to actually do the build we run one 586 00:21:36,720 --> 00:21:40,740 command to package colon colon 587 00:21:39,240 --> 00:21:42,059 when we do this it takes about eight 588 00:21:40,740 --> 00:21:43,140 seconds there's some streaming output 589 00:21:42,059 --> 00:21:45,120 I've trimmed it down to what's 590 00:21:43,140 --> 00:21:46,799 interesting let's walk through it step 591 00:21:45,120 --> 00:21:48,600 by step 592 00:21:46,799 --> 00:21:50,580 first we can say we make the minimum Bar 593 00:21:48,600 --> 00:21:52,440 for a build system it's functional it's 594 00:21:50,580 --> 00:21:54,659 produced our two zip files so we've got 595 00:21:52,440 --> 00:21:57,000 echo.zip got plot.zip we can upload 596 00:21:54,659 --> 00:22:00,000 those those to AWS and 597 00:21:57,000 --> 00:22:01,760 we've got working lambdas 598 00:22:00,000 --> 00:22:03,659 foreign 599 00:22:01,760 --> 00:22:05,340 there's something that was missing from 600 00:22:03,659 --> 00:22:06,900 the configuration on the previous slide 601 00:22:05,340 --> 00:22:08,340 we didn't have to say anything about 602 00:22:06,900 --> 00:22:10,559 message spec we didn't have to say that 603 00:22:08,340 --> 00:22:13,100 Echo uses message spec we didn't have to 604 00:22:10,559 --> 00:22:15,720 say that the plot Lambda uses matplotlib 605 00:22:13,100 --> 00:22:18,120 what pants has done is it's inferred the 606 00:22:15,720 --> 00:22:20,820 dependencies so it actually looks at our 607 00:22:18,120 --> 00:22:24,059 echo.pi file and observes it as an 608 00:22:20,820 --> 00:22:25,559 import message spec lying in there it 609 00:22:24,059 --> 00:22:28,919 understands this is a reference to our 610 00:22:25,559 --> 00:22:32,220 requirements so it knows that that's it 611 00:22:28,919 --> 00:22:34,140 to run the echo dot Pi file you'll need 612 00:22:32,220 --> 00:22:36,240 to have message spec available and thus 613 00:22:34,140 --> 00:22:38,220 when we build the echo Lambda 614 00:22:36,240 --> 00:22:41,340 pants make sure to include the message 615 00:22:38,220 --> 00:22:42,960 spec library in that Lambda 616 00:22:41,340 --> 00:22:44,880 there's no other import statements in 617 00:22:42,960 --> 00:22:47,640 that file there's no input matplotlib so 618 00:22:44,880 --> 00:22:49,799 matplotlib doesn't need to be included 619 00:22:47,640 --> 00:22:51,360 buff dependency inference means that our 620 00:22:49,799 --> 00:22:53,640 Lambda is automatically including only 621 00:22:51,360 --> 00:22:54,960 the dependencies that it actually needs 622 00:22:53,640 --> 00:22:56,460 we're solving that problem of 623 00:22:54,960 --> 00:22:57,960 accidentally having larger builds than 624 00:22:56,460 --> 00:22:59,640 necessary 625 00:22:57,960 --> 00:23:01,620 the same process applies for the plot 626 00:22:59,640 --> 00:23:03,059 Lambda so pants has looked into the 627 00:23:01,620 --> 00:23:05,400 plot.pi file and observed that 628 00:23:03,059 --> 00:23:08,780 matplotlib is imported therefore it 629 00:23:05,400 --> 00:23:08,780 better be included in the Lambda 630 00:23:10,380 --> 00:23:14,220 let's talk about performance because 631 00:23:12,000 --> 00:23:16,559 performance is the the next bar or above 632 00:23:14,220 --> 00:23:18,659 functional for a build system 633 00:23:16,559 --> 00:23:21,240 the total build Tech took about eight 634 00:23:18,659 --> 00:23:23,520 seconds and eight seconds is less than 635 00:23:21,240 --> 00:23:25,440 it would take to First build echo which 636 00:23:23,520 --> 00:23:27,360 was two seconds and then build plot 637 00:23:25,440 --> 00:23:28,919 which was also about eight seconds 638 00:23:27,360 --> 00:23:30,240 what's going on here 639 00:23:28,919 --> 00:23:33,299 well instead of building them one by one 640 00:23:30,240 --> 00:23:34,919 it's not going Echo then plot 641 00:23:33,299 --> 00:23:36,780 pants is automatically building these in 642 00:23:34,919 --> 00:23:39,780 parallel so it's building Echo and pants 643 00:23:36,780 --> 00:23:40,740 at the same time Echo M plot at the same 644 00:23:39,780 --> 00:23:41,820 time 645 00:23:40,740 --> 00:23:44,039 um 646 00:23:41,820 --> 00:23:45,900 parallel is nice it doesn't make too 647 00:23:44,039 --> 00:23:50,100 much of a difference for these lambdas 648 00:23:45,900 --> 00:23:52,140 but um it uh 649 00:23:50,100 --> 00:23:53,640 but if you had more it would make a much 650 00:23:52,140 --> 00:23:55,320 bigger difference 651 00:23:53,640 --> 00:23:57,000 when we're talking about performance we 652 00:23:55,320 --> 00:23:58,559 better run things multiple times so if 653 00:23:57,000 --> 00:24:01,020 we run pants package again it gets so 654 00:23:58,559 --> 00:24:03,419 much faster what's going on there 655 00:24:01,020 --> 00:24:05,039 well pants has built-in caching 656 00:24:03,419 --> 00:24:07,020 the first time we ran the package 657 00:24:05,039 --> 00:24:09,659 command we had to run build so we 658 00:24:07,020 --> 00:24:12,000 started with echo.pi and plot.pi 659 00:24:09,659 --> 00:24:13,320 and we built our zip files that will 660 00:24:12,000 --> 00:24:14,940 take two seconds and eight seconds they 661 00:24:13,320 --> 00:24:17,220 run in parallel 662 00:24:14,940 --> 00:24:19,140 when we run it the second time we 663 00:24:17,220 --> 00:24:20,820 haven't changed code we haven't changed 664 00:24:19,140 --> 00:24:22,919 configuration 665 00:24:20,820 --> 00:24:25,140 so instead of having to build the things 666 00:24:22,919 --> 00:24:26,940 again pants understands the inputs are 667 00:24:25,140 --> 00:24:29,580 the same therefore the outputs will be 668 00:24:26,940 --> 00:24:31,320 the same this happens so much quicker 669 00:24:29,580 --> 00:24:32,940 it's just copying files around rather 670 00:24:31,320 --> 00:24:35,820 than having to build like actually do 671 00:24:32,940 --> 00:24:38,159 the expensive build process 672 00:24:35,820 --> 00:24:40,020 this happens in a fine-grained way so if 673 00:24:38,159 --> 00:24:42,120 we had changed echo.pi imagine we'd 674 00:24:40,020 --> 00:24:44,220 added a feature to our Echo Lambda but 675 00:24:42,120 --> 00:24:46,559 we've left plot as it was 676 00:24:44,220 --> 00:24:49,280 when we ran this when we would package 677 00:24:46,559 --> 00:24:49,280 this again 678 00:24:49,860 --> 00:24:53,100 the plot Lander would still be cached 679 00:24:51,480 --> 00:24:54,600 because we haven't changed any code that 680 00:24:53,100 --> 00:24:56,520 affects the plot map 681 00:24:54,600 --> 00:24:58,500 the echolanda has changed so we need to 682 00:24:56,520 --> 00:25:00,960 run that build but now the whole process 683 00:24:58,500 --> 00:25:03,600 takes two seconds and still gives us all 684 00:25:00,960 --> 00:25:05,400 of the zip files that we requested 685 00:25:03,600 --> 00:25:07,080 this caching applies to more than just 686 00:25:05,400 --> 00:25:09,059 building packages so we use it for 687 00:25:07,080 --> 00:25:12,360 testing we use it for linting and the 688 00:25:09,059 --> 00:25:14,039 caching applies to that as well 689 00:25:12,360 --> 00:25:16,440 caching is the first and Panthers 690 00:25:14,039 --> 00:25:18,360 performance Powers so caching means that 691 00:25:16,440 --> 00:25:19,559 pants never really does work that it's 692 00:25:18,360 --> 00:25:22,500 already done 693 00:25:19,559 --> 00:25:25,320 when you when Pants is running a process 694 00:25:22,500 --> 00:25:26,039 it's usually because it has to it's 695 00:25:25,320 --> 00:25:27,840 um 696 00:25:26,039 --> 00:25:29,279 it's new work 697 00:25:27,840 --> 00:25:31,500 the next performance power is 698 00:25:29,279 --> 00:25:33,360 parallelism so when work has to happen 699 00:25:31,500 --> 00:25:35,580 happens in parallel 700 00:25:33,360 --> 00:25:37,620 the third one surprisingly enough is 701 00:25:35,580 --> 00:25:39,059 dependency inference depends the 702 00:25:37,620 --> 00:25:41,039 inference is what ensured that we did 703 00:25:39,059 --> 00:25:42,960 the minimum amount of work possible our 704 00:25:41,039 --> 00:25:45,059 Echo Lambda only included the dependency 705 00:25:42,960 --> 00:25:46,740 it needed to include 706 00:25:45,059 --> 00:25:49,020 the final one which is the one we sold 707 00:25:46,740 --> 00:25:50,460 first is native execution we're not 708 00:25:49,020 --> 00:25:52,320 having to do virtual machines we're not 709 00:25:50,460 --> 00:25:55,020 having to emulate CPUs 710 00:25:52,320 --> 00:25:56,460 so the work that needs to run is run it 711 00:25:55,020 --> 00:25:57,720 runs in parallel 712 00:25:56,460 --> 00:25:59,520 it's the smallest amount of work 713 00:25:57,720 --> 00:26:02,940 possible and it runs as fast as possible 714 00:25:59,520 --> 00:26:05,159 that makes for a happy developer 715 00:26:02,940 --> 00:26:07,380 for our system this is the impact it had 716 00:26:05,159 --> 00:26:09,600 so I remember how I set our builds we're 717 00:26:07,380 --> 00:26:12,840 taking about three minutes before 718 00:26:09,600 --> 00:26:14,279 now they take about 90 seconds and this 719 00:26:12,840 --> 00:26:16,140 is actually happening already on Linux 720 00:26:14,279 --> 00:26:18,059 so this is all because of parallelism 721 00:26:16,140 --> 00:26:20,460 and it's all because of the dependency 722 00:26:18,059 --> 00:26:22,980 inference reducing how much work happens 723 00:26:20,460 --> 00:26:25,140 far more significantly though when we're 724 00:26:22,980 --> 00:26:26,820 testing our infrastructure locally 725 00:26:25,140 --> 00:26:28,500 previously it will take us five and a 726 00:26:26,820 --> 00:26:30,000 half minutes and that's mostly because 727 00:26:28,500 --> 00:26:32,159 we would be building and rebuilding 728 00:26:30,000 --> 00:26:33,360 lambdas pointlessly every time we run 729 00:26:32,159 --> 00:26:35,880 tests 730 00:26:33,360 --> 00:26:37,260 now Panthers caching kicks in so instead 731 00:26:35,880 --> 00:26:39,179 of having to rebuild the land that's 732 00:26:37,260 --> 00:26:41,400 already been built it just gets served 733 00:26:39,179 --> 00:26:43,020 out of the cache thus our tests take 10 734 00:26:41,400 --> 00:26:46,039 seconds instead 735 00:26:43,020 --> 00:26:46,039 that's much more enjoyable 736 00:26:46,679 --> 00:26:50,700 in summary this is about as much 737 00:26:48,480 --> 00:26:52,740 clothing as we could get on Sterling 738 00:26:50,700 --> 00:26:55,020 he's not going to wear pants he barely 739 00:26:52,740 --> 00:26:57,779 tolerates his harness 740 00:26:55,020 --> 00:26:59,940 but actually at exoflare we saw that 741 00:26:57,779 --> 00:27:01,860 when we adopted pants using it for 742 00:26:59,940 --> 00:27:03,659 building lambdas it dramatically reduced 743 00:27:01,860 --> 00:27:05,700 our build times and our test times for 744 00:27:03,659 --> 00:27:08,520 our infrastructure as well as keeping 745 00:27:05,700 --> 00:27:10,919 our configuration really simple 746 00:27:08,520 --> 00:27:12,480 EXO flare has a strong open source 747 00:27:10,919 --> 00:27:15,120 mindset and understands how important it 748 00:27:12,480 --> 00:27:17,159 is such as me contributing to 749 00:27:15,120 --> 00:27:18,480 um pants as well as paying for our 750 00:27:17,159 --> 00:27:21,059 dependencies 751 00:27:18,480 --> 00:27:23,279 and where please come and talk to me if 752 00:27:21,059 --> 00:27:25,380 you're interested in biosecurity if 753 00:27:23,279 --> 00:27:27,120 you're looking for a job 754 00:27:25,380 --> 00:27:28,320 um and just generally if you want to 755 00:27:27,120 --> 00:27:30,179 have a chat 756 00:27:28,320 --> 00:27:32,820 the code examples and some more links 757 00:27:30,179 --> 00:27:35,720 are available in this Repository 758 00:27:32,820 --> 00:27:35,720 thank you very much 759 00:27:40,080 --> 00:27:43,740 unfortunately we haven't got enough time 760 00:27:42,120 --> 00:27:45,480 for questions but I'm sure you can find 761 00:27:43,740 --> 00:27:46,919 you on out and about in the conference 762 00:27:45,480 --> 00:27:48,600 if you have any further questions on the 763 00:27:46,919 --> 00:27:50,159 topic yeah please chase me if you have 764 00:27:48,600 --> 00:27:51,380 questions uh thank you we get the 765 00:27:50,159 --> 00:27:53,760 speakers 766 00:27:51,380 --> 00:27:55,940 thank you thank you guys thank you very 767 00:27:53,760 --> 00:27:55,940 much