RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    [Merged] Power Saver feature

    Scheduled Pinned Locked Moved Ideas and Development
    emulationstatiotestingpowersaver
    164 Posts 10 Posters 63.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • meleuM
      meleu @cyperghost
      last edited by meleu

      @cyperghost said in Testers needed :: Power Saver features :: PR #172:

      Screensaver seem to be disabled in this mod ...

      The OP says:

      • Dim and blank screensavers aren't triggered if PS enaled

      Then it isn't a bug.

      • Useful topics
      • joystick-selection tool
      • rpie-art tool
      • achievements I made
      cyperghostC 1 Reply Last reply Reply Quote 1
      • cyperghostC
        cyperghost @meleu
        last edited by cyperghost

        @meleu oh man ... why you are so quick... I just edited that :)
        Have a nice sunday brother :D
        I'm getting out of here :D Thank you

        cyperghostC 1 Reply Last reply Reply Quote 1
        • cyperghostC
          cyperghost @cyperghost
          last edited by cyperghost

          @Hex
          All in all your mod seems to work.
          The CPU instantly raises if I disable Power Savings.
          Nice solution :) The effect on a RPI2/3 wouldn't be so massive but the 0 and 1 do profit from this!

          The 2.1.5 version of ES let's the CPU raise (for ex. NES selection list) and does not drop. Your branch let also the CPU raise but then there is a drop from 60% to 5-10% within a few seconds! Results for 2.3.5RP vs 2.3.2RP PowerSaving listed are listed here

          1 Reply Last reply Reply Quote 2
          • TMNTturtlguyT
            TMNTturtlguy
            last edited by

            @hex this look really cool! What are the advantages when running a pi 3? As you know I run video screensaver and video preview all of the time, will my build recieve any benefits?

            Thanks for the hard work and cool features!

            cyperghostC 1 Reply Last reply Reply Quote 0
            • HexH
              Hex
              last edited by Hex

              @TMNTturtlguy
              Briefly : If Video Screensaver is enabled PS is disabled by force.

              Video Screensaver works because PS is hardcoded to not work when VS is enabled.

              If I were to remove that requirement then VS will not be triggered just like Dim and Blank. All screensavers can be manually triggered though.

              PS accounts for Video snaps if the display is set to Automatic. It is enforced if set to Detailed. It is disabled if set to Video.

              So if you have video previews and set it to Automatic then PS is disabled when you are on a gamelist which has videos. When you are on a gamelist without videos it is enabled again. It is always enabled on System/Carousel, unless you have disabled PS from settings or you have VS enabled

              Sent from 20,000 leagues under the sea.

              Powersaver Emulation station : https://github.com/hex007/EmulationStation
              ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

              1 Reply Last reply Reply Quote 2
              • cyperghostC
                cyperghost @TMNTturtlguy
                last edited by cyperghost

                @TMNTturtlguy The advantages even on a PI3 are clear. The CPU usage is now between 15-20% in idle mode. If Screensaver is activated then trigger buttons are disabeld and the CPU get down to 3-5%. If you use video preview then it may be useless but not every user gots the preview on :)

                With PS enabeld it will always be 3-5% (I guess from!) that saves some energy. The effect is not as strong as for the PI1/0 but will be noticable on PI2/3. So I think the branch of "Power Saving mode" makes sense.

                I'm still not sure why there are Loops installed that waits for key evenst! @hex Can you explain please? Are you using interrupts?

                1 Reply Last reply Reply Quote 1
                • HexH
                  Hex
                  last edited by Hex

                  @cyperghost in short SDL2 event handling is shit.


                  How a normal framework should handle key presses

                  The UI is rendered on the main thread. When a key is pressed, the OS should send an interrupt/signal to the framework. Framework checks which method handles key press and calls that method to handle key press. The method should return if it consumes the key press or not. If key press was not consumed then the framework passes it to its internal key press handler.


                  How SDL2 handles key press
                  SDL2 main thread check if user has pressed a key by SDL_pollevent or SDL_waitevent. When a user presses a key it is added to event queue. SDL_poll call checks if there is an event in event queue and returns with the first incoming event (null if no event). the main thread then handles the incoming event and renders the frame accordingly. Since we need lots of frame for smooth animations this has to be put in a timed loop. The timer decides which frame is being rendered.

                  The problem starts here. Now that you are in a while loop for rendering, what happens if no events are received? You just keep on looping doing nothing but rendering the screen which is not changing, thus consuming CPU.

                  SDL_Wait come to the rescue. SDL_wait waits for an event to occur and only then returns. so it is a blocking call. If an event doesn't occur, your main thread is not rendering. Hence the CPU savings. But what does SDL_wait do in the background? It just polls and sleeps in a loop till an event occurs, which is stupid.

                  Sent from 20,000 leagues under the sea.

                  Powersaver Emulation station : https://github.com/hex007/EmulationStation
                  ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                  cyperghostC 1 Reply Last reply Reply Quote 2
                  • cyperghostC
                    cyperghost @Hex
                    last edited by cyperghost

                    @Hex Okay I understand. So it's a question of the framwork and the programmer (aloshi?) was forced to use this stupid polling events.

                    It's really a nice that you made this possible! And I hope that this fix will find it's place in ES development!


                    Nearby for info @interested:
                    Polling is a timed loop waiting for events - just stupid. You are doing this if you have really no knowledge how a process is working or the surrounded framework lacks of better techniques. Then you are using polling events! So you let the CPU do something (or let the CPU just waiting in background) and after 100µS you check an event (button press...) and it says "Something happend" or "Nothing happend". Then you can produce errors like bouncing ... make 2 steps instead of one.

                    The better way is to use interrupts. You use a trigger that stays permanent in memory and this trigger is waiting for an event. If the event has started than a vector jumps back to the programm and says "Something happend!" and that's always better for CPU usage but needs a bit more programming skills!

                    Think about 2 humans talking to each other.

                    The Poller:

                    Person 1: What's up?
                    Person 2: Nothing!
                    After 5 minutes
                    Person 1: What's up?
                    Person 2: Nothing!
                    After 5 minutes
                    Person 1: What's up?
                    Person 2: Nothing!
                    After 5 minutes
                    Person 1: What's up?
                    Person 2: You get me on the nerves?
                    Person 1: Really - what you want me to do?
                    Person 2: Get me out of this

                    The Interrupter

                    Person 1: If there is a need for smalltalk... then please tell me! (=set pointer to person 2)
                    5 min
                    5 min
                    5 min
                    Person 2: It's so boring (=vector back to Person 1 = Interrupt request or IRQ)
                    Person 1: What you want me to do?
                    Person 2: Get me out of this

                    ;)

                    1 Reply Last reply Reply Quote 1
                    • HexH
                      Hex
                      last edited by Hex

                      @cyperghost The programmer Alec "Aloshi" Lofquist, was probably coding on a PC and did not make things for small devices. Stock ES uses 1% at idle on my Linux laptop which equates to 60% on Pi 0.

                      Lets say ES is a worker and OS is his manager. ES is at his desk. Never mind you just edited to add something like this :| And the 5mins is more like 1ms

                      Sent from 20,000 leagues under the sea.

                      Powersaver Emulation station : https://github.com/hex007/EmulationStation
                      ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                      1 Reply Last reply Reply Quote 2
                      • cyperghostC
                        cyperghost
                        last edited by cyperghost

                        @Hex
                        I just wanted to write something everbody can imagine! It's better to talk about a pointer that is setted to a fixed RAM cell and sends a vector back to the pointer with annother value? Of course we are talking about GHz so 1ms is really a long long time :)
                        Thank you for the technical background.

                        1 Reply Last reply Reply Quote 1
                        • SanoS
                          Sano
                          last edited by

                          Optimizing is ALWAYS a good thing, even on the most powerful hardware.

                          I know most devs (except maybe linux/free software devs) nowadays think it will be cheaper and faster to just add more RAM or whatever, but this is wrong on so many levels...

                          As a sysadmin, I can swear I've seen so many poorly coded applications that I just want to flip a table over some devs head.
                          I have tons of examples if you want to laugh :)
                          Including some SQL request going down from 20min to 4s after simple optimization, or a soft doing 70000 iops (yup !) for a 3min long on-user-demand treatment that was optimized to a mere 15s (and 150iops usage).
                          God sometimes I hate my life...

                          1 Reply Last reply Reply Quote 1
                          • HexH
                            Hex
                            last edited by

                            Are your systems running on batteries or connected to a power supply? My battery life testing is quite simple. if i have to test different batteries I run Contra on NES emu. It has something like attract mode where the Cpu plays so i get comparison between different batteries or boost circuits.

                            With ES I switch screensaver off and just leave it on Systems view. This allows me to compare power savings over multiple ES builds.

                            Sent from 20,000 leagues under the sea.

                            Powersaver Emulation station : https://github.com/hex007/EmulationStation
                            ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                            1 Reply Last reply Reply Quote 2
                            • HexH
                              Hex
                              last edited by

                              I am switching to PS enabled by default and all changes are being finalized. Would the testers like to report any bugs or problems with the branch. One major problem is auto launch of screensaver doesnt work. Manual trigger works. I am looking into that and once that is stable the PR would be ready for merge

                              Sent from 20,000 leagues under the sea.

                              Powersaver Emulation station : https://github.com/hex007/EmulationStation
                              ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                              meleuM 1 Reply Last reply Reply Quote 0
                              • meleuM
                                meleu @Hex
                                last edited by

                                @Hex said in Testers needed :: Power Saver features :: PR #172:

                                One major problem is auto launch of screensaver doesnt work. Manual trigger works.

                                I like this behavior. Can we label it as a feature instead of a problem. :-)

                                • Useful topics
                                • joystick-selection tool
                                • rpie-art tool
                                • achievements I made
                                fellegF 1 Reply Last reply Reply Quote 0
                                • SanoS
                                  Sano
                                  last edited by Sano

                                  Ok, sorry guys, was short on free time the few past days.

                                  I installed the powersaver version of ES on a Pi3, and just... Wow !
                                  We're talking about a night and day difference here.

                                  As I previously stated, ES CPU usage when active was around 30 to 40%, and dropped to 3-6% only after the screensaver timeout (5min).

                                  Now we have :
                                  25% when active
                                  after a few seconds only, it drastically drops to 0.3 %
                                  Very impressive !

                                  I'll let the option activated in order to test more in real conditions, but I can't wait the merge with the main branch.
                                  Congratulations @Hex

                                  Edit :
                                  @Hex Is the game number on carousel tweak an addition of yours too ? It may be me, but I didn't see it before using your version.
                                  Anyway, this is brilliant.

                                  1 Reply Last reply Reply Quote 0
                                  • fellegF
                                    felleg @meleu
                                    last edited by felleg

                                    @meleu said in Testers needed :: Power Saver features :: PR #172:

                                    @Hex said in Testers needed :: Power Saver features :: PR #172:

                                    One major problem is auto launch of screensaver doesnt work. Manual trigger works.

                                    I like this behavior. Can we label it as a feature instead of a problem. :-)

                                    This is a problem if you want to avoid screen burn-in. I'd much rather have the screensaver be able to start automatically, although, don't get me wrong, being able to start it manually is great in its own right.

                                    cyperghostC meleuM 2 Replies Last reply Reply Quote 0
                                    • cyperghostC
                                      cyperghost @felleg
                                      last edited by

                                      @felleg Please explain "Screen Burn In" on LCD/TFT

                                      1 Reply Last reply Reply Quote 0
                                      • HexH
                                        Hex
                                        last edited by Hex

                                        @meleu Hehe, i dont take any "prisoners of war". Its bad when bugs start being labelled as features.

                                        @Sano Thank you. I dont understand what you mean by game number on carousel? Are you taking about the number of games in a system shown. That is available in the main branch since a long time.

                                        @felleg Worry not, the screensavers video/dim/blank are working as expected with the PS mod. The logic is becoming very complex on the other hand.

                                        @cyperghost there are some who use it on plasma or retro TV sets, might be for them?

                                        Sent from 20,000 leagues under the sea.

                                        Powersaver Emulation station : https://github.com/hex007/EmulationStation
                                        ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                                        SanoS cyperghostC 2 Replies Last reply Reply Quote 1
                                        • SanoS
                                          Sano @Hex
                                          last edited by Sano

                                          @Sano Thank you. I dont understand what you mean by game number on carousel? Are you taking about the number of games in a system shown. That is available in the main branch since a long time.

                                          Yes, but I realized on your version that the number doesn't appear automatically after a delay. I have to press down direction for it to appear.
                                          I like it, it's more convenient for me to not have this information unless I want it :)

                                          1 Reply Last reply Reply Quote 0
                                          • HexH
                                            Hex
                                            last edited by Hex

                                            @Sano Again, bugs are not features. It might be okay for you but for someone who doesnt know about this behaviour will be perplexed and complain on forums.

                                            Also what system are you getting this behaviour in?

                                            Sent from 20,000 leagues under the sea.

                                            Powersaver Emulation station : https://github.com/hex007/EmulationStation
                                            ES dev script : https://github.com/hex007/es-dev/blob/master/es-tests.sh

                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.