Closed Bug 929945 (128RAM) Opened 6 years ago Closed 5 years ago

[META][Tarako] Enable 128RAM config

Categories

(Firefox OS Graveyard :: General, defect)

defect
Not set

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: ying.xu, Assigned: seinlin)

References

(Depends on 4 open bugs)

Details

(Whiteboard: [tarako])

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
Depends on: 925628
Action 1.
In sprd code tree, udpate sprd_patch, cd sp7710lc_gonk, patch kernel_memory.patch to kernel project and patch  uboot_memory.patch to uboot project. 
Build u-boot and kernel, then flash them, and you can get a 128RAM system.

How to build and flash u-boot ?
cd u-boot direcotry, patch the code, make sp7710g2_config&&make -j4, u-boot.bin would be output in current path.Then, adb reboot bootloader, fastboot flash 2ndbl u-boot.bin

How to build and flash kernel ?
cd kernel directory, patch the code,exit the directory ,then make bootimage -j4, boot.img would be output in out/target/product/sp7710xxx/ path.
After that, adb reboot bootloader, fastboot flash boot boot.img and fastboot reboot
Action 2.
After action 1 was be done, system would be runnning at 128m ram config.But a few apps would run faulty.

There are some other patched such as zram ,swap ,low memory killer that may improve these faults.
I'm working on that.
ying.xu, I have a basic question. Why is 128RAM setting necessary?
Flags: needinfo?(ying.xu)
(In reply to ying.xu from comment #1)
> Action 1.
> In sprd code tree, udpate sprd_patch, cd sp7710lc_gonk, patch
> kernel_memory.patch to kernel project and patch  uboot_memory.patch to uboot
> project. 
> Build u-boot and kernel, then flash them, and you can get a 128RAM system.
> 
> How to build and flash u-boot ?
> cd u-boot direcotry, patch the code, make sp7710g2_config&&make -j4,

you may need this command to build kernel.
TARGET_HVGA_ENABLE=true make bootimage to set the screen at HVGA resolution


> u-boot.bin would be output in current path.Then, adb reboot bootloader,
> fastboot flash 2ndbl u-boot.bin
> 
> How to build and flash kernel ?
> cd kernel directory, patch the code,exit the directory ,then make bootimage
> -j4, boot.img would be output in out/target/product/sp7710xxx/ path.
> After that, adb reboot bootloader, fastboot flash boot boot.img and fastboot
> reboot
Flags: needinfo?(ying.xu)
What i can answered is to provide our customers more choices.

We are still evaluating the system with 128RAM right now.
Wish do this with you people together.


(In reply to Sotaro Ikeda [:sotaro] from comment #3)
> ying.xu, I have a basic question. Why is 128RAM setting necessary?
(In reply to ying.xu from comment #5)
> What i can answered is to provide our customers more choices.

Thanks.
(In reply to Sotaro Ikeda [:sotaro] from comment #3)
> ying.xu, I have a basic question. Why is 128RAM setting necessary?

Make FFOS more competitive, because Tizen only need 128M ram.
One thing you might want to give it a try is the Nuwa template child process (bug 771765), which is already on m-c and is targeted on 1.3. You might need to rebase your code base to the recent m-c if you are behind.

In summary, Android has zygote and Nuwa does similar, just that we take a more hacky (read: aggressive) approach to clone the process while it already has a dozen of threads.
(In reply to Cervantes Yu from comment #8)
> One thing you might want to give it a try is the Nuwa template child process
> (bug 771765), which is already on m-c and is targeted on 1.3. You might need
> to rebase your code base to the recent m-c if you are behind.
> 
> In summary, Android has zygote and Nuwa does similar, just that we take a
> more hacky (read: aggressive) approach to clone the process while it already
> has a dozen of threads.

OK, fugu is also support FFOS v1.3, we'll try Nuwa.
By the way, android4.4 also use low memory mechanism, like zram/ksm/swap ...
Blocks: 930359
Attached file memory-report-nuwa.tgz
Memory report of fugu with 128MB when nuwa is enabled.
James, please also attach the patches from kernel side, such as zRAM, Low memory killer.
Flags: needinfo?(james.zhang)
ying.xu will provide these patches before 11.7
Flags: needinfo?(james.zhang)
Flags: needinfo?(ying.xu)
add three more patches to enable zram and swap function..Please update.

bionic                      63f50ab5532af842f885d1d1001c938578ebe95f
system/core/toolbox         ea9c356847ef6469ef922f350bf1da374bd40d93
device/sprd/sp7710lc_gonk   41297133d44bb64e2fff542fc25c57cecef6737c

you can adjust zram and swap parameters referring this commit
device/sprd/sp7710lc_gonk   41297133d44bb64e2fff542fc25c57cecef6737c

currently, swap space is pointed to zram space. code is located in device/sprd/common/tools/swap/zram.sh
And you can change the swap space to other places as you wish(recommend external sdcard ).

please select sp7710lc_gonk-userdebug as your lunch device by adding these code into config.sh.
Otherwise, you need source build/envsetup.sh ,lunch devices and make manually.
And don't forget to apply the patches located at path  sprd_patch/sp7710lc_gonk before build.

@@ -222,6 +222,14 @@ case "$1" in
 	echo LUNCH=sp7710ga_gonk-eng >> .tmp-config &&
 	echo GONK_VERSION=SP7710_13A_W13.39.7 >> .tmp-config &&
 	repo_sync $1
+    ;;
+
+"sp7710lc_gonk4.0")
+	echo DEVICE=sp7710lc_gonk >> .tmp-config &&
+	echo LUNCH=sp7710lc_gonk-eng >> .tmp-config &&
+	echo TARGET_HVGA_ENABLE=true >> .tmp-config &&
+	echo GONK_VERSION=SP7710_13A_W13.39.7 >> .tmp-config &&
+	repo_sync sp7710ga_gonk4.0
 	;;
 
 "sp7710ga_gonk4.1")
@@ -374,6 +382,7 @@ case "$1" in
 	echo - sp7710ga_gonk4.0_nokia ======================= Sprdroid4.0, gecko/gaia@sprdroid4.0.3_vlx_3.0_b2g,nokia style homescreen and lockscreen, gonk@sprdroid4.0 and sprdlinux3.0
+	echo - sp7710lc_gonk4.0 ======================= Sprdroid4.0, gecko/gaia@sprdroid4.0.3_vlx_3.0_b2g, gonk@sprdroid4.0 and sprdlinux3.0, 256M ROM, 128RAM
Flags: needinfo?(ying.xu)
ying.xu, pls tell steven how to appy sprd_patch.
Flags: needinfo?(ying.xu)
Steven,

    cd sprd_patch
    ./patch.sh sp7710ga_gonk4.0
    ./patch.sh sp7710lc_gonk
Follow comment 13 and got another memory report. But the over UX is still not good enough.

---------------------------
memory-report-nuwa + zram
---------------------------
System memory info:
            Total 119.1 MB
     Used - cache  89.0 MB
  B2G procs (PSS)  68.1 MB
    Non-B2G procs  20.9 MB
     Free + cache  30.1 MB
             Free   3.6 MB
            Cache  26.5 MB


---------------------------
memory-report-nuwa
---------------------------
System memory info:
            Total 111.0 MB
     Used - cache  88.8 MB
  B2G procs (PSS)  68.9 MB
    Non-B2G procs  19.9 MB
     Free + cache  22.1 MB
             Free   3.6 MB
            Cache  18.5 MB
Kai-Zhan, did you try the patches in comment 15?
Flags: needinfo?(kli)
(In reply to styang from comment #17)
> Kai-Zhan, did you try the patches in comment 15?

Yes, I use the patch as in comment 15.

    ./patch.sh sp7710ga_gonk4.0 ---> Partially inlucded. This is for SPRDFM and some customization such mute and some webaaps, but SPRDFM build failed I didn't inlcude SPRDFM.

    ./patch.sh sp7710lc_gonk  ---> All included. This is for 128MB Ram in boot.img and kernel.
Flags: needinfo?(kli)
Hi James, From the memory info in comment 16, we can see Non-b2g process consume about 20MB.
In my observation Non-b2g process could consume about up to 25~26MB when some app were lunched.
Could you help to sort if any native process can be disabled or removed?
Thanks!
Flags: needinfo?(james.zhang)
to ying, please give kai-zhen more information about non-b2g process, for example, slog, engmode, media server ...
Flags: needinfo?(james.zhang)
It may take us some time to dig.
I think these modifications may have been done on our android system before FFOS.

And If you don't mind ,can you tell me how to generate memory statistics like yours?
So I can know how to count the Non-b2g processes.

(In reply to Kai-Zhen Li from comment #19)
> Hi James, From the memory info in comment 16, we can see Non-b2g process
> consume about 20MB.
> In my observation Non-b2g process could consume about up to 25~26MB when
> some app were lunched.
> Could you help to sort if any native process can be disabled or removed?
> Thanks!
(In reply to ying.xu from comment #21)
> It may take us some time to dig.
> I think these modifications may have been done on our android system before
> FFOS.
> 
> And If you don't mind ,can you tell me how to generate memory statistics
> like yours?
> So I can know how to count the Non-b2g processes.

Hi Ying, 

The memory report I attached is generated with "./tools/get_about_memory.py"
But now it does work to b2g process only.

I found that after modified the following attrs in "b2g/app/b2g.js", b2g will work much smooth than before.
    hal.processPriorityManager.gonk.BACKGROUND.KillUnderMB = 10
    dom.ipc.processPrelaunch.enabled = false
(In reply to Kai-Zhen Li from comment #22)
> (In reply to ying.xu from comment #21)
> > It may take us some time to dig.
> > I think these modifications may have been done on our android system before
> > FFOS.
> > 
> > And If you don't mind ,can you tell me how to generate memory statistics
> > like yours?
> > So I can know how to count the Non-b2g processes.
> 
> Hi Ying, 
> 
> The memory report I attached is generated with "./tools/get_about_memory.py"
> But now it does work to b2g process only.

I will try it.

> I found that after modified the following attrs in "b2g/app/b2g.js", b2g
> will work much smooth than before.
>     hal.processPriorityManager.gonk.BACKGROUND.KillUnderMB = 10
>     dom.ipc.processPrelaunch.enabled = false

Oh, I will merge these patches to the code base.
Flags: needinfo?(ying.xu)
Hi, Ying,

On last FRI I follow comment 13 and can build a kernel where
    Total system memory is 121956 kB
    setprop zram.disksize 180
    setprop sys.vm.swappiness 60

This kernel can provide a better UX for 128MB.

But after I repo sync yesterday and the kernel can only provide total system memory is 113676 kB.

Can you Help me to identify this?
to ying, please provider sprd ffos github to Kai-Zhen. 
We can use the same code base for 128M dev.
Flags: needinfo?(ying.xu)
(In reply to Kai-Zhen Li from comment #24)
> Hi, Ying,
> 
> On last FRI I follow comment 13 and can build a kernel where
>     Total system memory is 121956 kB
>     setprop zram.disksize 180
>     setprop sys.vm.swappiness 60
> 
> This kernel can provide a better UX for 128MB.
> 
> But after I repo sync yesterday and the kernel can only provide total system
> memory is 113676 kB.
> 
> Can you Help me to identify this?

I modified the kernel code to adjust the memory map to 128M RAM,nothing else.

This may was related to changes of enabling the zram function of kernel.

bionic                      63f50ab5532af842f885d1d1001c938578ebe95f
system/core/toolbox         ea9c356847ef6469ef922f350bf1da374bd40d93
Flags: needinfo?(ying.xu)
I would recommend add some sort of memory pressure mechanisms on the platform, because we are running JavaScript, which heavily relies on garbage collection. A few seconds before OOM killer kills everything is definitively a good time for GC.
Hi James, do you plan to implement the low memory notify in kernel?
You can see there is a low memory watcher in B2G, "gecko/widget/gonk/GonkMemoryPressureMonitoring.cpp"
It will be useful if kernel can notify the low memory situation.
(In reply to ying.xu from comment #26)
> (In reply to Kai-Zhen Li from comment #24)
> > Hi, Ying,
> > 
> > On last FRI I follow comment 13 and can build a kernel where
> >     Total system memory is 121956 kB
> >     setprop zram.disksize 180
> >     setprop sys.vm.swappiness 60
> > 
> > This kernel can provide a better UX for 128MB.
> > 
> > But after I repo sync yesterday and the kernel can only provide total system
> > memory is 113676 kB.
> > 
> > Can you Help me to identify this?
> 
> I modified the kernel code to adjust the memory map to 128M RAM,nothing else.
> 
> This may was related to changes of enabling the zram function of kernel.
> 
> bionic                      63f50ab5532af842f885d1d1001c938578ebe95f
> system/core/toolbox         ea9c356847ef6469ef922f350bf1da374bd40d93

If you have fugu code base.
cd B2G
git remote add sprd https://github.com/sprd-ffos/B2G.git
git fetch sprd
git checkout sprd/sprd
./config.sh sp7710lc_gonk4.0
./build.sh
(In reply to Kai-Zhen Li from comment #28)
> Hi James, do you plan to implement the low memory notify in kernel?
> You can see there is a low memory watcher in B2G,
> "gecko/widget/gonk/GonkMemoryPressureMonitoring.cpp"
> It will be useful if kernel can notify the low memory situation.

Can you give us some example? Does CA kernel implement this mechanism?
(In reply to Kai-Zhen Li from comment #28)
> Hi James, do you plan to implement the low memory notify in kernel?
> You can see there is a low memory watcher in B2G,
> "gecko/widget/gonk/GonkMemoryPressureMonitoring.cpp"
> It will be useful if kernel can notify the low memory situation.

Low memory killer?
Briefly summarize some possible directions for this:

1. SPRD provide notify trigger at kernel side, for memory pressure mechanism in GonkMemoryPressureMonitoring.

2. Disable OOP for those apps in UX spec that shouldn't get killed. Please see outOfProcessBlackList in gaia/apps/system/js/window_manager.js for disabling OOP

3. Tweak KillUnderMB in gecko/b2g/app/b2g.js for LMK parameters. This might get your more background apps.

4. pref("dom.ipc.processPrelaunch.enabled", true) in b2g.js. Set false to disable pre-allocated process.

5. pref("browser.cache.memory.enable", true); -> in-ram cache, but I don't recommend this.

6. pref("image.mem.max_decoded_image_kb", 30000); I don't recommend tweak this either.

7. Maybe one more for test, disable oop of browser frames. pref("dom.mozBrowserFramesEnabled", true);
(In reply to James Zhang from comment #31)
> (In reply to Kai-Zhen Li from comment #28)
> > Hi James, do you plan to implement the low memory notify in kernel?
> > You can see there is a low memory watcher in B2G,
> > "gecko/widget/gonk/GonkMemoryPressureMonitoring.cpp"
> > It will be useful if kernel can notify the low memory situation.
> 
> Low memory killer?

Code Aurora Forum has a possible implementation. PLEASE NOTE THE COPY RIGHT AND LICENSE PROBLEMS, because I think below patch actually comes from Code Aurora Forum.

https://github.com/mozilla-b2g/kernel-omap/commit/b170065c97e23d05797ea6f145d72d73f181e28f
(In reply to Alan Huang [:ahuang] from comment #33)
> (In reply to James Zhang from comment #31)
> > (In reply to Kai-Zhen Li from comment #28)
> > > Hi James, do you plan to implement the low memory notify in kernel?
> > > You can see there is a low memory watcher in B2G,
> > > "gecko/widget/gonk/GonkMemoryPressureMonitoring.cpp"
> > > It will be useful if kernel can notify the low memory situation.
> > 
> > Low memory killer?
> 
> Code Aurora Forum has a possible implementation. PLEASE NOTE THE COPY RIGHT
> AND LICENSE PROBLEMS, because I think below patch actually comes from Code
> Aurora Forum.
> 
> https://github.com/mozilla-b2g/kernel-omap/commit/
> b170065c97e23d05797ea6f145d72d73f181e28f

Maybe we can apply this patch because kernel is under GPL license and we'll keep the CA signature.
It would be great if the SPRD chipset uses the same OOM notification code as our existing devices, which should be possible due to the GPL. It was rather difficult to get that code to behave right. The less divergence we have in behavior here the better for everyone.
Status: UNCONFIRMED → NEW
Ever confirmed: true
(In reply to Alan Huang [:ahuang] from comment #32)
> Briefly summarize some possible directions for this:
> 
> 1. SPRD provide notify trigger at kernel side, for memory pressure mechanism
> in GonkMemoryPressureMonitoring.
> 
Ying, please apply this patch and test.

> 2. Disable OOP for those apps in UX spec that shouldn't get killed. Please
> see outOfProcessBlackList in gaia/apps/system/js/window_manager.js for
> disabling OOP
> 

I don't think it's a good idea, if apps in blacklist crash, b2g process will also crash.

> 3. Tweak KillUnderMB in gecko/b2g/app/b2g.js for LMK parameters. This might
> get your more background apps.
> 
> 4. pref("dom.ipc.processPrelaunch.enabled", true) in b2g.js. Set false to
> disable pre-allocated process.
> 
> 5. pref("browser.cache.memory.enable", true); -> in-ram cache, but I don't
> recommend this.
> 
> 6. pref("image.mem.max_decoded_image_kb", 30000); I don't recommend tweak
> this either.
> 
> 7. Maybe one more for test, disable oop of browser frames.
> pref("dom.mozBrowserFramesEnabled", true);

Maybe we can add macro or system.property to distinguish normal device and low memory device, for example, moz.low.memory = true.
Hi, James, here is a summary how I can build a firmware for 128MB device and which does work smoother than before.
- enable zram
- pref("dom.ipc.processPrelaunch.enabled", false) in b2g.js
- pref("hal.processPriorityManager.gonk.BACKGROUND.KillUnderMB", 10) in b2g.js
- user build, add "VARIANT=user" in .config
- implement oom notify if possible (now, this one is missing)
(In reply to Kai-Zhen Li from comment #24)
> On last FRI I follow comment 13 and can build a kernel where
>     Total system memory is 121956 kB
>     setprop zram.disksize 180
>     setprop sys.vm.swappiness 60

With zRam, I think higher swappiness may help UI responsiveness because it makes kernel swap out earlier and smoother, instead of preferring to drop caches. With low swappiness, kernel swap out lots of pages only when running out of memory and may result in a lag more perceivable.

Of course only experiment tells :-)
Yes.
These configs are set for 256M RAM system.

On the 128M RAM system ,they are

    setprop zram.disksize 64
    setprop sys.vm.swappiness 100
 

(In reply to Ting-Yuan Huang from comment #38)
> (In reply to Kai-Zhen Li from comment #24)
> > On last FRI I follow comment 13 and can build a kernel where
> >     Total system memory is 121956 kB
> >     setprop zram.disksize 180
> >     setprop sys.vm.swappiness 60
> 
> With zRam, I think higher swappiness may help UI responsiveness because it
> makes kernel swap out earlier and smoother, instead of preferring to drop
> caches. With low swappiness, kernel swap out lots of pages only when running
> out of memory and may result in a lag more perceivable.
> 
> Of course only experiment tells :-)
Is there a downside to using zram on every device we have? Should we enable it in trunk, assuming the kernel supports it? We would need some sort of auto-configuration based on available physical memory.
Is there a downside to using zram on every device we have?
A:There are some side effects if enabling swap and zram in kernel.such as performance and power consumption,
However ,we don't have the detail figures of badness of these side effects.

Should we enable it in trunk, assuming the kernel supports it?
A: I think you can consider to enable it in trunk. 
Because Google has enable it default at Android4.4 version.
Thanks Ying.
(In reply to Alan Huang [:ahuang] from comment #32)
> Briefly summarize some possible directions for this:
> 
> 1. SPRD provide notify trigger at kernel side, for memory pressure mechanism
> in GonkMemoryPressureMonitoring.

Done.
And confirm the MemoryPressureWatcher runs functionally.


> 2. Disable OOP for those apps in UX spec that shouldn't get killed. Please
> see outOfProcessBlackList in gaia/apps/system/js/window_manager.js for
> disabling OOP
> 
> 3. Tweak KillUnderMB in gecko/b2g/app/b2g.js for LMK parameters. This might
> get your more background apps.
> 
> 4. pref("dom.ipc.processPrelaunch.enabled", true) in b2g.js. Set false to
> disable pre-allocated process.
> 
> 5. pref("browser.cache.memory.enable", true); -> in-ram cache, but I don't
> recommend this.
> 
> 6. pref("image.mem.max_decoded_image_kb", 30000); I don't recommend tweak
> this either.
> 
> 7. Maybe one more for test, disable oop of browser frames.
> pref("dom.mozBrowserFramesEnabled", true);
(In reply to Kai-Zhen Li from comment #24)
> Hi, Ying,
> 
> On last FRI I follow comment 13 and can build a kernel where
>     Total system memory is 121956 kB
>     setprop zram.disksize 180
>     setprop sys.vm.swappiness 60
> 
> This kernel can provide a better UX for 128MB.
> 
> But after I repo sync yesterday and the kernel can only provide total system
> memory is 113676 kB.
> 
> Can you Help me to identify this?

Yes,I can confirm that .After enabling swap and zram function.
Depends on: 930282, 944155
Depends on: 943254
Group: mozilla-corporation-confidential
Group: mozilla-corporation-confidential
Wrong operation I made, sorry about that.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 944457
(In reply to Steven Yang [:styang] from comment #46)
> 
> *** This bug has been marked as a duplicate of bug 944457 ***

Fugu will not have a 128MB configuration, remarking it as INVALID.
Resolution: DUPLICATE → INVALID
since there are a lot of discussion in this bug already. let's use this to discuss supporting 128MB in general
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Summary: [Fugu][B2G]Enable 128RAM config for fugu device → [Tarako] Enable 128RAM config
Depends on: 903149
Alias: 128RAM
No longer depends on: 925628
Depends on: 948276
No longer depends on: 944155
Depends on: 950266
Whiteboard: [tarako]
Blocks: 944457
new u-boot can support "fastboot flash system.img", so new u-boot can be updated by
fastboot flash 2ndbl u-boot.bin
Hi James, any hot key to enter fastboot mode if adb can't work.
Flags: needinfo?(james.zhang)
(In reply to thomas tsai from comment #50)
> Hi James, any hot key to enter fastboot mode if adb can't work.

Tarako hasn't camera key, so we can't enter fastboot mode by hot key.
Flags: needinfo?(james.zhang)
Depends on: 957512
I'm modifying the SMS app to lazy-load the sources it doesn't need right away, this is providing some very tangible benefits memory-wise (up to 1MiB worth of savings, see bug 947234 comment 26). I'm adding the dependency here as I think it's relevant since the SMS app is quite ubiquitous.
Depends on: 947234
Depends on: 959966
to kli for now so we don't lose this bug
Assignee: nobody → kli
Depends on: 983050
Depends on: 983051
Depends on: 983056
Depends on: 984759
No longer depends on: 984759
Depends on: 996512
Summary: [Tarako] Enable 128RAM config → [META][Tarako] Enable 128RAM config
Resolve bug as Tarako devices are shipping. This is a meta bug, nothing to be fixed.
Status: REOPENED → RESOLVED
Closed: 6 years ago5 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.