ByteDance makes Linux kernel reboots faster
Skills:
Linux & CLI70%
Key Takeaways
Explains how ByteDance's proposed Linux kernel patches can reduce kernel reboot time from 500ms to 15ms
Full Transcript
the company behind tech talk bindance proposed few fixes to the linux kernel to improve the speed on which the linux kernel actually reboots i find this fascinating well while this is not really relevant for you on me and uh you know normal engineers it is quite significant to large companies such as ticktock google scale or you know amazon scale you know and so shaving few milli hundred milliseconds can make big big performance to their slas so we've seen this with google like few months back where they improved their linux kernel to reboot faster when you have large amount of ssds because you see the the previous api was synchronous that means you call in an ssd reboot and then you once that reboot go to the next one and reboot and i believe if i'm not mistaken each ssd takes like five seconds to shut down so that really adds up so they moved it to a asynchronous api which obviously significantly improved the reboot process but now we're seeing the same thing with tick tock slightly different but i don't i wanted to discuss this how about jump into it so this comes from phoronx how about we read a blurb and then discuss bindance working to make it faster que exec booting the linux kernel binance as a chinese company behind tick tock has been working on a number of linux kernel optimization a few years and their recent work is for faster k execute rebooting the kernel so if you you might say it's like what is that and that is exactly what the question i have like what is k execute because you see i don't work with the linux kernel and i don't develop that kind of linux kernel but here here is one problem you know when it comes to kernel development and kernel updating like if you want to if you have a linux operating system and you want to update its kernel because you want to stay up to date right with this enhancement new kernel features security so it needs to stay up to date and as a result you need after you apply the new kernel you need to restart it same thing with kernel development if your kernel like you you compile your kernel and it crashed because you had a bug what do you do the kernel is down you have to restart your whole machine and restarting a machine takes time like minutes right especially if you have hardware you have to do this post thing like power on self-test you have to initialize hardware so it takes time so imagine you are a kernel developer and you have to do the restart every single time you crash or every time you have to restart so people invented this thing that's called k execute the kernel execute which is a very clever way you know what it does is basically you take the the new kernel image that you want to load and then you give it the old one and just execute that and when you execute that the operating system will load the new kernel image and then discard the old one without going through the boot sequence processes and doing the hardware initialization you might argue that oh your hardware can put in a weird state but if you can't live with it and you know the consequences that's a huge save time so today right without any of the optimization this takes around 500 milliseconds so that was like a summarization of whatever is being said here right apparently that's not enough for tick-tock it's too slow you might wonder what tech talk is doing i don't know are you updating the kernel every every day that seems like a little bit excessive if you ask me unless they're doing something else with the kernel right or maybe they're using the kernel reboot to reboot their servers and instead of actually applying a new kernel images i don't know so they're planning to optimize this to down to 15 and that is the part that interests me right as an engineer i like to see that part like what do you what did you guys do to optimize that you see when i when i explained the kernel image right the kernel execute i said it takes an image that image by default was designed to be compressed here's one optimization because it's compressed first of all you have to decompress it and in order to decompress it you have to copy it so there is a copying involved and there is decompressing involved and those two things significantly slow down and that contribute to the 500 milliseconds apparently right and if you guys are interested this is their poll request or whatever it's called the commit the proposal so this has come coming from one of by dance developers hanji albert in many time sensitive scenarios we need a shorter time to restart the kernel however in the current k execute fast restore code or that's what it's called today there are many places in the memory copy operation verification of verification so there's a verification as well that i didn't talk about right so apparently we're verifying if the images is that kernel image is actually correct or not so that takes time wouldn't you still need to verify the image regardless even if it's uncompressed i don't know and decompressing the decompression and permission which takes more than 500 milliseconds through the following patch series machine kxs start kernel only takes 50 milliseconds so so here's some more of the patches so four patches in total pretty cool thing right and yeah like a bunch of stuff and guys yeah and guys i absolutely love to cover these things because i learned so much you know i before i read this one news this morning i didn't know even what kernel execute is you know but just reading that it's like wow there is a thing that was designed to solve a problem and that thing is now being optimized to make it even better it just fascinates me i don't know maybe maybe this is just me you know the ground of seems a scheme of things you know it's like shaving half a second of kernel boot you know it's not really matter for me and you you know if i'm gonna upgrade my linux setup i don't care if i can wait an extra second or half a second who cares right but think of scales right tick tock have is being is as popular as ever you know so they have tons of servers so if the a new kernel security patch has come in and they have let's say uh to be to be conservative 100 000 servers 200 000 servers you know definitely more than that you know if they want to apply you know the the security patch to all 200 000 servers let's do the math here so i just did a quick math guys if tick tock assume that they have 200 000 servers and just to be you know conservative they definitely have more than that you know and uh there is a new kernel that they need to update you know there's a new linux kernel security patch origin they have to do it or there's an optimization in the new kernel and they want to load the new kernel using today's method which takes around 500 milliseconds half a second to load a new kernel they are they need 27 hours 28 hours to be specific so yeah 28 hours to update all 200 000 servers and you might say they do it in parallel it's not really serially right it's not you're just not waiting for one server after another to reboot it depends on the script and how they wrote it but if you do it in parallel yeah it's going to be slightly less than that obviously but this really matters for them shaving that from 500 milliseconds down to 15 brings this down to what it's nuts this brings down this to less than an hour so yeah if they implemented this and it's approached by linus travolt then they can bring this reboot sequence to 15 milliseconds they can bring down the 28 hours down to less than an hour and obviously with in parallel it just it's gonna be a few minutes probably to do the entire thing so yeah it really adds up and i just i just love enjoy reading this article and go uh check out the for onyx really i love their content this this is an amazing website that just you know focuses on details you know they try to stay stay objective about the thing itself and discussing this stuff so guys as a summary i think this is i i absolutely love this thing because it it changes the way i think about anything i think i talked about this in another video like the other day right i talked about this video where there's a linux function that have been sitting there for ages you know and someone decided to take a look at the code and improve it yeah just by looking at what is it doing and they took advantage of new cpu architecture and just they improved it by what why three times they made it really fast you know it's just i absolutely love this thing it just changes the way i think when i look at michael and says why am i doing it this way it just opens up you know different avenues for you to think and especially as a back-end engineers where we have we we deal with operating systems right we deal with networking we deal with databases we deal with proxying so any latency really adds up and if you think holistically about this stuff it just changes the way i think and i'm i'm learning ever new things every day yeah it's just fascinating to me this is indeed c back in engineering is an unending beautiful sea of things to learn see you in the next one you guys stay awesome
Original Description
ByteDance, the company behind TikTok is proposing few patches to the linux kernel to make kernel reboots via kexec go from 500ms down to 15 ms saving huge time in updating kernel on thousands of machines. Let us discuss this
0:00 Intro
1:30 Linux Kernel Reboot Options
2:30 how kexec works
4:00 The optimization
5:00 Going through the patch
6:00 Updating Servers at TikTok scale
9:00 Summary
https://www.phoronix.com/news/Bytedance-Faster-Kexec-Reboot
https://lore.kernel.org/lkml/20220725083904.56552-1-huangjie.albert@bytedance.com/
Fundamentals of Networking for Effective Backends udemy course (link redirects to udemy with coupon)
https://network.husseinnasser.com
Fundamentals of Database Engineering udemy course (link redirects to udemy with coupon)
https://database.husseinnasser.com
Introduction to NGINX (link redirects to udemy with coupon)
https://nginx.husseinnasser.com
Python on the Backend (link redirects to udemy with coupon)
https://python.husseinnasser.com
Become a Member on YouTube
https://www.youtube.com/channel/UC_ML5xP23TOWKUcc-oAE_Eg/join
Arabic Software Engineering Channel
https://www.youtube.com/channel/UChWZsjdoRvZ0T9QWZOD6UpA
🔥 Members Only Content
https://www.youtube.com/playlist?list=UUMO_ML5xP23TOWKUcc-oAE_Eg
🏭 Backend Engineering Videos in Order
https://backend.husseinnasser.com
💾 Database Engineering Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQXjD0HOzN7P2tgzu7scWpl2
🎙️Listen to the Backend Engineering Podcast
https://husseinnasser.com/podcast
Gears and tools used on the Channel (affiliates)
🖼️ Slides and Thumbnail Design
Canva
https://partner.canva.com/c/2766475/647168/10068
Stay Awesome,
Hussein
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Hussein Nasser · Hussein Nasser · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Extending ArcObjects (IGeometry) - 01 - Getting Started
Hussein Nasser
Extending ArcObjects (IGeometry) - 02 - The Document, The Map and The Layers
Hussein Nasser
Channel Update - New Book, New Job, New Videos
Hussein Nasser
Learn Programming with VB.NET - 01 - Getting Started
Hussein Nasser
Learn Programming with VB.NET - 02 - Classes and Objects (Part 1)
Hussein Nasser
Learn Programming with VB.NET - 03 - Classes and Objects (Part 2)
Hussein Nasser
Learn Programming with VB.NET - 04 - User Interface
Hussein Nasser
Learn Programming with VB.NET - 05 - By Value v. By Reference
Hussein Nasser
Learn Programming with VB.NET - 06 - Variable size, 32 bit vs 64 bit
Hussein Nasser
Learn Programming with VB.NET - 07 - Conditional Statements
Hussein Nasser
Learn Programming with VB.NET - 08 - Inheritance
Hussein Nasser
Learn Programming with VB.NET - 09 - Strategy Design Pattern
Hussein Nasser
Learn Programming with VB.NET - 10 - How did I learn programming
Hussein Nasser
IGeometry 2016 Retrospective - Channel Update
Hussein Nasser
Javascript by Example - The Vook
Hussein Nasser
Vlog - Keep your servers close and your database closer
Hussein Nasser
Vlog - Client/Server Programming Languages
Hussein Nasser
Javascript By Example L1E01 - Getting Started
Hussein Nasser
Persistent Connections (Pros and Cons)
Hussein Nasser
Javascript By Example L1E02 - Building the Calculator Interface
Hussein Nasser
Happy new Year from IGeometry!
Hussein Nasser
Synchronous v. Asynchronous
Hussein Nasser
Javascript By Example L1E03 - Displaying the Digits on Calculator Screen
Hussein Nasser
Show Your Work. Blog, Vlog, Write, Create and Develop!
Hussein Nasser
Relational Database Atomicity Explained By Example
Hussein Nasser
Javascript By Example L1E04 - Operators, All Clear with Arrow Functions
Hussein Nasser
What Comes First, User Experience or Software Architecture?
Hussein Nasser
Javascript By Example L1E05 - Evaluate the Calculator Expressions with eval
Hussein Nasser
Fastest Way to Learn Programming Language or Technology
Hussein Nasser
Javascript By Example L1E06 - Fix Leading Zero Bug with Conditions
Hussein Nasser
Stateful vs Stateless Applications (Explained by Example)
Hussein Nasser
Javascript By Example L1E07 - Running our Calculator on the Mobile Phone
Hussein Nasser
Advice for New Software Engineers and Developers
Hussein Nasser
Why JSON is so Popular?
Hussein Nasser
Building Scalable Software - SLA, HS, VS
Hussein Nasser
Vlog (Istanbul) - Datacenter Proximity
Hussein Nasser
Should Software Engineers Learn Bleeding-Edge Technologies?
Hussein Nasser
Do Developers Build Bad User Interfaces/Experience?
Hussein Nasser
Learn By Doing.
Hussein Nasser
I Wrote Bad Front-End Code That Broke Chrome
Hussein Nasser
My Story
Hussein Nasser
Vlog - Horizontal vs Vertical Scaling
Hussein Nasser
Can User Experience Help Build Better Rest API?
Hussein Nasser
Reverse engineering Instagram in flight mode
Hussein Nasser
The Benefits of the 3-Tier Architecture (e.g. REST API)
Hussein Nasser
Stateless v. Stateful Architecture (Podcast)
Hussein Nasser
The evolution from virtual machines to containers
Hussein Nasser
Proxy vs. Reverse Proxy (Explained by Example)
Hussein Nasser
Canary Deployment (Explained by Example)
Hussein Nasser
No Excuses
Hussein Nasser
Synchronous vs Asynchronous Applications (Explained by Example)
Hussein Nasser
What is an Asynchronous service?
Hussein Nasser
Difference between Client Polling vs Server Push in Notifications
Hussein Nasser
Software vs. Hardware AdBlockers (Explained by Example)
Hussein Nasser
HTTP Caching with E-Tags - (Explained by Example)
Hussein Nasser
Simple Object Access Protocol Pros and Cons (Explained by Example)
Hussein Nasser
Nodejs Express "Hello, World"
Hussein Nasser
Reverse Engineering Instagram feed
Hussein Nasser
Popup Modal Dialog with Javascript and HTML
Hussein Nasser
MIME and Media Type sniffing explained and the type of attacks it leads to
Hussein Nasser
More on: Linux & CLI
View skill →Related Reads
📰
📰
📰
📰
When `await mutation()` lies: the `{ error }` destructuring that saves your weekend
Dev.to · Michel Faure
Addressing JavaScript Excel Library Flaws: A New Approach to Prevent Data Loss and Ensure Reliability
Dev.to · Pavel Kostromin
Java 26 Is Here, and You Can’t Avoid It Anymore
Medium · Programming
Breaking the Clipboard: Why Copy-Pasting Across Different OS is Still Painful
Dev.to · SimpleDrop-Free&Secure File Sharing
Chapters (7)
Intro
1:30
Linux Kernel Reboot Options
2:30
how kexec works
4:00
The optimization
5:00
Going through the patch
6:00
Updating Servers at TikTok scale
9:00
Summary
🎓
Tutor Explanation
DeepCamp AI