We have moved to a new Sailfish OS Forum. Please start new discussions there.
18

Fix/Reduce lags on 1.1.0.3x (Update 9)

asked 2014-11-12 14:51:45 +0300

leszek gravatar image

updated 2014-11-12 14:54:15 +0300

As mentioned in the update 9 the UI can stutter in low memory situations. As I am a heavy multitasking user I stumbled upon and wanted to provide me a fix for this.
This fix works for me as it reduces the amount of stutter noticeably. However this might be not the ideal solution for every user.

Basically what I did was tweaking the vm.swappiness handling. The default value is set to 30 which is around half of the default value of the linux kernel and in easy terms means swap out not too early . The problem I encountered that this value seems to low as it swap outs too late which causes stutter in the ui. So I just simply raised the value to 100 which in easy terms means swap out as early as possible. Of course this makes overall system performance a little less fast but there I don't suffer from long lags due to full running ram anymore.

In easy terms. Its just like on modern gaming consoles. A 60 FPS rate is nice to have (like the default vm.swappiness 30) but it is noticeable when the framerate drops drastically on fast actions or many stuff being rendered. Reducing to a healthy 30 FPS (vm.swappiness 100) makes performance a little slower but the system is more able to render this framerate constantly and a big break down of the framerate is not observed.

If you want to try it out I recommend to do a backup of the file /etc/sysctl.d/vm.conf . You need developer mode enabled and have to edit this file with devel-su rights. Change the vm.swappiness=30 to vm.swappiness=100 . To apply the change either reboot or enter sysctl -p /etc/sysctl.d/vm.conf

Also for all still running the older 1.0.x version and having zram module installed (from warehouse). This change should be ideal as swapping out early onto a compressed swap is much faster than onto a swap partition/file on the internal flash.

Would be interesting if testers could provide feedback for this.

edit retag flag offensive close delete

Comments

2

When user becomes heavy multitasker with Jolla?

I typically have 3 to 7 open apps such as Mitäkuuluu, Jolla Message app, Jolla browser, Jolla email with three accounts activated, Phone app, Persons app and Settings App

Is this already heavy multitasker situation from Jolla point of view?

I have not updated yet to 1.1.0.3x (Uitukka) due to low memory warnings, but I have to say that also the SF OS 1.0.8.21 Tahkalampi seem to have similar issues continuously. I don't have applied the ZRam module either - Should I do that before trying this fix?

If I would proceed with the fix, how to edit the designated file with terminal app?

Kari ( 2014-11-12 16:12:21 +0300 )edit

Yeah I would say all above 4 apps (also depending on the apps mostly also) falls into the category of heavy multitasker. But of course multitasking also implies switching between open apps often and doing parallel jobs in them.

If you didn't already tried the zram module and zram config package on 1.0.x I would recommend trying it first with the defaults and then with the vm.swappiness change and see it for yourself if it improves your workflow.

For editing text files in terminal I personally use vi . But the vi text editor is not for everyone. I don't think there is any other text editor preinstalled on SailfishOS that works in the command line. So here a link for a vi in 10 minutes documentation: http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html

Step by step:

  1. open terminal

  2. type in devel-su

  3. enter your password (password set in settings development mode)

  4. type in vi /etc/sysctl.d/vm.conf

  5. Use arrow or j key to navigate cursor down to the 3 of 30

  6. Press c followed by w (means replace word)

  7. Type in 100

  8. Press ESC

  9. Type in :wq (means write and quit)

leszek ( 2014-11-12 16:23:27 +0300 )edit

Thank you very much for the instructions to make the update of the VM.conf file

I wonder would it be good to make the swappiness change before the Zram installation?

Less tinkering for the inexperienced user ;)

Kari ( 2014-11-12 16:30:22 +0300 )edit

I would recommend first installing zram. (but that module only works on 1.0.x) As for inexperienced users. All those changes are more targeted for advanced users who are able to undo all changes without a guide to help them.

All in all zram is the solution that will come in update 10 most probably so I would recommend testing it if you have the chance. Together with the vm.swappiness it could make a good pair when it comes to multitasking.

leszek ( 2014-11-12 16:35:42 +0300 )edit

Kudos for the initiative of tweaking things and sharing your findings, however, there might be a pretty unpleasant side effect to setting the vm.swappiness to 100.

Although I am not an expert on this topic, my first thought when thinking about "swapping as early as possible" is the fact that it is done on flash memory which has a limited number of writes in its lifetime. The default value of 30 might have had this aspect taken into consideration by the sailors at Jolla.

Some related articles on this topic:

http://unix.stackexchange.com/questions/88693/why-is-swappiness-set-to-60-by-default/88820

http://unix.stackexchange.com/questions/34034/what-is-the-appropriate-value-of-vm-swappiness-when-using-zram

Drekkarian ( 2014-11-12 23:33:31 +0300 )edit

3 Answers

Sort by » oldest newest most voted
9

answered 2014-11-14 16:10:37 +0300

Philippe De Swert gravatar image

100 is a bit extreme. Especially as in most cases extreme values are not the right way to go.

I have this tweaked /etc/sysctl.d/vm.conf file

# delay writeback time
vm.dirty_writeback_centisecs = 1500

# reduce swappiness to enhance the response to interactive
vm.swappiness = 40

# Limit amount of stuff in cache
vm.dirty_background_ratio = 5

# max amount of memory available for dirty pages
vm.dirty_ratio = 10

Which seems to work quite well for me. It tweaks a few more values and is imho more balanced than the don't keep anything in memory and push it to swap asap (as that approach will soon hit IO issues if memory fills up).

All feedback on experiences and tunings other people have tried are always good to hear.

edit flag offensive delete publish link more

Comments

than the don't keep anything in memory and push it to swap >asap (as that approach will soon hit IO issues if memory fills >up).

Setting 100 does not mean that don't keep anything in memory. It just means move unused stuff out faster leaving more ram free for file caches and other applications. But sure it's a controversial topic as even kernel developers themselves discuss this topic for years with completely different opinions.

leszek ( 2014-11-14 16:25:42 +0300 )edit

For those who do not like vi editor:

  1. ssh into your phone
  2. devel-su
  3. enter your passwrd
  4. mv /etc/sysctl.d/vm.conf /etc/sysctl.d/vm_old.conf
  5. cat>/etc/sysctl.d/vm.conf
  6. copy paste from above Philippe De Swert message
  7. press CTRL+D
  8. chech file with cat /etc/sysctl.d/vm.conf
  9. reboot && exit
tvicol ( 2014-11-14 16:31:39 +0300 )edit
3

@leszek: asap == as soon as possible. Which pretty much does mean don't keep anything in memory that can be moved out. Indeed to free up memory for new apps. And that is unused stuff (of course how quickly something gets marked as that etc is all up for grabs, even the meaning of asap is stretchable) But yes the whole topic is quite complex and open for discussion. And open for misunderstandings as what I feel just happened. And yes 100 might work quite well if you have zram enabled as that will compress things when swapping out. However once you start hitting the disk swap and low memory 100 might be way too agressive and you will hit IO stalls. That is why my approach tries at the same time to limit the amount of dirty pages that can fill up ram, trying to balance between swapping out, caching stuff and keeping ram free.

Of course depending on use cases, personal usage behaviour etc... experience might vary also. What works well for you might not for somebody else.

Philippe De Swert ( 2014-11-14 16:49:24 +0300 )edit

@Philippe De Swert as I already requested earlier, would the vm.conf settings you proposed above help the memory handling even the Zram is not installed.

Kari ( 2014-11-15 14:53:35 +0300 )edit

@Kari it should help. But this post is also to evaluate if it does in all use cases. Therefor I would suggest you try it out if you know how to do it. I tested both my own vm.swappiness=100 and Philippe De Swert solution. They both work fine for my work case though I like a bigger cache sometimes as it tends to make things smoother.

leszek ( 2014-11-15 15:05:49 +0300 )edit
3

answered 2015-01-24 05:27:42 +0300

droll gravatar image

updated 2015-01-25 03:09:17 +0300

foss4ever gravatar image

With latest update 1.1.1.27 lags seem to be gone for me. Mine was related to swapping. I have 6 days of uptime and the device is DELIGHTFULLY silky smooth like after a fresh boot. i am a happy user.

EDIT: all problems pointed in the Q seems to have been resolved in update10 for me, too.

edit flag offensive delete publish link more
1

answered 2014-12-20 12:50:11 +0300

simo gravatar image

I'm not experiencing lags in normal multitasking after update 10. Solved?

edit flag offensive delete publish link more

Comments

renderer is dropping frames way less, for sure. though loading / processing / 'thinking' times seem to have increased across the board for 1.1.1

meowmeow ( 2014-12-20 13:25:43 +0300 )edit
Login/Signup to Answer

Question tools

Follow
4 followers

Stats

Asked: 2014-11-12 14:51:45 +0300

Seen: 2,519 times

Last updated: Jan 25 '15