WSL2: Code faster on the Windows Subsystem for Linux! | Tabs vs Spaces

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi my name is Craig Lowen and I'm here today to talk to you all about the windows subsystem for Linux which we commonly shortened down to WSL specifically we're going to be talking about the latest and greatest feature coming to w cell which is w cell to let set so you run a lot more Linux apps with a hundred percent system call compatibility and lets you run them a lot faster with significantly increased file i/o performance so what exactly is the windows subsystem for Linux anyway well double shell allows you to run your favorite Linux command line tools utilities and applications all directly on Windows they're all totally unmodified and you're running actual l 64 Linux binaries you can even access your windows files from that environment and run Windows executables if you want to learn more about WL in general please check out to our Doc's today we're gonna be focusing on the windows subsystem for Linux 2 which is the latest version what cool new things can you do in w cell 2 well they're the two main features of w cell two are faster file i/o performance and 100% system call compatibility so with faster file i/o performance all of your system calls that go to write reading and writing files will go way faster this means when you're doing things like sudo apt updates adapt install or pip install or NPM install or git clone you'll notice a significant file performance increase in general this will be about 3 to 6 times of performance increase depending on how file i/o intensive the operation you are running is this will also be shown across all of your different distros that are running inside of WL 2 on top of this the second half is system call compatibility with a hundred percent system call compatibility you can run a lot more apps inside Adobe so this means apps such as docker will run as well as fuse and more and with docker you can actually containerize all of your workflows directly in WL 2 so jumping into our first demo let's take a look at exactly how much faster is WSL 2 compared to w sub 1 so on my laptop here I have Windows terminal running on the left side I have WL 2 running in the preview pane and on the right side I have W cell 1 and what we're gonna do is run time sudo apt install Python and we'll first start that off in W cell 1 and we'll run the exact same command in W cell 2 so as they build you'll notice that W cell 2 is a lot faster it's actually about 3 to 6 times faster depending on what you're doing this is something that is dependent on how file i/o intensive the operation that you're running is if you do something like unzipping a tarball you can actually get to about 20 times faster which is a huge improvement you're going to notice this when you do things like su to have to update install which you're going to do all the time as well as git clone and NPM install at the end of the day once these are completed we see that w cell 2 ran this operation in just 14 seconds well W cell 1 took a minute and 24 25 seconds so that's about 5 to 6 times faster which is something that you're sure gonna notice on any file i/o operation that you're gonna do and do so what apps can I now run in w cell to that I couldn't in W cell 1 well in W cell 2 we have 100% system call compatibility which is powered by an actual Linux kernel and so this lets you run a ton of more apps and empower you to do a lot more developer workflows for example you can run docker and do container workflows as well as fuse and more so let's jump into what this actually looks like by taking a look over here on my laptop so I'm in my a boon to distro I'm at my home folder I'm going to go into my view apps folder and take a look at a ghost game so here I have the docker container service running in the backend and I'm going to run sudo docker compose up this is going to start up my containers using docker compose I have two containers that I'm running the first is a view app front-end server so it's serving a web server that is powering a view app front end and the other half is a WebSocket server so this is allowing you to have multiple browser windows that will be talking to each other across the server to have a game that will be played across multiple browser windows so now that the servers have started I can flip on over to take a look at what that looks like once i refresh this we can see that I have some chocolate on left and a reset button if I click this in one browser it will actually play the reset command across both and when I lose this game inside one browser it will lose it in both and this is powered through having those different docker containers talking to each other what's really exciting about this is this is also powered by docker desktop for Windows so the doctor desktop team has added in the latest stable version a new optional component that you can check inside of your settings so if I open up the settings page of my darker desktop for Windows app I see that there's an enable the experimental wl2 based engine option here I can click that and now my docker service is running inside of WL 2 and so I can access that with my W cell app as I showed here or I can open up PowerShell and I can run my daugher commands from here as well like docker image LS and I can see those docker images that I built 27 minutes ago which were the exact ones that I just ran to power this experience let's take a look at how you can use vs code and W Cell together to create an awesome developer environment so jumping back in I'm going to go back into my Linux environment from PowerShell so goodbye and PowerShell will close you down and we're going to run code dot this is going to open up vs code remote vs Code remote is an extension inside of vs code that makes a remote server run in W cell what this means is only the UI is running in Windows everything else is running entirely in Linux so I have my site already open and on the bottom left you can see there's a W cell a boon to option here this shows that you're running in a remote context and if I hover over these files you'll see a Linux file path this is because as we're developing exactly like you would on a Linux machine and when I go and open up my integrated terminal I got access to bash right away so I can start programming as I would in a Linux environment so I'm going to go and CD into my site folder and I'm going to run NPM serve and while running the site not in a container now we're running it locally actually inside of my distro now that it's running there the front end is completed so we'll close that down so we don't need to see it and the other half of this is here in this folder called socket logic and this contains the nodejs half which is the other docker container that we ran that powers the server that communicates among the web sockets to coordinate the experiences across the browsers and we can go and actually debug this app so if we run this in debug mode then we can start the app and we can see that what the debugger is seeing so web socket is ready for connections and here we can reload our app and now we're running with that debugger based inside of Linux and if I open this back up we can actually set breakpoints here so if I go down to this line of code this is just saying if there are we receive a reset reset message from one of our containers or one of the apps that were connected to then we need to reset and so we'll set a breakpoint here and if I close this and I hit reset then we notice that nothing happens this is because it actually paused down here in this debugger the pause is showing that we've hit this breakpoint and you can actually go in and take a look at all the different variables that you have like the message is reset you can take a look at the call stack and just to really prove that we're running on Linux I created an extra variable here called my platform and it says Linux so we're actually running this as a full length process and debugging through it so vs code works really well with the Microsoft edge browser as well with wsl we're running this on localhost so it's all in a highly integrated and highly connected experience you don't have to feel like you're developing on a totally separate machine everything feels like it's under the same box to get wl2 working on your machine the first thing you need to do is make sure you are in the latest version of Windows that supports W cell 2 so to do that it will be generally available in the first half of 2020 if you want to get it right away you can always join the windows insider program and it's available on the fast ring or the slow ring so join any of those make sure you are on the correct build of Windows and then you're ready to start once you have the correct boiled of Windows we're gonna jump on over to my laptop to see what you can do from there so what you need to do is open up the Start menu go turn Windows Features on or off this will show you the optional components dialog box inside of Windows scroll to the bottom and make sure that you have the windows subsystem for linux checked as well as the virtual machine platform option checked once those are both checked you'll need to restart your computer to make sure they're totally installed and from there we're gonna open up a new tab on PowerShell from here you can go w cell - L - V this will list all your distros in a verbose manner so you can see all the distress that I have running as well as what version they are so here I have an alpine distro as a version 1 distro and to convert it over all I need to do is do W cell - - set - version Alpine - - it will convert once it's converted in is complete then I can just run it right away I can run W cell - D will run my Alpine distribution and if I ever want to go back to version 1 then I can run WL - set - version Alpine 1 and this will convert it back right away and if you like W cell so much that you want to make to be sold to your default you can run W cell - - set - default - version 2 and then this will make W cell to your default version so now anytime you install a new distro it will install automatically as a w cell - district we did a lot of work behind the scenes to make W cell 2 possible to fully explain all of the architecture changes that we did first you need to understand the architecture of W cell 1 which is the current version that's widely available W cell 1 we have a translation based approach so we have actual Linux user space binaries that are provided by the maintainer x' like canonical debian openSUSE these are the actual binaries that run and whenever they have a system call like accessing memory or files or network they call down to the W cell translation layer we translate these system calls from a Linux system call to a Windows system call and then that goes down to the Windows NT kernel the NC kernel sends a response back up to our translation layer we translate that back to something that Linux would understand and then the day we've implemented the application binary interface for Linux this worked great because everything ran under the same kernel however there were some challenges Windows and Linux have very different semantics and so this could be complicated especially when these semantics were diametrically opposed from each other in WSL 2 we've moved to a virtualization based approach rather than a translation layer so we have your discharge is all your user space binaries and we've put that inside of a lightweight utility VM this is a VM that is really fast it boots up in under a second and does not hog tons of resources on your machine and we've put a real Linux kernel inside of this this is a kernel that is built by Microsoft maintained by Microsoft and is totally open-source and all the source code is available on github whenever you have a system call from your Linux user space binaries it calls down to this kernel and is immediately responded so this means that you don't have to go through this translation layer which is what leads to 100% system call compatibility and way faster file i/o performance at the end of the day this all runs on the Windows hypervisor layer and to power this VM and we've also included all of your favorite Windows integration features with WSL such as accessing all your windows files and running Windows executables straight from this Linux environment [Music] I prefer spaces to tabs and that's because tabs don't actually have a the notation of how wide or short they have to be and indentations so that's totally done by your IDE so if you open it up in a different IDE it might have a different level of indentation if you use spaces you'll always have the same annotation level if you're using a fixed width font but however I still use the tab key and I just make my editor insert spaces for me thanks for joining us take a look at how you can use the windows subsystem for Linux - to power your Linux development workflows including running containers with docker desktop for Windows using faster file IO perf and making use of that a hundred percent system call compatibility we have a lot more links for you to take a look at if you want to dive deeper into everything W cell you can check out our Doc's learn how to install WL to learn where to file issues watch our blog for newl news and as well you can check out our jost game source code so this is the game that we demo today you can see exactly how we made that possible and you can follow me on Twitter I'm at Craig a Lowen please reach out to me if you have any questions thanks again for watching tab services spaces please like and subscribe and look out for new episodes coming soon
Info
Channel: Microsoft Developer
Views: 173,812
Rating: undefined out of 5
Keywords: Microsoft, Developer, linux, wsl, wsl2, docker, windows, ubuntu, nodejs, vue, vscode
Id: MrZolfGm8Zk
Channel Id: undefined
Length: 13min 43sec (823 seconds)
Published: Thu Mar 12 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.