We ACTUALLY downloaded more RAM

Sdílet
Vložit
  • čas přidán 2. 06. 2024
  • Visit www.squarespace.com/LTT and use offer code LTT for 10% off
    Create your build at www.buildredux.com/linus
    It is no longer just a joke. You can download more RAM! Join us on this foolish escapade to make a system with unholy amounts of memory.
    Original Tweet: tjhorner/status/1...
    Discuss on the forum: linustechtips.com/topic/14098...
    Buy G.SKILL Ripjaws V 16GB (2x8GB) DDR4 3200
    Amazon: geni.us/zpntB
    Newegg: geni.us/NXl4lb
    Buy G.SKILL Trident Z Neo 32GB (2x16GB) DDR4 3600
    Amazon: geni.us/0mPIQ1
    Newegg: geni.us/vky1v7I
    Buy Kingston FURY Renegade 32GB (2x16GB) DDR4 3600
    Amazon: geni.us/zAZ2P5
    Newegg: geni.us/zAZ2P5
    Purchases made through some store links may provide some compensation to Linus Media Group.
    ► GET MERCH: lttstore.com
    ► AFFILIATES, SPONSORS & REFERRALS: lmg.gg/sponsors
    ► PODCAST GEAR: lmg.gg/podcastgear
    ► SUPPORT US ON FLOATPLANE: www.floatplane.com/
    FOLLOW US ELSEWHERE
    ---------------------------------------------------
    Twitter: / linustech
    Facebook: / linustech
    Instagram: / linustech
    TikTok: / linustech
    Twitch: / linustech
    MUSIC CREDIT
    ---------------------------------------------------
    Intro: Laszlo - Supernova
    Video Link: • [Electro] - Laszlo - S...
    iTunes Download Link: itunes.apple.com/us/album/sup...
    Artist Link: / laszlomusic
    Outro: Approaching Nirvana - Sugar High
    Video Link: • Sugar High - Approachi...
    Listen on Spotify: spoti.fi/UxWkUw
    Artist Link: / approachingnirvana
    Intro animation by MBarek Abdelwassaa / mbarek_abdel
    Monitor And Keyboard by vadimmihalkevich / CC BY 4.0 geni.us/PgGWp
    Mechanical RGB Keyboard by BigBrotherECE / CC BY 4.0 geni.us/mj6pHk4
    Mouse Gamer free Model By Oscar Creativo / CC BY 4.0 geni.us/Ps3XfE
    CHAPTERS
    ---------------------------------------------------
    0:00 Intro
    0:31 How it works
    1:39 Memory hierarchy
    2:17 Linux super power
    3:19 Why won't Google let us?
    4:11 Our solution
    5:18 aaaand it Crashed
    5:50 Why this is dumb
    7:05 Using it how it's intended
    10:27 outro
  • Věda a technologie

Komentáře • 3,2K

  • @BreakingPintMedia
    @BreakingPintMedia Před 2 lety +4091

    With Linus it's never "click-bait". It's more like "click-ahhhh..ok..makes sense"

    • @deher9110
      @deher9110 Před 2 lety +117

      Its click bait tho🧐

    • @stitchfinger7678
      @stitchfinger7678 Před 2 lety +291

      @@deher9110 Its not clickbait just because it made you wanna see it, that's just good marketing
      Clickbait has to be false. Literally "bait" for something else

    • @pumbi69
      @pumbi69 Před 2 lety +51

      @@stitchfinger7678 he said he would use Google drive and proceeded to make a video about pagefile

    • @AcornGR
      @AcornGR Před 2 lety +106

      @@pumbi69 he put google drive as a drive and then assigned a pagefile to it, which means it used google drive as ram. but it crashed because of google drive's security stuff. then he actually did it with their own server that didnt have that security stuff in it

    • @JZL003
      @JZL003 Před 2 lety +26

      A video every day is cool and maybe it's just a division in audience but I'd rather slightly fewer videos if it meant more quality. These past videos just feel like they took a random click bait like title and then figured out how to pad it into a 10 minute video. That beginning google drive served no purpose just to pad, at least find another cloud service which allows random reads and writes. But the end result was really "swap is sometimes somewhat useful but otherwise, use ram". Who is that aimed at

  • @tassaron
    @tassaron Před 2 lety +2326

    We went from always having virtual memory to "what's virtual memory?" within like a decade. Wild

    • @scurvofpcp
      @scurvofpcp Před 2 lety +67

      There are still use cases for virtual memory, but anymore if I'm going to be doing something that is that ram intensive that I need that much ram, I'll just use the dated machine with maxed out ram and a 1 tb ssd as a swap device.
      But, I also know not to expect snappy performance when using a machine to process 100 gig scenes.

    • @DareDevilPhil
      @DareDevilPhil Před 2 lety +58

      Says more about today's average user's knowledge level than the computer hardware to be honest.

    • @scurvofpcp
      @scurvofpcp Před 2 lety +20

      @@DareDevilPhil Anymore ram is cheep and once you have 16 gig or so you are pretty much set for most games and applications. Unless you are getting really deep into it, and even then very seldom do you need to load it all into memory at once.
      Unless you are dealing with some poorly coded applications. Or are working with several raw video frames at a time or some crap like that.
      If I'm baking texture maps or doing large scene renders I'll use my older machines just because sometimes it is nice to toss 500 gig of server ram at a problem and be done with it.

    • @CheapSushi
      @CheapSushi Před 2 lety +12

      Your C drive is defaulted to a Page File on Windows. It still has virtual memory...

    • @DareDevilPhil
      @DareDevilPhil Před 2 lety +2

      @@CheapSushi unless you.. change the settings from default?

  • @licktastic9669
    @licktastic9669 Před 2 lety +727

    The fact that hp and Dell actually sell laptops with only 4g of ram to consumers that mostly have no idea what ram actually is amazes me.

    • @stitch8635
      @stitch8635 Před rokem +10

      what happned to me 😔😔

    • @konigaminggr
      @konigaminggr Před rokem +79

      4 gigs of ram is enough for a nokia, not a laptop...

    • @thefathobo4798
      @thefathobo4798 Před rokem +14

      @@konigaminggr I mean most Chromebook have usually 2-4 gbs ram

    • @yourfinestlocalidiot
      @yourfinestlocalidiot Před rokem +33

      @@thefathobo4798 chromebooks are lightweight machines that can take notes, search the web and do no more than the first fucking iPhone.

    • @bedwar12494
      @bedwar12494 Před rokem +3

      bro i am on one 😭😭😭😭

  • @TheRipeTomatoFarms
    @TheRipeTomatoFarms Před 2 lety +690

    So even LINUS knows the pillow is over priced! I knew it!

  • @mini_bomba
    @mini_bomba Před 2 lety +734

    You might have missed the "vm.swappiness" kernel variable... It kinda controls how likely the kernel is to move data into the swap file/partition.
    (btw, no - i'm not recommending actually using swap as part of your system memory, I'm just adding a little thing you could've tested)

    • @JirayD
      @JirayD Před 2 lety +32

      I actually needed swap memory a couple of years ago, when my 32 GB of RAM weren't enough for a complex database job.

    • @huantian
      @huantian Před 2 lety +23

      Yeah I'm surprised he didn't talk about the swappiness variable

    • @kquote03
      @kquote03 Před 2 lety +28

      @@waldolemmer he personally doesnt, but he has a team of writers and well, anthony :P

    • @helenHTID
      @helenHTID Před 2 lety +6

      Yes. And he needs to set the command to 100 - for aggressive swapping! Muahaha.. Keeping in context with the video lol

    • @s.i.m.c.a
      @s.i.m.c.a Před 2 lety

      with full real memory utilization, it very likely swap would be used without any variable. Why to use all these synthetics and settings cheating?

  • @JimiArchive
    @JimiArchive Před 2 lety +2592

    with the current prices of GPUs, I’d love to download one

  • @MikkoRantalainen
    @MikkoRantalainen Před 2 lety +125

    5:50 You might be able to do swap on network drive if you increase /proc/sys/vm/min_free_kbytes to reserve enough buffer memory to not hang while trying to allocate buffers for pushing bytes to network drive. Maybe also increase /proc/sys/vm/swappiness and /proc/sys/vm/watermark_scale_factor to make kernel more aggressive pushing the data to swap. And you could also try increasing /proc/sys/vm/page-cluster to somewhere in range 6-10 so move bigger blocks at once - trying to move 4 KB blocks with random access would hit hard.
    Swapping to remote network drive could make sense on L6 or L7 level. Before that you should swap to zram, SSD, HDD and fall back network drive only after every other swap device is full. Just set slower swap storage with lower priority and it will not use if there's any free space on any higher priority storage. Of course, as you correctly figured out, getting anything back from network drive would hurt you really bad. Like getting data back may take something like 100 KB/s.

  • @ilovetrainsscr
    @ilovetrainsscr Před 5 měsíci +58

    i'm sorry, but these sponsor segues are so funnily predictable

    • @kmarin_11
      @kmarin_11 Před měsícem +1

      ikr

    • @someperson1028
      @someperson1028 Před měsícem +1

      The whole point of that is because its a "horrible transition" into todays sponsor!

  • @andresilvasophisma
    @andresilvasophisma Před 2 lety +220

    When I was doing my masters degree one of the teachers actually mentioned that one of the other teachers did this back in the 80's when he was a student.
    You could request RAM from a mainframe server that was running at the college.
    Latency was bad but at least you got RAM.

    • @GavinFromWeb
      @GavinFromWeb Před 2 lety +17

      That’s actually pretty damn cool. I wonder if that college you went to still has that.

    • @andresilvasophisma
      @andresilvasophisma Před 2 lety +51

      @@GavinFromWeb They didn't used that anymore when I was there in around 2005.
      But we had another cool thing. Our lab computers had a boot loader where you could select which OS you wanted to run. The image would then get downloaded from a server and you would have a fresh OS installed in less than two minutes. It would be a native install, not a virtual machine.
      This was all developed at the university, way before any of this stuff was commercially available.

    • @iselmon
      @iselmon Před 2 lety +11

      Back then, if you had a class requiring mainframe/mini access, you got a weekly budget in dollars to spend on processing time. Something like $25 and cpu time cost about 50¢/hr.

    • @Jehty21
      @Jehty21 Před 2 lety

      What's the point of RAM if the latency is bad?
      Is the use for that that if a program requires more ram than you have?

    • @Solarbonite
      @Solarbonite Před 2 lety +1

      Memcachedb does this!
      It's lower latency than spinners usually.
      Now that we have not-expensive NVMe ssds and expensive RAM I imagine datacenters use ssds instead though.

  • @TheInternetHelpdeskPlays
    @TheInternetHelpdeskPlays Před 2 lety +139

    I remember setting up a page file back in windows 95 on an extra 500Mb drive. It actually sped up my system quite a bit. But this was back when 32Mb RAM was considered a good system.

    • @virtualtools_3021
      @virtualtools_3021 Před 2 lety +3

      Just not having it on your main drive is a bit boost

    • @Gurj101
      @Gurj101 Před 2 lety +9

      Do you remember Windows 7 came with a feature to use a pendirive as a virtual memory. Maybe it worked the same way. You should still be able to do it. If i remember right it requires minimum 4gb capacity pendirves to work(could be wrong).

    • @Gurj101
      @Gurj101 Před 2 lety

      not that anybody would need to do it since most systems have 8gb ram these days

    • @cyrilvaneijkelenburg3743
      @cyrilvaneijkelenburg3743 Před 2 lety

      and I actually think there needs te be a follow up video . By just moving the pagefile to the secondary ssd in windows there would be a significant improvement to having it on the same disk as windows. But why stop at one ssd ? Shouldn't it be possible to instead of one ssd use a raid 0 of multiple ssd's ? And instead of using sata ssd's maybe use m.2 pci express gen4 since I am pretty sure Linux has acces to motherboard with a lot of m.2 slots.

    • @shawn2780
      @shawn2780 Před 2 lety +8

      @@Gurj101 You're referring to ReadyBoost which does work in a similar way. Any size will do, as long as it has a couple hundred megs of space, though you need at least a gig to see any benefit. You can only use now it if you have a 100% hard drive system though. If you have any ssds installed at all it'll hide the feature - since swapping to the slowest ssd will always be faster than the fastest usb drive. It's still around though, even on Windows 11

  • @theaaravyt
    @theaaravyt Před rokem +8

    Instructions unclear, i accidentally downloaded a processor.

  • @pi_xi
    @pi_xi Před 2 lety +46

    This reminds me of the scammy “memory enhancement software” in early days, some of them actually used LZ77 compression for user space memory, but most of them only changed the size of the page file.

    • @Wyld1one
      @Wyld1one Před 2 lety +3

      I used some of them back pre-pentium days.
      Well it wasn't a perfect solution, at least it gave your hardware a little more breathing room until the next generation came around. Also could be used for games because that's what I did as well.
      That was the ones that actually use compression

  • @koevoet7288
    @koevoet7288 Před 2 lety +489

    You could’ve set the swappiness to something like 99 instead of the default 60. That would’ve put stuff into swap at 1% ram usage (instead of the default 40%)

    • @slithery9291
      @slithery9291 Před 2 lety +57

      That isn't what the swappiness value means. It's much more complex than that...

    • @SodaWithoutSparkles
      @SodaWithoutSparkles Před 2 lety +2

      At 1% _swap_ usage?

    • @TheFrantic5
      @TheFrantic5 Před 2 lety +56

      I love that 'swappiness' is an official term that grown Linux users are required to use.

    • @notalostnumber8660
      @notalostnumber8660 Před 2 lety +8

      Perhaps also the vm.vfs_cache_pressure to a high value, like 200

    • @tralphstreet
      @tralphstreet Před 2 lety +8

      @@TheFrantic5 No one discusses Swap on a daily basis. You either use it or you don't. I personally don't bother with it.

  • @entropyxu4044
    @entropyxu4044 Před 2 lety +769

    I did something like this in my PHD. Several things you might want to try:
    1. Using cgroup to explicitly control processes can eliminate most of the crashes and it improves the performance of the system overall.
    2. Using Intel Optane (even the low-end 16G model) as swap is much faster than swapping to a local SSD. A lot of larges models that needs tens of TBs of memory relies on Optanes.
    3. The performance of swapping inside a VM is better than swapping outside a VM.

    • @bigpod
      @bigpod Před 2 lety +20

      as someone who spent days days optimizing his swap i can tell you this is correct but reality is you should not in any way hope for swap for actualy doing tasks its a waiting place at best. this days its main uses are VMs and hibernation

    • @entropyxu4044
      @entropyxu4044 Před 2 lety +19

      @@bigpod Yes! Swap is definitely going to be slow no matter how you optimizes it. Swap is accessed in the size of memory pages (2K-4K) while CPUs access memory in the size of bytes. Which means even you "swap to a memory", it is still going to be slow. But sometimes, the goal of swap is to simply makes it possible to run some programs (especially those programs that needs 10TB+ memory).

    • @xtremezmc443
      @xtremezmc443 Před 2 lety +27

      I don't understand a single thing between these Einstein's but I'm here anyways

    • @philuhhh
      @philuhhh Před 2 lety +2

      "Using cgroup to explicitly control processes" - what do you mean by that? Do you mean setting per-process- (or per-cgroup-) RAM limits, so to delegate the memory management to the applications instead? If so, wouldn't that be the same as turning swap completely off, in other words, do you suggest we shouldn't use swap at all? And of course, what if those processes actually *need* the memory and then ... die? Also, why do cgroups improve the system performance overall?
      Just curious, thanks for your input! :-)

    • @bigpod
      @bigpod Před 2 lety +1

      @@entropyxu4044 while yes it can allow you to run those programs like SAP Hanna for example (being the most apt example) performance of such app will most likely be horrible (and is horrible) and will most likely only work for small examples(where 10TB+ is not needed) or sparsly accessed programs.
      but lets remember there are fairly small amount of such programs(databases and research stuff) where many of those programs can be relegated to a server room or even a computing cluster or in some cases even supercomputing clusters(colloquially known as supercomputers)

  • @Ichwiebrot
    @Ichwiebrot Před rokem +4

    LTT is a god at roasting 6:33
    The way his expression never changed
    While he casually mentions where everyones dad is.

    • @GoofyGeekGang
      @GoofyGeekGang Před 9 měsíci

      Poping out for 15 minutes to get milk 🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛🥛

  • @yushie8158
    @yushie8158 Před 2 lety +27

    At 5:50 -- This setting can be tweaked around by the "Swapiness" value. It essentially tells the kernel how likely it should use Swap. Since Linux also does eager swapping to clear out *actual* RAM, this is quite a handy feature.

  • @anezay4987
    @anezay4987 Před 2 lety +625

    Reminds me of "no replacement for displacement"; at the level of performance we expect today, you can't really cheat your way out of using the correct hardware.

    • @spoolinturby1640
      @spoolinturby1640 Před 2 lety +17

      their is a replacement for displacement. Look at my PFP 😏

    • @BrazenRain
      @BrazenRain Před 2 lety +13

      @@Jtzkb without a massively oversized heavy engine weighing you down

    • @lukewoodside9420
      @lukewoodside9420 Před 2 lety +1

      @@Jtzkb Shoving a big fat turbo in because natural aspiring an engine is just dumb if you want horses

    • @flandrble
      @flandrble Před 2 lety +1

      except there is, it's called compression, and often it means access is even faster as there's less to read/write in compressed form.

    • @thebaker8637
      @thebaker8637 Před 2 lety +6

      @@flandrble It's funny you bring this up, because compressed pages are literally equivalent to turbochargers. Sure, you will get more available RAM space and little performance hit in optimal situations, but there ain't such thing as a free lunch, so you're paying for that extra space by having to spend CPU cycles decompressing it on a page fault. Sure, if you have lots of RAM to begin with, on average it will probably actually speed up your system. However, compressing pages on a RAM-constrained system will tank your performance because you'll just end up thrashing at lower utilization and hitting the expensive decompression path a lot instead of using all your available RAM as it is. There's no replacement for more place to store ones and zeroes. More RAM is more better, and (unlike going with a bigger engine) it does not result in any significant disadvantage outside of higher cost.
      This is very similar to the argument for/against turbos. A turbo can deliver much of the same power in a smaller engine as a bigger engine could, but it has drawbacks such as having to wait a bit for all the power to be immediately available. If you have a very small engine that you're always redlining, slapping a turbo on it will not help you much. However, they are useful for squeezing extra performance out of engines when they're optimally specced out.

  • @kensmith5694
    @kensmith5694 Před 2 lety +199

    Way back in the MS-DOS days, there was a trick for having "expanded memory" keep the bulk of the stuff in upper RAM compressed and also do a swap file if needed. If made programs that needed it go very slow indeed.
    There also was a trick mostly done by Borland, that allowed you to make a program where most of the program didn't load from disk unless needed. Stubs for all your subroutines in the main program and kept a list of the ones it currently had in RAM. If a subroutine was needed but wasn't in RAM one of the ones you haven't used in a while was removed from RAM and replaced with the one you needed. The result worked surprisingly quickly because you could often break a program into parts that mostly didn't interact.

    • @nsa3967
      @nsa3967 Před 2 lety +10

      zram

    • @noergelstein
      @noergelstein Před 2 lety +13

      Nowadays programs are placed into memory by mmap. Basically you tell the OS I want this file accessible from RAM. It doesn’t actually load it into RAM though, but it promises it will be there when you need it. Then, when you touch a part of the file (for example by executing code from that file), the memory management unit in the CPU will trap the execution, pass control to the OS, which will load in a “page” (usually 4Kb) of the file to RAM and the let the program continue executing. If a 4kb page hasn’t been accessed for a long time, the OS might unload it to free up RAM. If a part of a file is not used, it doesn’t need to be loaded either. And if another program has already loaded a program library, both programs can share that library in memory (it doesn’t need to be kept in memory twice).

    • @batsonelectronics
      @batsonelectronics Před 2 lety +1

      if you are referring to "lh" or "loadhigh" back in the day, that was to use the ram above 640k, it was not compressed.

    • @MarkusRessel
      @MarkusRessel Před 2 lety +1

      ​@@nsa3967 zram is great. It does take a while to initialize on boot though, so on a system with "enough" ram I would still advise against it. And of course there is some overhead due to the compression, but that runs in hardware these days so its not that big of a deal if you need more RAM.

    • @dtibor5903
      @dtibor5903 Před 2 lety

      DOS had only 640k addressable memory and the extended memory was not compressed at all. DOS had no swap, real time OS-es can not have a swap by design. Stop misinforming people. The dynamic load in Borland was a thing but it was just annoying mostly, especially when running from floppy disks.

  • @jkengland832
    @jkengland832 Před 2 lety +9

    Linus doesn't need stock videos or photos to explain something because his crew does it for him and it's brilliant

  • @MichaelSidneyTimpson
    @MichaelSidneyTimpson Před 2 lety +5

    There were programs that we installed on our system in the '90s such as "virtual ram" that worked without crashing your system. I imagine the single processor systms and operating systms of those days were so slow that it was not as big of deal (they did mention that while improving your multitasking, your computer would take a speed bump.). In those days we were used to waiting for things to load, so it was quite tolerable.

  • @lperkins2
    @lperkins2 Před 2 lety +251

    Scientific tasks are actually an area where swap, especially tiered swap, really shines. Specifically if the modeling software needs to generate a huge dataset but only rarely needs to look back at data from near the start of the simulation.
    I sometimes do computational fluid dynamics (CFD) on systems where the working set of data reaches into the low 100GB range, on a system with 32 GB of ram. 20GB is enough to hold the volatile working set easily, so I actually configure it to use the next 12GB as compressed ram swap (zram), which manages a 3:1 ratio, and trades CPU time to still have low latency. This gets me to 56GB of effective ram, before touching the next storage system. For a while I actually then layered my GPUs VRAM in, as it is higher performance than my SSD, and it's a 16GB card, with zram on top of it that's an extra 45GB (leave a bit to actually drive your display), for a total of 101GB before you have to touch a disk. (Unfortunately, the GPU userspace memory system has gotten a bit unstable, so I had to drop this level). Data which doesn't compress well, or the oldest data once the compressed space is full, gets written out to disk, needing between 10 and 30 GB for most of my projects.
    If you are using the system this way, you need to set up memory cgroups or you're in for a bad time.

    • @Wyld1one
      @Wyld1one Před 2 lety +4

      It needs to be automatic as well. If a user doesent know about it, it won't be used.

    • @lperkins2
      @lperkins2 Před 2 lety +6

      @@Wyld1one Unfortunately it's the kind of prolem that is rather resistant to automation (and if you're working in a domain where it's needed, you likely know what to do). There are lots of knobs to tweak, and what is sensible behavior in one case may be exactly wrong in another. For example, if you don't have swap, and run out of memory, the OOM killer picks the program most likely to be leaking or hogging memory and kills it. This keeps the system responsive, but obviously killing a semi-random program can be bad (you can give the OOM-k hints so it gets the right program, but it's fiddly). On the other hand, if you try to have the system just swap, and slam it with too heavy of a load, the system will go unresponsive for potentially hours as it tries to figure out what can be swapped out or thrashes the CPU. It likely *will* recover, unless there is a runaway program, but you're often better off hard resetting the computer at that point as a reboot is much faster.
      That said, there is a decent way to configure a machine for general use, when swap is present, that I think *should* be default for user-friendly distros. If you push the user-level programs into a memory (c)ontrol group, which is configured to use say 95% of the system memory max, then if the user launches something that tries to use too much memory, the system will go unresponsive, but the tty login (or ssh) will remain available. Trouble is c-groups are relatively new, so adoption is still rather slow.

    • @nunyabusiness3786
      @nunyabusiness3786 Před 2 lety +13

      It just makes me feel all warm and happy inside that people actually use computers for doing smart stuff and not just videogames/crummy business stuff.

    • @cyjanek7818
      @cyjanek7818 Před 2 lety +2

      I wonder how much performance you are leaving "on the table" though. CFD calculations are mostly ram speed limited so making ram painfully slow by replacing it with compressed SSD sounds like big loss, much bigger than anyone reading your comment would expect (in your comment it sounds like good replacement).
      You would need to test it but it looks like upgrading to 64 or 128 gb of ram (if possible) would give you massive advantage.

    • @lperkins2
      @lperkins2 Před 2 lety +2

      @@cyjanek7818 Depends a lot on the particulars of the project, and the machine used. If you are ram-speed limited, you can actually get better performance from compressed zram, as the compression is done in CPU caches, so the data sent to and from ram is reduced. That obviously trades more CPU time, but if the calculation can only effectively use a portion of your CPU (in the obvious case if it is single threaded), you can get a bit extra effective I/O performance by devoting a couple of cores to reducing the bandwidth used. Even then, you do pay a pretty significant *latency* hit, so it's only useful with certain workloads.
      Specifically, when you are doing time-dependant CFD, and the program doesn't manage tiered storage itself, it will keep data from the first time slice around until the end, even though it may well never need to reference it again. In this case, compressing that data and swapping it out will keep the program happy, and give good performance. The swap algorithm itself picks the least recently used data (disk cache or program memory) to compress/write out, so it will naturally pick the unused/old pages. This can be fine tuned by giving the cgroup a low point to *start* swapping, so that it never ends up with significant memory pressure. It's also important to tune the amount of compressed vs non-compressed memory so that the actual working set has enough memory.
      For my last project, that required keeping at least 24 gb of normal memory for the program, and then 24gb of compressed high speed ram, with the balance written out to nvme, compressed. I worked out those numbers by turning on some extra metrics to observe how often data was getting pulled *back* from swap. It would read data back from the compressed ram at the start of each new "frame", but not within a frame. It only read data back from the nvme storage at the end.
      Would having an extra $200 of ram sped the process up? Maybe by a couple minutes, out of a week of computation. At some point I may get some extra ram just long enough to compare, but I honestly don't think it would make that big a difference. Also, the same argument will hold the whole way up. 32gb of ram using zram lets you do CFD needing up to 100gb of virtual memory. 128gb of ram would let you reach 512gb projects without needing to go to threadrippers. 2tb eypc platforms would let you have an 8tb simulation.

  • @akkesm
    @akkesm Před 2 lety +240

    Three words: swap on zram. Set the limit to 100/150% RAM capacity, set swappiness to 200, get more RAM from your RAM.

    • @protocj3735
      @protocj3735 Před 2 lety +19

      I have swap on zram on my Pi Zero 2 and it made it so much more responsive and usable

    • @notalostnumber8660
      @notalostnumber8660 Před 2 lety +25

      Funny thing is, zram actually expects the compression to be half or even a third (so double or triple the space)
      That is, if you had 8GB of RAM, you could have 16GB of zram-swap.
      It will be slower, but way better than storage-swap. And I really recommend Zstd as your comp alg, it's fast and decent

    • @shinyhappyrem8728
      @shinyhappyrem8728 Před 2 lety +5

      So what happens if you try to load 16 GB of MP3s/JPGs/MKVs into 8 GB of zram'd RAM?

    • @shockwaverc1369
      @shockwaverc1369 Před 2 lety +6

      @@shinyhappyrem8728 those files are already compressed and they cant be compressed further, even a high level zstd can only compress with a ratio of 99/98%

    • @shinyhappyrem8728
      @shinyhappyrem8728 Před 2 lety +4

      @@shockwaverc1369: I know, that's why I asked about them. The program ought to handle cases like that somehow.

  • @DethFaux
    @DethFaux Před 2 lety

    This video was very informative. The examples you gave with the people helped it make more sense to me.

  • @GabrielForth
    @GabrielForth Před rokem

    This is a really good video for an introduction to swap space. One thing worth mentioning is another factor reducing the use of swap space besides cheaper RAM is the prevalence of SSD.
    When your swap space was on a HDD it was slow but didn't have any side affects other than a loss of 16 - 32GB of capacity to a swap partition, however since swap experiences a lot of random reads and writes there is a good chance it'll impact the lifespan of an SSD it's put on.

  • @schtromar
    @schtromar Před 2 lety +474

    Part 2 idea: Zram. It compresses less used stuff in the memory in real time with less CPU overhead than you'd imagine, giving you an effective ~2.5x the system memory. It really works!

    • @ukraniankgb9131
      @ukraniankgb9131 Před 2 lety +39

      Literally SoftRAM but real.

    • @MiniRockerz4ever
      @MiniRockerz4ever Před 2 lety +3

      Didn't work out too good with Raspberry Pi 400, but then again I was running latest beta Bullseye OS version.

    • @user-xr3rb6pn9m
      @user-xr3rb6pn9m Před 2 lety +49

      @@MiniRockerz4ever ZRAM is a tradeoff, you're saving ram at the expense of CPU usage as CPU needs to constantly zip and unzip the data in RAM. AND RPi 400 is more CPU-limited

    • @jorismak
      @jorismak Před 2 lety +2

      It's been in windows and macos for quite some years ... I wonder if it's useful these days though

    • @junkerzn7312
      @junkerzn7312 Před 2 lety +10

      Very non-deterministic, and it burns cpu at a time when the cpu tends to be busy. Not recommended. It's actually better to just page the data to a fast SSD these days, with as low a CPU overhead as possible. There have also been attempts in the past to have compressed swap (effectively compressed memory when the swapfile is on a tmpfs filesystem). NeXT famously had compressed swap, and it was a disaster.
      These days you just want to configure a SSD partition and point swap at it. A swapfile works too but isn't quite as deterministic (in linux its about as fast as a partition, but it goes through a filesystem layer that has to record all the block ranges on the underlying raw device, which is a bit risky because the filesystem can't reallocate those swapfile blocks. You have to trust that the filesystem implements it properly).
      Another reason to use a swap partition instead of a swap file is that you can TRIM the swap partition at boot time. Thus your swap partition serves as extra SSD space for wear leveling since 99% of the time your machine doesn't actually have to use much swap. Highly deterministic on all fronts and very desirable.
      -Matt

  • @achillesa5894
    @achillesa5894 Před 2 lety +155

    8:00 you can see this in action if you have 8 GB of ram and while playing a game you tab out to another program like your browser. It will often hang or slow down for a few moments because the OS has moved the browser's stuff (especially background, inactive tabs) to the page file to free up the ram for your game. This kind of stuttering when multitasking is easily solved by adding more ram and is why pc builders recommend 16 GB even though you could play most games with less.

    • @yesed
      @yesed Před 2 lety +9

      I would say at todays standards, 16gigs I have are not quite enough anymore, chrome likes it too much

    • @pcfan1986
      @pcfan1986 Před 2 lety +3

      @@yesed You could just close chrome while playing if you experience a bottleneck. But I also would recommend 32 Gigs nowadays to be sure.

    • @HanSolo__
      @HanSolo__ Před 2 lety

      I think scaling it in case of needs above 64 GB for Virtual Machines that do procesess on them own for hours/days.

    • @jimmyb1451
      @jimmyb1451 Před 2 lety +1

      @@yesed You should just swap to Brave.
      My system admittedly only has 4 cores and I don't play games on it. I do use it for circuit design simulation though which is a pretty heavy load. 16 gigs and I've never seen it use the swap file. To the extent that I turned off the swap about 12 months ago. Haven't had a crash yet.

    • @Azarilh
      @Azarilh Před 2 lety

      Ok finally some explaination at what the hell is goin on on my PC with some heavy RAM games.

  • @nelejanbbi4616
    @nelejanbbi4616 Před 2 lety +4

    8:16 love that they used icons of what you'd use in linux instead of word, chrome and photoshop lol

  • @jonathanbrutt
    @jonathanbrutt Před 2 lety +6

    Did he just call his own pillow... overpriced? 3:05 *shock*

    • @vrgamer6644
      @vrgamer6644 Před 2 lety

      Ik it's as if he is telling a joke!!

    • @unibyte09
      @unibyte09 Před 2 lety

      @@vrgamer6644 it is. 69.99 for a pillow lol

    • @vrgamer6644
      @vrgamer6644 Před 2 lety

      Well what do you expect from linus

    • @redtrexmedia
      @redtrexmedia Před 4 měsíci

      They just don’t care if you buy it or not coz they getting paid from sponsors and videos

  • @astralplane6182
    @astralplane6182 Před 2 lety +225

    The editing, extra graphics, and cute live-action, few-second vignettes really elevate this video to the next level - well done LTT!

  • @DavidAddis
    @DavidAddis Před 2 lety +33

    The editing on this video was crazy good. Well done, Dennis!

    • @mzamroni
      @mzamroni Před 2 lety +1

      But its not high frame rate despite tons of expensive equipments ltt has

    • @chiroyce
      @chiroyce Před 2 lety

      @@mzamroni This is not a fast paced race or something that needs 60FPS or more, 30 is enough for LTT videos.

    • @guitaripod
      @guitaripod Před 2 lety +2

      @@chiroyce 60 fps looks better. End of story. No, Mr. Editor. It's better 😂

    • @mzamroni
      @mzamroni Před 2 lety +1

      @@chiroyce watch gamers nexus recent videos for comparison

  • @burunduk3
    @burunduk3 Před 2 lety +3

    My experience with network-based swap is usually like:
    - The swap is provided by some userspace software (like sshfs, and here I've heard of smb, not sure if it's completely in-kernel),
    - This software gets swapped,
    - Unable to unswap pages which are needed to unswap pages.

  • @tld8102
    @tld8102 Před 2 lety +6

    is it me or the lighting and colouring on this video is ON POINT today? it looks better than normal

  • @Xavierpng
    @Xavierpng Před 2 lety +904

    The animated explanation of ram was awesome 👍.

    • @iHaveTheDocuments
      @iHaveTheDocuments Před 2 lety +19

      How much did you pay for your channel?

    • @AndroidFerret
      @AndroidFerret Před 2 lety +3

      So realistic cgi

    • @justlixian293
      @justlixian293 Před 2 lety +3

      around 7k i think

    • @lucky_lol
      @lucky_lol Před 2 lety +4

      Bots all around

    • @Tuberex
      @Tuberex Před 2 lety +4

      Fr.
      Unbelievable,
      Crowning,
      Kudos to
      You for this
      Outstanding
      Understanding of the
      Broadcast
      Of
      The Great Linus

  • @shangerdanger
    @shangerdanger Před 2 lety +89

    the computer SFX made me feel like i was watching bill nye lmao

  • @noahb4399
    @noahb4399 Před 2 lety +2

    I like the water glass, people bumping into each other etc. Visual analogies. Would be neat to see more to explain technical details 😀

  • @tiagoserodio1694
    @tiagoserodio1694 Před 2 lety +2

    Linus, you're the only guy on the internet that I enjoy going through sponsors! Kudos my man

  • @dumpsterdawg
    @dumpsterdawg Před 2 lety +15

    Title Correction
    We ACTUALLY downloaded more unusable RAM

  • @Frog-ko6uu
    @Frog-ko6uu Před 2 lety +12

    I remember when I was trying to get an an oldish mini PC that only had 2 gigs of RAM to not lock up all the time, I configured Windows to swap to a 16GB mSATA SSD that I had for some reason whose only function was to act as the page file. It worked wonders and that computer basically never crashed after that.

  • @ramgladore
    @ramgladore Před 2 lety +2

    I remember learning about this when I got my first PC about 20 years ago. It was called virtual memory. You just go into the settings and tell Windows to use a section of your HHD as ram. But it works about as well as you would think because it was a HHD and not a SSD. I'm actually curious to try to use it with an SSD now.

  • @FengLengshun
    @FengLengshun Před 2 lety +4

    9:36 this is probably why we're collectively moving to zram over normal swap on Linux because from the looks of it compressed ram is still better than swap (outside of hibernate).

  • @Cainns98
    @Cainns98 Před 2 lety +20

    It would have been nice to mention that having a swap allows you enable hibernation by writing the contents of your ram to your drive so that it can cut power to the DIMM slots. It has been helpful for me on my laptop.

    • @mckryall
      @mckryall Před 2 lety +2

      And every OS and filesystem I'm aware of now defaults to using a file for swap. You can still use a swap partition, I do.

  • @stevemoore-vale5632
    @stevemoore-vale5632 Před 2 lety +3

    The best timed video I’ve ever seen. I’ve been researching page files all this weekend due to it slowing down my photo editing software and then this pops up. Superb.

  • @chozen_666
    @chozen_666 Před 2 lety

    LTT is so underrated FR your intro’s are OP you make me laugh every time thank you 👌🏼😌

  • @mgord9518
    @mgord9518 Před 2 lety

    This is a really good explanation of swap, I've always had a hard time explaining it to people outside of "basically RAM but on your hard drive"

  • @MrDennisben
    @MrDennisben Před 2 lety +23

    I am an IT and telecommunications student and these videos are so much more interesting to me than regular reviews and which gaming laptop has better speakers. Looking forward to lab content.

  • @Cwize1
    @Cwize1 Před 2 lety +30

    Ok, hear me out: 6 workstations, 1 set of RAM. Setup a server with a massive amount of RAM, setup a RAM disk on the server, share that RAM disk to the workstations using an inifiband network (lower latency than ethernet) and then setup a swap space on the network drive.

    • @CheapSushi
      @CheapSushi Před 2 lety

      I think Supercomputers do this, no?

    • @Tymczaq10
      @Tymczaq10 Před rokem +1

      @@CheapSushi I think each node in SuperComputer have it's own ram, because convienience

    • @carlbutcher2268
      @carlbutcher2268 Před rokem

      At this point you basically just do what a lot of retail stores do with their till systems (even if most the staff don't actually know it), and just have every workstation just be a client device that accesses a virtual machine on the same server.

  • @zanidd
    @zanidd Před rokem +1

    This is now my favorite LTT videos

  • @TinyGiraffes
    @TinyGiraffes Před 2 lety +1

    8:34 There's a few notes in that music that is just like one of the default alarms on my phone. It's giving me anxiety.

  • @charliedallachie3539
    @charliedallachie3539 Před 2 lety +25

    Couldn’t imagine the system performance on cloud RAM especially on glitchy Wi-Fi connections 😂

  • @buttersquids
    @buttersquids Před 2 lety +9

    Hey, I remember seeing this as an idea a few months ago on a linux subreddit. So cool to see you guys actually give it a try!

  • @chodgson
    @chodgson Před 2 lety +1

    9:00 what is actually happening is that the system is using extra available RAM to cache the drive access - because there is extra available to do that. It won't try to cache the drive access using the swap file, because the swap file is ON the drive (or at least a similarly slow device).

  • @IainPurdie
    @IainPurdie Před 2 lety

    The section on memory hierarchy is something we cover on our Higher (year... 12? Dunno how it compares to US/Canadian schools) course, and nails it in such a nice, short, compact format that I'm putting it into our class resources. Thanks!

  • @Neoxon619
    @Neoxon619 Před 2 lety +174

    When memes become reality……kinda. I didn’t think downloading RAM would actually be possible (even to this extent).

    • @okktok
      @okktok Před 2 lety +9

      it its not, its just a bait title

    • @Neoxon619
      @Neoxon619 Před 2 lety +2

      @@okktok That’s why I said kinda.

    • @deher9110
      @deher9110 Před 2 lety +2

      He aint downloading ram tho and this aint a substitute for ram by a long shot

    • @id104335409
      @id104335409 Před 2 lety +4

      ACTUALLY...
      In the distant future you might be able to download pretty much anything over a network that feeds it into your 3d matter printer. So you could download as much memory as you need for your new PC.

    • @samsus4944
      @samsus4944 Před 2 lety +1

      What if you download the schematics for a ram stick and then 3d printed it?

  • @caio1998caio
    @caio1998caio Před 2 lety +93

    It would be interesting to test if Intel's Optane would perform better in this test, since Intel claims such low latency and high iops on that memory

    • @notalostnumber8660
      @notalostnumber8660 Před 2 lety +1

      According to intel it's 10% the latency (or speed?) of RAM

    • @junkerzn7312
      @junkerzn7312 Před 2 lety +12

      It has been tested but basically the answer is... its a waste of money. Pageouts to swap are asynchronous, so latency is well absorbed. Pageins do read-ahead, so latency is fairly well absorbed (random pageins are the only things that suffer).... but honestly, unless the system is being forced to pagein tons of data, the difference wont be that noticable. The latency of the page-fault itself winds up being the biggest issue and you get that both ways.
      Now 'optane as memory' (verses 'optane as swap device') is a different beast entirely because there is no page fault. The CPU essentially stalls on the memory operation until the optane module can bring the data in from the optane backing store. So latency in this case is far lower. Still not nearly as low as main memory, of course, but significantly faster than making the operating system take a page fault.
      -Matt

    • @jimbo-dev
      @jimbo-dev Před 2 lety +1

      @@junkerzn7312 That's interesting. And as optane is insanely expensive that result is believeable. If a workload depends on insane amount of ram, last generation memory is quite affordable. (My photogrammetry server is still using DDR3)
      Fast ssd or optane might be more worth it if installed as zfs cache on hard drives

    • @morosis82
      @morosis82 Před 2 lety +1

      @@jimbo-dev the difference is the 'insane amounts of memory' part. With Pmem 200 series and a dual CPU config, you can have 6TB of optane as memory in a single machine, assuming 12 slots per cpu. You could then also have your 768GB of DDR4 per cpu.
      Optane is expensive, but I think generally it's less than the equivalent in DDR4.

    • @CheapSushi
      @CheapSushi Před 2 lety

      @@junkerzn7312 Been tested where? Because Optane seems like the perfect swap for huge database workloads even with lots of memory.

  • @Zeldon567
    @Zeldon567 Před 2 lety +4

    What I want to know is if no ram and only swap space would work at all. I'd like to see a video testing that.

  • @lordofthewest
    @lordofthewest Před 2 lety +39

    I love seeing linus using the linux terminal properly to mount filesystems and make swap space. He's come so far from "yes, do as i say!"

  • @sandmann521
    @sandmann521 Před 2 lety +51

    Seems useful in a pinch for edge-case workloads, but I imagine constantly hitting an SSD swap space would dramatically reduce the SSD's lifespan, while DRAM basically lasts forever.

    • @blowtorchhonor
      @blowtorchhonor Před 2 lety +3

      This ^^^

    • @naamadossantossilva4736
      @naamadossantossilva4736 Před 2 lety +2

      agreed,and with how cheap RAM is nowadays this seems even stupider.

    • @Pasi123
      @Pasi123 Před 2 lety +12

      I used a cheap DRAM-less Kingston A400 120GB just for Windows pagefile for a year and after that as a OS drive. It still works fine but according to CrystalDiskInfo the health status is only 64%, it has 18TB host reads, 19TB host writes, 37TB NAND writes, 20k power on hours and 161 power on count

    • @kered13
      @kered13 Před 2 lety +3

      SSD read/write lifetimes are not that short these days. There's no realistic harm in using SSDs as swap space.

    • @myname356
      @myname356 Před 2 lety +5

      I have used a 750 GB NVME SSD as "extra RAM" for probably 3 years by now, at times using it hard (i.e. it writing 200-300 MB/s for hours straight several times per week) and I have not noticed any problems yet. I was thinking it would probably start breaking after a few months but no, still going strong. Getting that SSD was the best hardware investment I've ever made, that amount of RAM would have cost a fortune.

  • @dataterminal
    @dataterminal Před 2 lety +31

    You can mount your VRAM as a device and use it as swap space, or just a handy super fast temp directory.

  • @allenjunge4127
    @allenjunge4127 Před 2 lety

    This was a fantastic demonstration of thrashing. In college I had a hard time grasping the concept at first

  • @circle_line
    @circle_line Před 2 lety

    LTT is one step away from setting up Remote Direct Memory Access and I want that video so badly

  • @adriangunnarlauterer4254
    @adriangunnarlauterer4254 Před 2 lety +95

    You could try changing the swappines. So that the system pushes earlier and more aggressively to the swap.

    • @pvshka
      @pvshka Před 2 lety +13

      @@chy4e431 the amount of people like that who either didn't watch or don't understand the video but are commenting is giving me cancer.

    • @iDraKzy
      @iDraKzy Před 2 lety +2

      @@zenstrata The amount of work it would require to get actual information from raw RAM data makes it not worth it anyway (even if they did send data to google which they didn't cause it didn't work x))

    • @Krmpfpks
      @Krmpfpks Před 2 lety

      @@zenstrata it's no problem to encrypt the swap file, at least on linux and macos.

    • @linsetv
      @linsetv Před 2 lety

      @@zenstrata did you even watch the whole video?

  • @UnbelievableCH
    @UnbelievableCH Před 2 lety +25

    fun fact: you can also do the opposite and mount a specified amount of RAM as a temporary filesystem (tmpfs) to use it as a disk. You could try to install a small game on it which should have blazing fast loading times :-)

    • @TheBurritoLord
      @TheBurritoLord Před 2 lety +5

      I think they’ve done that before, every time you shut down your PC will “uninstall” the game tho. Since RAM gets cleared

    • @UnbelievableCH
      @UnbelievableCH Před 2 lety +3

      @@TheBurritoLord oh, I missed that. Yeah that's the downside of it as it's volatile storage hehe

    • @shinyhappyrem8728
      @shinyhappyrem8728 Před 2 lety +5

      They also had a PCI RAM card that came with a battery, iirc.

    • @MarcellPlazOn
      @MarcellPlazOn Před 2 lety +2

      Yeah I read that someone installed crysis 3 on a RTx 3090’s vram

    • @nulano
      @nulano Před 2 lety

      My ASUS motherboard had a similar program for Windows bundled on the CD. It automatically syncs data to the hard drive, but keeps it in RAM when the system is running. However, most games don't really benefit from a ramdisk beyond what you can achieve with an SSD as you are typically CPU limited at that point anyway.

  • @originlgazza5925
    @originlgazza5925 Před 2 lety

    I full-on laughed at like 5 cutaways in this but the best one was the horsepower and Linus casually riding past on a horse hahahahahah omg I love LTT so much.

  • @jasonmohr1599
    @jasonmohr1599 Před měsícem

    When installing operating systems like arch or gentoo typically recommend you only dedicate half of your amount of ram to a swap partition, assuming you have 16 gigs or less, otherwise just your system will be fine without swap, although if you never turn your pc off, they still recommend creating a swap file with hibernation so your pc doesn't close your programs

  • @fiws
    @fiws Před 2 lety +62

    Cool to see more content involving linux!
    When linux runs out of memory it is supposed to invoke the "OOM killer" which just ends a process forcefully. I'd expect desktop linux to freeze or dump you to tty in some edge cases. I think there must be a bug or some kind of problem, because it should not be crashing at all.

    • @mthf5839
      @mthf5839 Před 2 lety +7

      in the 'dump to tty' case, I would also expect the display manager get restarted automatically by systemd.
      So you might see the tty for a couple of seconds, but then get the login screen.

    • @YeaSeb.
      @YeaSeb. Před 2 lety +3

      nohang does a pretty good job at it, the default oom killer doesn't do much killing 'til after you hang.

    • @jwhite5008
      @jwhite5008 Před 2 lety +3

      @@YeaSeb. I agree, for some reason default OOM killer is useless in most cases.
      It tries its "best" but actually makes it worse by allowing all caches to be disabled.
      When it takes >10 minutes to just switch to a VT you know that recovery is not really an option.

    • @monsterhunter445
      @monsterhunter445 Před 2 lety

      And windows is supposed to do that as well in oom but I have gotten bluesceeen so no you are wrong not always the case thing is oom killer probably needs ram but if everything is full including swap it will crash. I work with 100s of gigabyte of memory at work for my software development.

    • @junkerzn7312
      @junkerzn7312 Před 2 lety +4

      Its more difficult to accomplish than people think. It is fairly easy for the kernel to deadlock on the auxiliary kernel memory allocations that might be required in order to accomplish something that relieves user memory. Paging is a great example. To page something out the kernel has to manage the swap info for the related page, must allocate swap space, might have to break-up a big-page in the page table, might have to issue the page write through a filesystem or device that itself needs to temporarily allocate kernel memory in order to operate properly. The pageout daemon itself has to be careful to avoid deadlocking on resources that processes might be holding locked while waiting for memory to become available. The list is endless. Avoiding a low-memory deadlock in a complex operating system is not easy.
      This is yet another good reason why swap space should not be fancy. Swap directly to a raw partition on a device. Don't compress, don't run through a filesystem (though linux does a good job bypassing the filesystem when paging through a swapfile), don't let memory get too low before the pager starts working, don't try to page to a swapfile over the network (NFS needs to allocate and free temporary kernel memory all over the place). The list goes on.
      Those of us who work on kernels spend a lot of time trying to make these mechanism operate without having to allocate kernel memory. It is particularly difficult to do on linux due to the sheer flexibility of the swap subsystem. The back-off position is to try to ensure that memory reserves are available to the kernel that userland can't touch. But even so, it is possible (even easy) for the kernel to use up those resources without resolving the paging deadlock.
      Regardless of that, paging on linux and the BSDs has gotten a lot better over the years and is *extremely* effective in modern day. To the point where any workstation these days with decently configured swap space can leave chrome tabs open for months (slowly leaking user memory the whole time) without bogging the machine down. Even if 25GB of memory winds up being swapped out over that time. As long as you have the swap space configured, it works a lot better than people think it does.
      -Matt

  • @savantshuia
    @savantshuia Před 2 lety +101

    This is exactly why I love Linux, you can take full control of your computer, heck even delete you GUI or your bootloader.

    • @utfigyii5987
      @utfigyii5987 Před 2 lety +14

      I bought it, I wanna own it. That's why I go with linux on every pc I own

    • @qLeila
      @qLeila Před 2 lety +18

      Yea problem is when you do this on accident xD

    • @ignoolio12nera96
      @ignoolio12nera96 Před 2 lety +17

      Just like Linus did when installing Steam?

    • @cory1111
      @cory1111 Před 2 lety +13

      @@ignoolio12nera96 he’s literally illiterate. It told him many times not to do it. It’s entirely his fault

    • @alexevier
      @alexevier Před 2 lety +3

      sudo rm -rf /

  • @icraveforbananas2481
    @icraveforbananas2481 Před rokem +1

    "With this power, I can.. I can tell you about our spons-'
    **Skips**

  • @Tramelle
    @Tramelle Před 2 lety

    Quality Video, great editing and fun, SO MUCH BETTER THAN 3090 UNCLOCKING VIDEO.

  • @OsamaRana
    @OsamaRana Před 2 lety +4

    This was a splendid explanation of how swap storage works, and then it makes sense to use it. A+ animations to go along with the narration.

  • @WhoLover
    @WhoLover Před 2 lety +5

    1:37
    "To understand that, we need to talk about..."
    Pannenkoek fans: *trembling*

  • @moon200070
    @moon200070 Před 2 lety +1

    I was really hoping in the intro when he said "I can.. I can!" that he would say "Run a minecraft server", but fairplay with the segway Haha

  • @shawnrhode
    @shawnrhode Před 2 lety +3

    Rule of thumb regarding swap space on Unix/Linux is you never, ever, ever want to use swap. Even on an SSD like a Gen4 NVME, the performance is not nearly enough. The issue isn’t really bandwidth, it is latency. Sure, having more bandwidth to move data is nice, remember that when a process makes a call to load something from memory, that call blocks the processor in most cases because memory calls are not IO calls. They don’t have interrupts. As such, the longer the process waits for the first block of incoming data, the longer that process is blocking that core from doing pretty much anything else in user land (some interrupt driven calls can interrupt it, but the slice it has on the CPU is blocking). If you use swap, performance will basically come to a stand still.

    • @Ski4974
      @Ski4974 Před 2 lety +3

      lol no thats not a rule of thumb.
      For some cases, its absolutely necessary - for example, if I build AOSP on my laptop with 16GB RAM, it will get OOM killed if I don't have swap space.

    • @shawnrhode
      @shawnrhode Před 2 lety

      @@Ski4974 I wasn’t saying you shouldn’t have swap. But you don’t want to treat it like RAM. If you start swapping a lot, your performance will tank.
      If you are getting OOM killed when doing an AOSP build, you should make sure you aren’t set to use too much memory during the build. 16 GB should be more than enough to do the build without hitting swap space. You might also want to check your buffer caches and do a cache drop if a lot of filesystem caching is happening and not releasing fast enough. I used to run without any swap years ago in the 2.6 kernel days because drives were not that big then. Now I usually have around 4GB of swap even with lots of RAM since I want the stability of it as a “just in case” but don’t expect to use it.
      By the way, you should be able to turn off OOM kill in the sysctl settings.

    • @Ski4974
      @Ski4974 Před 2 lety

      @@shawnrhode Yeah it will probably be faster if I lower the jobs count and avoid swapping lol, ur right, I have 8c/16t so with that many jobs its bound to swap. And you're right, you don't just wanna assume your RAM = RAM + Swap. Thanks will check that :)

    • @shawnrhode
      @shawnrhode Před 2 lety

      @@Ski4974 yeah. You definitely want to avoid swapping if you can. Even if it ends up swapping out something unrelated that isn’t in high use, that is not guaranteed. When doing builds on multi core systems, it can be hard to find the right balance. However, if you start actively using swap as part of the build itself, you will find that CPU is always busy but not much is getting done because threads are waiting on swap in calls to finish. If you can get things to always stay in memory, performance will jump up. Just adjust the thread count to find the threshold then dial it back one or two threads for some breathing room for when the code base grows later (and they always do).

  • @samsai8989
    @samsai8989 Před 2 lety +31

    There is also another somewhat funky configuration you can apply to swap. You can basically also swap to RAM, which sounds completely stupid, but if you combine that with compression, it actually makes some sense. Assuming a good compression ratio, which can be as much as 50% in many typical workloads, you can basically end up with a fast (you only pay for compression/decompression) swap space and can technically squeeze more stuff into RAM, giving you "extra RAM for free".

    • @thibautsnoeijs
      @thibautsnoeijs Před 2 lety

      I've got an absolutely stupid idea that might work: swap inside of a raid array.

    • @shanek.6293
      @shanek.6293 Před 2 lety +3

      A lot of distros do this by default. Fedora uses zram which is almost exactly what you described with a few small differences. It's worth a read (and setting up on distros that don't have it on by default.)

    • @milesfarber
      @milesfarber Před 2 lety

      This problem doesn't exist on windows.

    • @XeZrunner
      @XeZrunner Před 2 lety

      Android phones do this nowadays, with swappiness set to 100.

  • @tratzz84
    @tratzz84 Před 2 lety

    I configured my 8gb ubuntu lately to have also 8gb of swap, which made it much more stable. By default ubuntu configures 1gb of swap.
    Combined with the package 'nohang', I've got zero freezes anymore on my linux laptop. Even when running VM's, with eclipse and lots of chrome-tabs.
    Using it the right way, it can help a lot!

  • @ModernRetroGameplay
    @ModernRetroGameplay Před rokem +1

    Yea my first thought was why not just go into windows system settings and set the page file manually? It takes 10 seconds. Also just fyi in 1 of the latest updates to windows OS they uped the default page file to 2GB so your not sitting at 16MB any more lol. I used to manually set mine to 8192MB-8192MB min/max which pretty much locks in your page file size at a flat number and helps alot when the page file comes into use so it doesnt have to manually expand it each time it caps with a variable min/max. I find with the update to windows it runs alot better on default then it used to but forcing it to sit at 8GB still works well. With a 16 core CPU id say try exactly what you did which is just ad a fast 1TB SSD than dedicate the entire drive as page file.

  • @Lamoosa
    @Lamoosa Před 2 lety +7

    Now get 100T

  • @carlosdot
    @carlosdot Před 2 lety +5

    3:59 Well… That’s how it feels on the PlayStation…

  • @seth181
    @seth181 Před rokem

    i know linus' ad intros so well at this point i always know when hes gonna go into it lol

  • @PixisFX.
    @PixisFX. Před rokem

    Great tutorial👍👍👍 I will be keeping this in mind next time i download ram 😃😃😃

  • @ChrisClark1999
    @ChrisClark1999 Před 2 lety +26

    By this definition you could technically download RAM, CPU and GPU power through a remote desktop

  • @joshhardin666
    @joshhardin666 Před 2 lety +19

    if you do lots of high memory usage tasks, I always recommend having about as much swap as you have ram for workstation configurations. modern operating systems are actually really good about what gets swapped and what remains in ram and it prevents systems from crashing when you run out of main system memory. my workstation has 128gb of ram, so I have 128gb of swap (spread out over my 3 nvme ssd's). this has improved my memory handling drammatically because stuff that isn't used RIGHT NOW gets swapped out leaving the remaining memory free for applications that require the lowest possible latency and highest possible bandwidth.

  • @Rhapsody_Sky
    @Rhapsody_Sky Před 2 lety

    With this segueway to the sponsor at the beginning I now just sit here and wait for LTT to create a Graphic-Card-Pillow that is never available in LLT-Store

  • @thomasafine
    @thomasafine Před 2 lety

    When I first go on the Internet in 1988, it was on Sun 3/50 workstations. We were running them diskless. They had no hard drive (or local storage of any kind besides RAM) at all. All files were served over Ethernet running at the amazing 10 Mbit/second. 10BaseT, which means subnets all shared that same 10Mbit/second (with collision loss and too).
    They DID have swap space. ON THE NETWORK. Swap was required back then, not optional. Swap had to at least match the memory. So swapfiles were network mounted. If these systems ran out of memory, they could continue to run, swapping over the network. The system was basically unusable at this point, but if a user was desperate because they had unsaved work, we would spend the half hour to run the commands needed to kill off processes until the machine became usable again.

  • @kice
    @kice Před 2 lety +10

    Modern OS expected to have page file / swap file to function properly and there are a lot of program will straight up ask for allocation of the page file. For any reason, if you want to turn off swap/paged file, check if you daily memory usage first, on windows it is the commit size not the actual RAM usage.
    Hope LTT include a test for comparing performance while having paged/swap file. on and off

    • @arjanscholl
      @arjanscholl Před 2 lety +1

      On top of this, some applications and games will straight up fail to run with the pagefile disabled on Windows. So turning it off is not a good idea

    • @shawn2780
      @shawn2780 Před 2 lety

      @@arjanscholl I get a kick out of people that do this especially on gaming systems and then complain when things randomly crash

    • @jeschinstad
      @jeschinstad Před 2 lety

      What Linux programs asks you to allocate swap? That sounds insane to me. I've been running Linux without swap for years. Never had an app ask me to please insert a swap file.

    • @johngangemi1361
      @johngangemi1361 Před 2 lety +1

      A user mode program should not care if a swap file exists or not as it is the Operating System kernel that allocates memory. Processes have to ask the OS for it in user mode.

    • @anandu6859
      @anandu6859 Před 2 lety +2

      @@jeschinstad In linux, the case is different. Application asks only for memory and linux decides to allocate the ram or swap to them. So in linux, it doesn't matter if you have swap space or not. But in windows, applications asks for page file. So in windows, it is necessary to have a page file

  • @darkxsuper
    @darkxsuper Před 2 lety +6

    congrats, keep the quality vids up

  • @thomaslechner1622
    @thomaslechner1622 Před 2 lety +4

    The intention of SSD swap is to avoid system crashes when running out of RAM. The intention is not to replace RAM, because it is much slower. If not even crashes can be avoided by enabling SSD swap (like in the video), I can see no point in using it at all.

  • @phylwx
    @phylwx Před 2 lety +1

    "But what if we use it in storage attached locally?" THEN IT ISN'T DOWNLOADING RAM, LINUS!

  • @lunatic911010
    @lunatic911010 Před 2 lety +6

    If you tried cod warzone on a swap you would see incredibly low framerates. I had a friend where warzone was hitting the swap file and tanking his fps. Bumping his ram from 8 to 16 gigs worked wonders to fix it.

    • @HululusLabs
      @HululusLabs Před 2 lety +2

      Not to mention if he went from single to dual channel, that'll help too

  • @DareDevilPhil
    @DareDevilPhil Před 2 lety +3

    Assuming the LAN server based swap was just a file served over SMB mounted as a loopback device, there's a better way to do it. On Linux there's the NBD protocol, which iirc can have optimisations enabled to be able to directly perform I/O on the server memory (DMA I believe) which reduces the network overhead of this kind of I/O considerably.
    I've done this once for a different purpose, maybe 5 years ago, I might be somewhat wrong.

  • @RileyIsPurple
    @RileyIsPurple Před 2 lety

    I love the example for Page File/ Swap Space.

  • @tomwimmenhove4652
    @tomwimmenhove4652 Před 2 lety +1

    Imagine if some of the code used by the kernel in any part of the chain from swapping to your mounted network filesystem allocates memory that can be swapped out. This can cause a loop in which the kernel tries to swap a page out, which call a bunch of code that allocated memory that causes another page to be swapped out.... I remember having this problem decardes ago when trying to setup a swap space over NFS (at least, I'm guessing that this is what was going on)

  • @simbiat
    @simbiat Před 2 lety +7

    I remember Windows had some feature that allowed USB drives to be used as extra RAM. I remember using it back in the day, when "Spider-Man 3" game was released and it did help a little bit, by giving me maybe like 2 FPS to original 20-something I was getting in the game.

    • @FriskGamer1
      @FriskGamer1 Před 5 měsíci +1

      ReadyBoost?

    • @simbiat
      @simbiat Před 5 měsíci

      @@FriskGamer1 yes, that's the one

  • @maesto
    @maesto Před 2 lety +4

    One big advantage of swap is when you have stuff that takes (lots of) RAM but doesn't actually use it to often. (Think VMs) There the performance hit isn't to dramatic since it's infrequently accessed anyways.

    • @jeschinstad
      @jeschinstad Před 2 lety

      For VMs, using KSM is quite a bit more lucrative though. You generally don't want to swap on VMs.

  • @TheBigBazzy
    @TheBigBazzy Před 2 lety

    It's so great to see more and more Linux videos popping up on mainstream channels.

  • @kyleboyer8542
    @kyleboyer8542 Před rokem +2

    With that much memory, you can maybe just maybe, open 4 google chrome tabs.

  • @RogueShadowTCN
    @RogueShadowTCN Před 2 lety +15

    A blast from the past. It's been a very long time since I've put together a PC with less than 32GB of ram. I remember swap, I remember...

    • @bite-sizedshorts9635
      @bite-sizedshorts9635 Před 2 lety

      The computer I'm using right now has only 8GB. It seems to work fine.
      I can record streaming audio, print documents, and have a bunch of browser windows open simultaneously, along with a number of other running programs, all without a problem. I do a lot of work on my computer.
      I currently have 20 browser instances running with multiple tabs on each, genealogy software (2 instances), a couple of file folders open, and Winamp shuffle playing a 200+ playlist of 70s hits. After a couple of weeks like this, I will finally gag the memory and have to save and close everything for a reboot. I guess I could go months between reboots with 32GB of RAM.
      I built the computer myself over 10 years ago, so I suppose I could add more RAM. I did replace the hard drive with an SSD.
      I've been at this long enough that my very first hard drive was 20MB and cost about $700.

    • @lightly-red-huedmaleindivi6266
      @lightly-red-huedmaleindivi6266 Před 2 lety

      8GB of RAM is more than enough for anything these days. You don't need 32GB of RAM unless you're using it for work.

  • @DantalionNl
    @DantalionNl Před 2 lety +5

    You will never see this... But to prevent Linux from crashing with swap you need to configure the reserved portion of system memory that the Kernel will keep free no matter how many programs try to allocate memory. These parameters are controlled through sysctl, involved settings include lowmem_reserve_ratio and user_reserve_ratio.

    • @philuhhh
      @philuhhh Před 2 lety

      is it generally necessary to alter these properties? If so, why aren't they the default? In Linux kernel world, I have generally learned to trust the default parameters.

    • @DantalionNl
      @DantalionNl Před 2 lety +1

      @@philuhhh It isn't unless you try to open half a dozen programs at once even though your memory is already full. Which is what the benchmark / stresstest they have is doing. These settings have performance implications as you can't fully utilize all of system memory anymore, so not having these as defaults outweighs the niche usecase of people opening 10 memory heavy apps at once with full system memory.
      Everyone is free to configure the memory subsystem for their usecase which is one of many things what makes Linux so flexible.

    • @philuhhh
      @philuhhh Před 2 lety +1

      @@DantalionNl I see, thanks!

  • @00SNIVY00
    @00SNIVY00 Před rokem

    I believe I went into my settings and turned swap off, only to end up with more crashes. Even when I limited the amount of swap to a lower amount, it still crashed more often than with it off, despite the amount I limited it to being more than what it claimed to be using.

  • @joker345172
    @joker345172 Před 2 lety

    Now we just need you to turn it around and use ram as disk space! I'd love a video in this style about ramdisks

  • @shockwaverc1369
    @shockwaverc1369 Před 2 lety +17

    you should use zswap to compress the swapped memory and double the bandwidth

    • @pumbi69
      @pumbi69 Před 2 lety +1

      But wouldn't that increase latency even more

    • @shockwaverc1369
      @shockwaverc1369 Před 2 lety +4

      @@pumbi69 cpu is faster than storage, so no