Skip to content

Put system to sleep when going idle #3566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 7, 2017
Merged

Conversation

betzw
Copy link
Contributor

@betzw betzw commented Jan 11, 2017

Description

While waiting for tickless mode being implemented & stable, put system to sleep when going idle.

Status

READY

Migrations

NO

Related PRs

#3607
#3602
#3693

@bulislaw
Copy link
Member

I don't think that will give us much power savings, due to systick set to 1ms by default for RTX. On the other hand it shouldn't cause us any issues so might be worth doing anyway (on top of which we can build a tickless solution). We should actually measure that so we have some hard points rather than 'I think'.

@bulislaw
Copy link
Member

/morph test

@betzw
Copy link
Contributor Author

betzw commented Jan 11, 2017

Any idea why continuous-integration/jenkins/pr-head fails. On my side the link fails to open with a timeout.

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1380

All builds and test passed!

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 11, 2017

Any idea why continuous-integration/jenkins/pr-head fails. On my side the link fails to open with a timeout.

Just restarted. Reason was not able to allocate resources.

@betzw
Copy link
Contributor Author

betzw commented Jan 11, 2017

We have performed a little test on a NUCLEO_F401RE with the following application:

#include "mbed.h"

int main() {
    printf("Start waiting forever ...\r\n");

    while(1) { // wait forever
	wait(24*60); // wait a day
    }
}

Compiling this program with mbed compile the MCU consumes 18.71mA.
Compiling this program with mbed compile -DNDEBUG the MCU consumes 5.84mA.

@bulislaw
Copy link
Member

I just thought that the test run didn't test much as we don't run it with NDEBUG, we use the default profile. @bridadan is there a way of triggering a NDEBUG run?

@betzw
Copy link
Contributor Author

betzw commented Jan 11, 2017

Well, I think compiling with mbed compile -DNDEBUG will define the macro NDEBUG in whatever profile you use, isn't it?

@betzw
Copy link
Contributor Author

betzw commented Jan 11, 2017

And using option -vv seems to confirm my hypothesis.

@bulislaw
Copy link
Member

Sure, but I want to run the tests on CI with that option so we can see how other platforms behave.

@betzw
Copy link
Contributor Author

betzw commented Jan 11, 2017

What about the small.json profile?

@bridadan
Copy link
Contributor

@bulislaw There currently isn't a way to change the profile for CI tests.

PR #3019 tried to add this as well but it was closed. @sg- or @0xc0170 do you have concerns over this?

@betzw
Copy link
Contributor Author

betzw commented Jan 12, 2017

Just in order to underline that in contrast to #3019 I added both #ifdef NDEBUG and #if DEVICE_SLEEP around the call to sleep()!
Pls. consider also that this would help a bit in contradicting the rumour I heard from customers that mbed-os wouldn't be power efficient ...

@bulislaw
Copy link
Member

bulislaw commented Jan 12, 2017

Could you submit temporary change, like that:

diff --git a/tools/profiles/default.json b/tools/profiles/default.json
index d4755e9..1854374 100644
--- a/tools/profiles/default.json
+++ b/tools/profiles/default.json
@@ -5,7 +5,7 @@
                    "-fmessage-length=0", "-fno-exceptions", "-fno-builtin",
                    "-ffunction-sections", "-fdata-sections", "-funsigned-char",
                    "-MMD", "-fno-delete-null-pointer-checks",
-                   "-fomit-frame-pointer", "-Os"],
+                   "-fomit-frame-pointer", "-Os", "-DNDEBUG"],
         "asm": ["-x", "assembler-with-cpp"],
         "c": ["-std=gnu99"],
         "cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"],
@@ -14,19 +14,19 @@
                "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit"]
     },
     "ARM": {
-        "common": ["-c", "--gnu", "-Otime", "--split_sections",
+        "common": ["-c", "--gnu", "-Ospace", "--split_sections",
                    "--apcs=interwork", "--brief_diagnostics", "--restrict",
-                   "--multibyte_chars", "-O3"],
+                   "--multibyte_chars", "-O3", "-DNDEBUG"],
         "asm": [],
         "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
         "cxx": ["--cpp", "--no_rtti", "--no_vla"],
         "ld": []
     },
     "uARM": {
-        "common": ["-c", "--gnu", "-Otime", "--split_sections",
+        "common": ["-c", "--gnu", "-Ospace", "--split_sections",
                    "--apcs=interwork", "--brief_diagnostics", "--restrict",
                    "--multibyte_chars", "-O3", "-D__MICROLIB",
-                   "--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD"],
+                   "--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD", "-DNDEBUG"],
         "asm": [],
         "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
         "cxx": ["--cpp", "--no_rtti", "--no_vla"],
@@ -35,7 +35,7 @@
     "IAR": {
         "common": [
             "--no_wrap_diagnostics", "-e",
-            "--diag_suppress=Pa050,Pa084,Pa093,Pa082", "-Oh"],
+            "--diag_suppress=Pa050,Pa084,Pa093,Pa082", "-Ohz", "-DNDEBUG"],
         "asm": [],
         "c": ["--vla"],
         "cxx": ["--guard_calls", "--no_static_destruction"],

Which works around our CIs issues and would use the small profile instead of default one. We could kick off the run and revert the change after. That should give us some more information on how it works across multiple targets.

@betzw
Copy link
Contributor Author

betzw commented Jan 12, 2017

Done!

@bulislaw
Copy link
Member

Thanks!

/morph test-nightly

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1385

All builds and test passed!

@bulislaw
Copy link
Member

@betzw thanks, we can get rid of this test commit now.

@sg- what do you think about that?

@betzw
Copy link
Contributor Author

betzw commented Jan 12, 2017

Will do it tomorrow morning!

@adbridge
Copy link
Contributor

retest uvisor

@bridadan
Copy link
Contributor

bridadan commented Jan 12, 2017

Maintainers: I'd like @sg- and/or @0xc0170 to review this first before this comes in.

Also, as a developer, I would be surprised to see my device going to sleep just by enabling NDEBUG. It may be a welcome surprise in some cases, but I would be worried to see my device's power consumption dropping significantly with me only enabling NDEBUG.

If we are set on enabling this with NDEBUG, can this please be documented somewhere?

I think it might be more fitting to make this a config setting.

@bulislaw
Copy link
Member

Sure documenting would be great, any ideas what would be the right place to do it?

Also the uvisor tests need to be rerun, when we revert the change to build with 'small' profile. I'll put a 'do not merge' label so that happens before merging.

@bridadan
Copy link
Contributor

I'd suggest placing it in the build profiles documentation: https://github.com/ARMmbed/mbed-os/blob/master/docs/build_profiles.md#small-profile

@betzw
Copy link
Contributor Author

betzw commented Jan 13, 2017

Reverted PR back, i.e. CIs use default profile again.

@bulislaw
Copy link
Member

bulislaw commented Jan 13, 2017

@0xc0170 what do you think?
@betzw could you add to the docs, mentioned above, that the platform will go to sleep on idle (between systicks) please.

@betzw
Copy link
Contributor Author

betzw commented Jan 13, 2017

You can find a proposal for a change in documentation here.

@betzw
Copy link
Contributor Author

betzw commented Jan 13, 2017

@bulislaw Have you seen this? If you want I can merge it in!

@sg-
Copy link
Contributor

sg- commented Jan 18, 2017

resolves #2769

@betzw betzw changed the title Put system to sleep (when available) Put system to sleep when going idle Jan 19, 2017
@betzw
Copy link
Contributor Author

betzw commented Jan 19, 2017

Requires PR #3607!!!

@bulislaw
Copy link
Member

retest uvisor

@bulislaw
Copy link
Member

@mazimkhan it seems I don't have the runes to do the retest uvisor could you kick off the run and add me to the acl please.

@mazimkhan
Copy link

retest uvisor

@betzw
Copy link
Contributor Author

betzw commented Jan 27, 2017

Ciao Martin (@0xc0170), could you pls. proceed on & merge this PR too, or are there still some blocking points I am not aware of?

@bulislaw
Copy link
Member

I removed the labels: 'do not merge' as i added it before and it does not apply anymore and 'needs review' as it was reviewed.

@sg-
Copy link
Contributor

sg- commented Feb 2, 2017

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented Feb 2, 2017

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1493

All builds and test passed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants