Not a member yet? Why not Sign up today
Create an account  

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Xanmod and vm.swappiness values

#1
Just surfing the web I found a way to tweak sysctl.conf to make the system faster. Smile
Code:
sudo gedit /etc/sysctl.conf

There is some customizable options inside the file for safer browsing too.
Code:
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3
##############################################################3
# Functions previously found in netbase
#
# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1
# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1
# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1
# Uncomment the next line to enable packet forwarding for IPv6
#  Enabling this option disables Stateless Address Autoconfiguration
#  based on Router Advertisements for this host
#net.ipv6.conf.all.forwarding=1
###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
#net.ipv4.conf.all.accept_redirects = 0
#net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
#net.ipv4.conf.all.accept_source_route = 0
#net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
#

I read that adding vm.swappiness=10 to the end of the file the system gets more performance. It's the only change that I have done because I don't understand the others too much by now, and it works nice for me.  Smile https://en.wikipedia.org/wiki/Swappiness

*
To know the current vm.swappiness value just type:
Code:
cat /proc/sys/vm/swappiness
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#2
I just added and tested the lines below and all is working nice, no problem at all. Smile

Code:
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.all.accept_redirects=0
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.all.accept_source_route=0
vm.swappiness=10
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#3
Coincidentally, I was thinking about it these days, to reduce by default the vm.swappiness value.  Need to test calmly because the system give greater priority in the swap when the memory is full is also an advantage. To empty the processes used less memory to save the performance. XanMod uses zswap with lzo algorithm for speed and transparency I/O united with the low latency BFQ, makes using the swap satisfactory. I will test calmly the possibility.
Reply

#4
Thank you, Xan, glad to help! Smile
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#5
You made me worried this morning, reading this forum. I thought I've entered some time warp or I'm getting more senile that I really am. That switch is being talked about for at least 6 to 7 years if not more. Just off-hand random search spilled on my native forum: this post of mine from 2010. ...
Oh boy, it goes even further:
1. swappiness
2. nsswitch.conf
3. sysctl...
A trip to the past... You make me feel so old, which I am... Wink
Isn't lz4 a bit faster than lzo?
"Everything has been thought of before, but the problem is to think of it again.“Goethe
Reply

#6
(27-12-2015, 07:12 AM)zika link Wrote: That switch is being talked about for at least 6 to 7 years if not more.

"Talking fixes nothing", my grandmother said.

(27-12-2015, 07:12 AM)zika link Wrote: Isn't lz4 a bit faster than lzo?

Best compression benchmark ever:
http://catchchallenger.first-world.info/...LZ4_vs_LZO

Probably you know more 6-7 years old forums talking about this. Wink

"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#7
(26-12-2015, 12:22 PM)tropic link Wrote:[quote author=zika link=topic=5.msg42#msg42 date=1451113056]How could it get better when it was not developed more the same day it was first presented? It's a one-time work and after that all that has been done (by Ubuntu, not by developer) is to re-compile it for new version... Wink It is OK but it's an orphan on birth, sadly. Nice idea but... I do use it but less and less often.
Probably it has got better Ubuntu version to work with.  Furthermore, near all people born after a one-time work and it's better to be orphan than having bad fathers, IMHO. 8)[/quote]
(27-12-2015, 09:24 AM)tropic link Wrote: [quote author=zika link=topic=8.msg59#msg59 date=1451200369]That switch is being talked about for at least 6 to 7 years if not more.
"Talking fixes nothing", my grandmother said.
(27-12-2015, 07:12 AM)zika link Wrote: Isn't lz4 a bit faster than lzo?
Best compression benchmark ever: http://catchchallenger.first-world.info/...ZOProbably you know more 6-7 years old forums talking about this. Wink[/quote]You win. I'll continue using it and my regards to Your grandmother. All the best to all.
"Everything has been thought of before, but the problem is to think of it again.“Goethe
Reply

#8
(27-12-2015, 07:12 AM)zika link Wrote: Isn't lz4 a bit faster than lzo?

Yeap. Lzo is default mainline. The next compilations will be lz4.
Reply

#9
To solve internet speed problems disabling IPV6 is recommended also:
https://help.ubuntu.com/community/WebBro...owIPv6IPv4
Sysctl.conf is very customizable. Linux is full of tweaks.  8)

Code:
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#10
Nice place for understanding better the sysctl.conf file and its benefits over TCP/IP stack hardening and get some protection against several internet attacks: Smile
https://wiki.archlinux.org/index.php/Sysctl

There are some other available different settings (vm.dirty, MDADM...), but the performance and the computer response under heavy online gaming were not good. After hours of intense use on three different computers with my friends, the next settings work amazingly with the XanMod kernel with safety and no problem at all.

Note: I have updated my sysctl.conf content as more performance and stability were observed with Linux Kernel 4.4.x branch and its XanMod derivate kernels. Tested in four computers with my friends help, no complaints done. Just remember that if any trouble is noticed, it's easy to turn back just editing the file and deleting the lines added at the end of it (it's better to add all the new lines at the end to locate them easily if needed):
$ sudo gedit /etc/sysctl.conf
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#11
Tropic, in next release removes vm.swappiness set. Because it will be by default "=1". 8) Wink
Reply

#12
(30-12-2015, 02:18 AM)Xan link Wrote: Tropic, in next release removes vm.swappiness set. Because it will be by default "=1". 8) Wink

Xan, did you mean vm.swappiness=1 or vm.swappiness=10?  ???
I'm testing 4.3.3-xanmod7 with vm.swappiness=1.  Tongue
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#13
In my tests, "1" presents problems when there is too much stress in big parallel workloads. With "10" is a safer value.
Reply

#14
(31-12-2015, 04:27 AM)Xan link Wrote: In my tests, "1" presents problems when there is too much stress in big parallel workloads. With "10" is a safer value.

I think you're right, it's better to get a safer value. Smile Thank you! Big Grin
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#15
(27-12-2015, 01:38 PM)Xan link Wrote: [quote author=zika link=topic=8.msg59#msg59 date=1451200369]
Isn't lz4 a bit faster than lzo?
Yeap. Lzo is default mainline. The next compilations will be lz4.
[/quote]

Why not LZ4HC? "Its compression ratio is typically 20% better than LZ4." Tongue
* http://www.findbestopensource.com/product/lz4hc
http://irtos.sourceforge.net/2000/Docume...ource.html
* https://github.com/Cl3Kener/UBER-N5/comm...b1732d7afd
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#16
Since xanmod-kernel is built with that option checked, others might not be, like mainline, it can be done by simple change in /etc/default/grub:
Code:
zswap.compressor=lz4
to
Code:
zswap.compressor=lz4hc
gives You
Code:
[    1.364035] zswap: loaded using pool lz4hc/zbud
Sadly, I do not get much chance to try it since I almost never get into using swap...
Caveat: By using HC You sacrifice some speed gained by using LZ4 compressor. So, as always, it is not for free. Decompression is not that slower so for swap it might make sense since You could be compressing once and decompressing many times. LZ4 is built for speed, compression rate is not its ultimate quality. So, if You're into compression rate You might want to look elsewhere. Even in field of speed there are ones much better than LZ4, not sure if they are awailable for zswap yet... Did not check for some time. LZ4 is not so much better in compression speed and ratio than LZO but is faster in decompression, as far as I know. I'll stop here, all this is off-topic since thread is about swappiness switch... Wink
"Everything has been thought of before, but the problem is to think of it again.“Goethe
Reply

#17
Thank you Zika for the info! The post is not off-topic, because vm.swappiness=10 means that the computer starts swapping when RAM is full at 90%. In a 2Gb RAM machine that means swapping when 1843 Mb are used instead of 1228 Mb (60%, the Linux kernel default), with a gain of 614 Mb. BTW in a modern machine with 16 Gb of RAM that would meant 614x8=4912 Mb gain for swap, near 4.8 Gb for cache before swapping. So the swap size should be small with the value of 10, and Lz4hc should manage it well. Smile

In fact, I introduced Lz4HC discussion because modern CPU should get profit of parallel multicore processing and also should get better use of low swap values -- because Lz4HC gives better speed ratios when lower values are decompressed. I wanted to talk first about LZturbo because "Lzturbo is a high performance lz77 based compressor featuring parallel compression/decompression and overlapping i/o, specially designed for modern processors and multicore systems", but as you said in your post, Lz4hc can be changed and I'm not sure too if LZturbo is available for zswap (as you pointed). Smile

http://compressionratings.com/i_lzturbo.html
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#18
You should take a good look into zram. I've played with it this holiday morning and with lz4 it is nice way of making Your memory look/act as larger. Just had to find the right place to make proper changes... Wink
"Everything has been thought of before, but the problem is to think of it again.“Goethe
Reply

#19
I was a former user of Zram and after some tweaking, Zram is close related to swappiness. In fact, with the default mainline kernel swappiness=60, I found that fraction=40 was the better value. The two values are related because vm.swappiness leaves % of "free" memory that you will use for Zram. For safety, if vm.swappiness=10, it should be fraction=9 to reserve free at least 1% to avoid OOM. I don't know to explain it better but I think you have understood what I meant clearly. Smile
"(...) the grandest occasion the past or present has seen, or the future can hope to see." -- Cervantes.
Reply

#20
I was aiming into pushing everything into swap so the swappiness value I've used is, of course, 100... Wink
I do understand what You've wrote but my goal was quite opposite.. Wink After 11.01, when I come back to work, I will test that on 2GB machines so that my users might be pleasantly surprised or totally angry, we'll see...
"Everything has been thought of before, but the problem is to think of it again.“Goethe
Reply



[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Forum Jump:


Users browsing this thread:
1 Guest(s)