LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-31-2024, 09:57 AM   #31
garpu
Senior Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 1,617

Original Poster
Rep: Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935

Quote:
Originally Posted by pan64 View Post
But if you have more RAM because there is no swap in (z)ram the OS will have more room to avoid swapping. It will "automatically" lower that memory pressure.

Anyway, here is a link about swap: https://chrisdown.name/2018/01/02/in...e-of-swap.html
That was interesting. (And basically I should stop trying to micro-manage what my box does with its swap...)
 
Old 05-31-2024, 12:00 PM   #32
Aeterna
Senior Member
 
Registered: Aug 2017
Location: Terra Mater
Distribution: VM Host: Slackware-current, VM Guests: Artix, Venom, antiX, Gentoo, FreeBSD, OpenBSD, OpenIndiana
Posts: 1,022

Rep: Reputation: Disabled
Quote:
Originally Posted by Petri Kaukasoina View Post
What do you mean by files in swap? Processes have memory pages in RAM and after swapping to ZRAM, the memory pages are still in RAM, only compressed.
If the system starts swapping out memory pages to free space for other applications, the passwords will be written unencrypted. No?

This is really bizarre: zram was introduced in 2014. ZSWAP even earlier. Nothing new there. Whoever really needs it should be using it for some time now.

It still baffles me why one would disable swap (in any form) because system will still swap if needed by memory (RAM) constrains.

Personally I always try to configure system so it uses memory without swapping (but swap configured). Now with swappiness 200 there is opposite trend. Thank God this is not mandatory.

Last edited by Aeterna; 05-31-2024 at 12:03 PM.
 
Old 05-31-2024, 12:27 PM   #33
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,960

Rep: Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571
Quote:
Originally Posted by Aeterna View Post
If the system starts swapping out memory pages to free space for other applications, the passwords will be written unencrypted. No?
The password will stay in RAM if the swap is in ZRAM.

Quote:
Personally I always try to configure system so it uses memory without swapping (but swap configured). Now with swappiness 200 there is opposite trend.
If swap is using a faster medium (RAM) than programs (SSD or especially HDD), it's better to prefer evicting other pages than program code, because faulting program code pages back is slower.

Last edited by Petri Kaukasoina; 05-31-2024 at 12:28 PM.
 
Old 05-31-2024, 01:06 PM   #34
Aeterna
Senior Member
 
Registered: Aug 2017
Location: Terra Mater
Distribution: VM Host: Slackware-current, VM Guests: Artix, Venom, antiX, Gentoo, FreeBSD, OpenBSD, OpenIndiana
Posts: 1,022

Rep: Reputation: Disabled
Quote:
Originally Posted by Petri Kaukasoina View Post
The password will stay in RAM if the swap is in ZRAM.



If swap is using a faster medium (RAM) than programs (SSD or especially HDD), it's better to prefer evicting other pages than program code, because faulting program code pages back is slower.
Explain why swap should be encrypted for privacy reasons.
If you need to force swapping, just to use ZRAM.. Just use enough RAM.
..and someone noticed faster FF with ZRAM. That is just exetutable running. Sounds like really subjective measurements.

ZRAM/ZSWAP are pretty old. Why now such a fuss?
 
Old 05-31-2024, 01:24 PM   #35
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,960

Rep: Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571
Quote:
Originally Posted by Aeterna View Post
Explain why swap should be encrypted for privacy reasons.
I wouldn't say it should be encrypted. I have never done that. But if swap is written on a disk and you lose your computer, whoever finds it can read the swap from the disk, just like the contents of the file systems.
Quote:
Originally Posted by Aeterna View Post
ZRAM/ZSWAP are pretty old. Why now such a fuss?
Because of this:
Code:
Tue May 28 18:08:19 UTC 2024
a/sysvinit-scripts-15.1-noarch-17.txz:  Rebuilt.
  rc.S: enable swapping on a ZRAM device, configurable in /etc/default/zram.
 
Old 05-31-2024, 01:58 PM   #36
slackerDude
Member
 
Registered: Jan 2016
Posts: 158

Rep: Reputation: Disabled
Quote:
Originally Posted by Aeterna View Post
Personally I always try to configure system so it uses memory without swapping (but swap configured). Now with swappiness 200 there is opposite trend. Thank God this is not mandatory.
Did you read the linked article? Unless you set swappiness to 0 (default is 60) which is a special hack, it only adjusts whether to prefer swapping-out (reclaiming for reuse) memory pages allocated to programs (through malloc, etc), or to prefer swapping out / dropping file-backing pages (i.e. disk cache, etc). Malloced-priority = swappiness, file-priority = 200 - swappiness, and it's the relative priorities which matter. So a setting of 60 results in 60 for malloc, 140 for files, so file pages are preferred for page reclamation roughly 2-1.

It doesn't really affect how much "swapping" happens. Of course, if you set it to 1, it will just free up any and all disk cache before writing program-allocated-pages to swap. That is still a form of "swapping" - the kernel will have to re-read those disk pages if you try to access those files again, it just doesn't have to write unmodified pages. Modified disk pages still have to be written to disk before being re-read, etc.

Now, as the article states, your workload will greatly affect what value of swappiness works best for you. If your program reads a huge file into RAM and then works on it for a long time without any I/O, swappiness of 1 (or 0) may be best for you, since you'll never need those file-caching pages again. Or even the default 60 for an HDD based system, where random reads are expensive. For an SSD system, it says things are about equally expensive, so swappiness of 100 may be best.

I guess with zram (or zswap), swapping malloced pages in/out is faster/preferred (since it's all in ram, no disk i/o), so swappiness of 200 tells the kernel highly prefer "swapping" malloced pages.
 
Old 05-31-2024, 02:30 PM   #37
rizitis
Member
 
Registered: Mar 2009
Location: Greece,Crete
Distribution: Slackware64-current, Slint
Posts: 722
Blog Entries: 2

Rep: Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533
I m using google translate I hope its translated "ok":

Quote:
ZRAM/ZSWAP are pretty old. Why now such a fuss?
I think its has to do with bcachefs which is the other (optional) new incoming in our system.
Because there are benefits to using bcachefs and ZRAM in the same system, particularly in improving performance and efficiency in specific use cases.
combining Bcachefs and ZRAM can lead to a more efficient and performant system, particularly in environments where memory and storage resources are constrained. By leveraging the strengths of both technologies, you can achieve improved responsiveness, better resource utilization, and enhanced overall performance.

Examples:
Bcachefs can handle large amounts of data efficiently, with features like CoW and compression. Adding ZRAM can further optimize memory usage, reducing the need to swap to disk and leveraging faster in-memory compression.

Bcachefs uses fast storage for caching slower devices. With ZRAM, some of this caching can occur in compressed memory, reducing I/O latency.

RAM decreases the frequency and volume of disk swapping, which can significantly speed up systems with limited RAM. This complements Bcachefs's performance optimizations by ensuring that more data can be handled quickly in memory.

and more similar examples... BUT all examples related for old hardware systems. When I say old dont mean only potato systems...

For me its good that PAT want to support everyone`s hardware... not everyone can buy a modern machine... (speaking for my self also) and all these new adds (Bcachefs, zram) giving a hope...

Quote:
@Petri Kaukasoina
NOW what happening in "modern" (hardware)systems and "modern" (software)technology like ai models:

If you have plenty of RAM-CPU (I m not using vram) and your AI models run fine, introducing ZRAM indeed introduce unnecessary overhead and potential problems, particularly with CPU usage. ZRAM uses CPU resources to compress and decompress data, which counterproductive if your CPU is already heavily utilized by AI model computations.
Issues I had using ZRAM (When You Have Plenty of RAM)
CPU Overhead:
ZRAM compresses data in memory, which requires CPU cycles. If your CPU is already busy with AI model computations (much more busy than compile QT6 for example), this additional overhead can lead to performance degradation.
The time and resources spent on compression/decompression outweigh any potential memory efficiency gains (especially when you have sufficient RAM)

With ample RAM, the primary benefit of ZRAM (reducing swap usage) is moot since your system doesn't need to swap to disk frequently, if at all.
end up using CPU resources for ZRAM that is much better utilized for your AI workloads.

=========
Conclusion:
Modern systems: if user have ample RAM-CPU and AI models are running fine, introducing ZRAM not be necessary and cause CPU-related performance issues. It is best to avoid ZRAM in this scenario and focus on optimizing your system's existing resources (if needed).
And the same I think for any other scenario... just not needed.

NOT-Modern systems: It might help a lot.

Last edited by rizitis; 05-31-2024 at 02:41 PM.
 
1 members found this post helpful.
Old 05-31-2024, 02:44 PM   #38
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,960

Rep: Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571
Quote:
Originally Posted by rizitis View Post
With ample RAM, the primary benefit of ZRAM (reducing swap usage) is moot since your system doesn't need to swap to disk frequently, if at all.
end up using CPU resources for ZRAM that is much better utilized for your AI workloads.
If the system doesn't swap, ZRAM uses zero CPU.
 
Old 05-31-2024, 03:05 PM   #39
rizitis
Member
 
Registered: Mar 2009
Location: Greece,Crete
Distribution: Slackware64-current, Slint
Posts: 722
Blog Entries: 2

Rep: Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533
Quote:
Originally Posted by Petri Kaukasoina View Post
If the system doesn't swap, ZRAM uses zero CPU.
Yes thats true, but what i said its not in theory... i can reproduced!
I m speaking for the slackware setup in /etc/defaults/zram
There are several explanations , but what is the true i dont know:
The `zstd` compression algorithm, while efficient, can still be CPU-intensive under certain conditions?
Allocating too much RAM to ZRAM can cause the system to handle more compression/decompression than necessary?
ZRAM has a high priority, the system might prefer it over regular RAM under certain conditions, leading to unnecessary CPU usage ?
Kernel bugs or inefficiencies in the handling of ZRAM in specific setup?
Hardware setups might not interact well with ZRAM, leading to performance issues?
The memory management and compression/decompression tasks associated with ZRAM are conflicting with the intensive memory and CPU demands of AI models (this is what I belive)
 
Old 05-31-2024, 03:25 PM   #40
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,960

Rep: Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571
Quote:
Originally Posted by rizitis View Post
Yes thats true, but what i said its not in theory... i can reproduced!
I m speaking for the slackware setup in /etc/defaults/zram
There are several explanations , but what is the true i dont know:
The `zstd` compression algorithm, while efficient, can still be CPU-intensive under certain conditions?
Allocating too much RAM to ZRAM can cause the system to handle more compression/decompression than necessary?
ZRAM is a block device. Like a hard disk drive is a block device. If you don't write anything to it, it doesn't do anything.
Quote:
ZRAM has a high priority, the system might prefer it over regular RAM under certain conditions, leading to unnecessary CPU usage ?
The swap priority only selects which swap is used first, zram or swap partition or swap file. It does not change "swappiness". If you have a swap on a disk drive and 'free' shows no swap usage, there won't be any usage after changing to swap on ZRAM.
Quote:
Kernel bugs or inefficiencies in the handling of ZRAM in specific setup?
Hardware setups might not interact well with ZRAM, leading to performance issues?
The memory management and compression/decompression tasks associated with ZRAM are conflicting with the intensive memory and CPU demands of AI models (this is what I belive)
It would really be helpful if you showed the output of command 'free'. And 'swapon'.
 
Old 05-31-2024, 03:42 PM   #41
rizitis
Member
 
Registered: Mar 2009
Location: Greece,Crete
Distribution: Slackware64-current, Slint
Posts: 722
Blog Entries: 2

Rep: Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533
Ok, tomorrow i will reproduce everything and give all informations here....
 
Old 05-31-2024, 09:10 PM   #42
Aeterna
Senior Member
 
Registered: Aug 2017
Location: Terra Mater
Distribution: VM Host: Slackware-current, VM Guests: Artix, Venom, antiX, Gentoo, FreeBSD, OpenBSD, OpenIndiana
Posts: 1,022

Rep: Reputation: Disabled
Quote:
Originally Posted by Petri Kaukasoina View Post
I wouldn't say it should be encrypted. I have never done that. But if swap is written on a disk and you lose your computer, whoever finds it can read the swap from the disk, just like the contents of the file systems.

Because of this:
Code:
Tue May 28 18:08:19 UTC 2024
a/sysvinit-scripts-15.1-noarch-17.txz:  Rebuilt.
  rc.S: enable swapping on a ZRAM device, configurable in /etc/default/zram.
I tried ZRAM in the past. Because ZRAM was available, so were scripts. However with 32GB RAM I did not see any swapping. Because I have laptop and need swap for hybernation, it make more sense to use ZSWAP.

@slackerDude
setting vm.swappiness it is not enough obviously. The link link discusses and explains how vm.swappiness affects vm management, not what do do to keep system in RAM. You need to configure vm.dirty_background_ratio, cache_pressure, overcommit, dirty_ratio, vm.vfs_cache_pressure and test best settings.
I had
vm.swappiness = 10
plus bunch of other options enabled before setting up ZSWAP.
ZSWAP has other sysctl (vm) requirements to get compression working.



@rizitis
select lz4.this is fastest (relatively lightweight) compressor. It is not as efficient compressor as other options.

If you do not have problems with swapping forget all about all this optimizations. Just leave it alone or blacklist module.
Nothing is free ZRAM and ZSWAP are useful but not when set up blindly. Both require more than just configuring zram config file. Check out vm optimizations too.
 
Old 06-01-2024, 01:46 AM   #43
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,960

Rep: Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571Reputation: 1571
Quote:
Originally Posted by rizitis View Post
Load models with zram make crazy cpu 498% of use...
Quote:
Originally Posted by rizitis View Post
Ok, tomorrow i will reproduce everything and give all informations here....
In addition to 'free' and 'swapon': Both with and without ZRAM, show those lines of 'ps auxw' which are about your program. There we can see %CPU VSZ RSS.

Last edited by Petri Kaukasoina; 06-01-2024 at 01:53 AM.
 
Old 06-01-2024, 02:40 AM   #44
rizitis
Member
 
Registered: Mar 2009
Location: Greece,Crete
Distribution: Slackware64-current, Slint
Posts: 722
Blog Entries: 2

Rep: Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533
I have attached one output with zram and one no_zram.

what i realized is that I have a on top output
Code:
 5017 root      20   0   43.6g   8.9g   7.1g S 863.6%  14.2   9:35.22 chat
which probably I understand it wrong because it exist in both zram and no_zram.
So to be sure I added an mpstat -P ALL output in my script and re-run script...
The output of mpstat -P ALL output dont look like a 863.6% of cpu...

So I m waiting to explain me what is what...
thanks.
Attached Files
File Type: txt no_zram_output.txt (41.5 KB, 3 views)
File Type: txt zram_output.txt (41.9 KB, 3 views)
 
Old 06-01-2024, 02:41 AM   #45
rizitis
Member
 
Registered: Mar 2009
Location: Greece,Crete
Distribution: Slackware64-current, Slint
Posts: 722
Blog Entries: 2

Rep: Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533
Quote:
Originally Posted by Petri Kaukasoina View Post
In addition to 'free' and 'swapon': Both with and without ZRAM, show those lines of 'ps auxw' which are about your program. There we can see %CPU VSZ RSS.
I havent see your last post but i think you are ok even with what I provide... if no tell me.
the programm we are interest is "chat"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: ZRAM Finally Promoted Out Of Staging In Linux Kernel LXer Syndicated Linux News 0 12-19-2013 06:50 AM
LXer: zRAM Is Still Hoping For A Promotion LXer Syndicated Linux News 0 11-26-2013 02:41 AM
LXer: ZRAM Might Finally Be Moved Out Of Linux Staging LXer Syndicated Linux News 0 08-15-2013 08:10 AM
LXer: Ubuntu Linux Considers Greater Usage Of zRAM LXer Syndicated Linux News 0 12-08-2012 03:30 PM
LXer: Increased Performance In Linux With zRam (Virtual Swap Compressed in RAM) LXer Syndicated Linux News 8 10-04-2011 12:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration