Menu

#162 Implement CPU Power Saving feature and more optimized emulation performance

future
open
nobody
None
8
2015-08-11
2015-02-05
Josh
No

DeSmuME X432R performs better than the original DeSmuME (in terms of speed). I do not know how or why this happen (It could be more optimized code). Not only it performs better in speed but also more stable frame rate. For instance, when my character is in static position but the fps will sometimes drop. Maybe stutter is a better word. Proven by this line in the console "SPU2 > Underrun compensation (3 packets buffered)" This line appears frequently on original DeSmuME despite running at full 60 fps speed.

I'm using Intel Core 2 Duo E7500 processor if you want to know (Overclocked by 5% which means it is running at 3.06GHz) So I tried experimenting on my friend's laptop which have Core i7 3rd gen and orignal DeSmuME runs buttery smooth.

You might tell me that my CPU is weak and need an upgrade. I know that fact already. But since DeSmuME X432R launch and I try to use it, the stutter effect is like completely gone and the emulation runs so much smoother and faster also.

And I notice one thing also that there is a CPU power saving feature in DeSmuME X432R which when enable will further increase FPS too.

What I wanted to ask the DeSmuME team to do is to reduce the CPU overhead as much as possible if can.

P.s There is this strange thing happen which is CPU usage is high even when no rom is loaded in DeSmuME.

4 Attachments

Discussion

  • zeromus

    zeromus - 2015-02-05

    nope. Performance is basically lowest priority. Maybe you can ask the x432r author what he did to achieve magic speedups. He probably rewrote a bunch of junk to support the HD stuff.

    The HUD is animating even when no rom is loaded in desmume. This takes CPU power.

    It's extremely odd for a 'power saving' feature to increase FPS. Sounds like your computer is oddly configured, maybe throttling itself down when it overheats.

     

    Last edit: zeromus 2015-02-05
    • Josh

      Josh - 2015-02-05

      If only I have the chance to even contact the author.

      But there is extra source code compile in a folder together with the emulator.
      The folder name is "r5082用差分ソース". Does that help to identify which part increase the performance?

       
  • Josh

    Josh - 2015-02-05

    Oddly in DeSmuME X432R does not have this high CPU usage when no rom is loaded. Maybe the HUD is not animating but most likely is not.

    Actually without power saving feature the emulation performance is still better than original DeSmuME but not so significant.

     
  • Josh

    Josh - 2015-02-05

    If you're talking about my CPU overheat, I might agree with that. But still even when I downclock the CPU to the default 2.93GHz, the performance in DeSmuME X432R is still better. It could be because of lower CPU overhead.

     
  • zeromus

    zeromus - 2015-02-05

    no, it doesnt help identify anything. i sent you on an impossible errand, nobody working on desmume now has any interest in performance. go use mysterious x432r forks if you want someone who works on performance. x432r author is taking desmume commits into his code so theres no reason for you to use vanilla desmume

     

    Last edit: zeromus 2015-02-05
  • Josh

    Josh - 2015-03-29

    A little update regarding this matter.

    Somehow when DeSmuME window is inactive there is a slight fps boost and CPU usage is slightly lowered (similar to DeSmuME X432R CPU power saving feature).

    I know this really doesn't matter to you (but I let you know anyway) as people nowadays have Intel Core I series processor which are at least quad-core while my Core 2 Duo is like the baseline processor to get 60 fps emulation most of the time.

    I agree with your statement which is my CPU get throttled if the usage is above 85%?

     

    Last edit: Josh 2015-03-29
  • Josh

    Josh - 2015-08-08

    Good news
    Since [r5235] you guys have actually improve the Softrasterizer performance by marginally 20% (8-9 fps extra in Pokemon Black title screen for my processor).
    And when I paused the emulator the CPU usage drop significantly compare to the predecessor of [r5234] which both have same high CPU usage regardless of the emulator in running or paused state.
    When no rom is loaded, CPU usage is still high in previous revision but no longer the case anymore.

    I also notice the CPU usage is no longer high during emulation except when rendering heavy 3D graphics.

    So I really want to applaud you guys for the minor code optimization work for that particular revision.

    P.s. Continue to clean up and optimize the code further until it can achive 0% CPU usage for no rom loaded and/or in paused state.

     

    Related

    Commit: [r5234]
    Commit: [r5235]


    Last edit: Josh 2015-08-08
  • Josh

    Josh - 2015-08-08

    But I find it a little weird. The minor code cleanup is for cocoa port but somehow performance improved is seen in the windows port.

     
  • zeromus

    zeromus - 2015-08-08

    It's because you're mistaken. Reconsider your measurement methodology.

     
  • Josh

    Josh - 2015-08-08

    Nope this is not a mistake. It is the fact.
    To double confirm this I had even test r5230 all the way to r5238 one by one. Starting from r5235 performance improvement is seen on my side (only Softrasterizer renderer). Screenshot is attached together above as proof.

     
  • zeromus

    zeromus - 2015-08-08

    If you tested someone else's builds, then at r5235 they began to build it differently.
    If you tested your own builds, then your measurement methodology is wrong or your compiler outputs chaotic results. The resulting exe should be bit identical given the changes made in r5235

     
  • Josh

    Josh - 2015-08-09

    I'm really surprise with your answer.
    What makes you think that I will test someone else's build or my own build and make comparison to the official build. This is just unfair comparison.

    If you don't believe me you can test it out yourself. Compare r5234 and r5235 and run the task manager side by side and see the CPU usage. Compare the emulator running and pause state also.
    I'm using the obsolete Core 2 Duo processor, it can run all games at 60fps except during some game title screen which have heavy 3D graphics.

    Before r5235, the game can run max at 51fps only at the Pokemon Black title screen. After r5235 it can run up to 60fps so it means a lot to me.

    Or do you need me to make a video capture for you to make it more convincing? I hope not.

     

    Last edit: Josh 2015-08-09
  • Josh

    Josh - 2015-08-09

    So let me highlight again, I have never modify any of the builds or use anyone's else builds.
    I only download the latest build from this website Orphis Buildbot. This is your official revision build website, so there is no way to deny it.

    Ask the author rogerman what he did that make this significant changes.

     

    Last edit: Josh 2015-08-09
  • zeromus

    zeromus - 2015-08-09
    1. OK, so it's someone else: orphis whose builds you're using
    2. those arent official builds, theyre a helpful stranger's buildbot builds. I dont know how he makes his builds
    3. there are 5 bytes different in the EXEs outside of the PE header and the various version number strings and timestamps.
    4. They both run at 96fps on my test case.
    5. you can't properly test performance with a 60fps throttled scenario.
    6. they both use 1% cpu idling paused so i can't test that.
    7. your measurement methodology must still be flawed. different settings in the different builds, running them on different monitors, running them both at once and getting chaotic resource contention from windows
    8. dont waste our time, find any other programmer in the world who says that diff can affect performance (you can't)
     

    Last edit: zeromus 2015-08-09
  • rogerman

    rogerman - 2015-08-09

    Sorry Josh, but zeromus is correct on this one. r5235 has zero performance impact. And just so you know, a 20% performance impact (whether positive or negative) is considered huge. Something else big must be going on here.

     
  • Josh

    Josh - 2015-08-10

    Now I realised what is wrong. It is the sound core setting that only take effect after the emulator is reset. I have changed Direct Sound Interface to Xaudio2 interface when the game is still running. I thought this setting is changed on the fly or realtime just as how 3D renderer works since it did not request a reboot. So this gives me false result on my testing.

    Ok, nevermind about that. There is one instance when I change the sound core it is not reflected on the fly.

    But in [r5239] it does gives extra 2-3 fps on the Pokemon Black title screen using the Softrasterizer.

     

    Related

    Commit: [r5239]


    Last edit: Josh 2015-08-10
  • Josh

    Josh - 2015-08-10

    Update
    The confusion is clear now, so it is the Xaudio2 interface that throttles down the emulator performance despite the Xaudio2 is a lower level API and also a sucessor to Direct Sound.

    I also found out that Xaudio2 Interface is the one that cause high CPU usage despite it is in paused state. It just drop slightly compared to the running state.
    Once I changed the sound to Direct Sound Interface, only then the CPU usage drops a lot when in paused state.

    Can explain why this happens?

     

    Last edit: Josh 2015-08-10
  • zeromus

    zeromus - 2015-08-10

    because of a bug I just fixed

     
  • Josh

    Josh - 2015-08-11

    So it is a CPU loop that causes high CPU usage. Thanks for the bug fix. Now both the sound core are behaving the same in terms of performance and CPU usage.

    I also noticed on the OpenGL side there is 1 - 2 fps increase with [r5241] for Pokemon Black version 2.

     

    Related

    Commit: [r5241]


    Last edit: Josh 2015-08-11

Log in to post a comment.