Lower cpu usage

Page 1 of 4 1234 LastLast
Results 1 to 15 of 56
  1. #1
    Hybrid Gembrid is offline
    MemberRank
    Mar 2006 Join Date
    1,121Posts

    Lower cpu usage

    without big explanations.

    Here is a part of the code in main.exe
    PHP Code:
        startDraw GetTickCount();
        
        
    drawFrame();

        
    frameTime GetTickCount() - startDraw;

        while(
    frameTime 40)
        {
            
    frameTime GetTickCount() - startDraw;
        } 
    Imagine that we have a simple scene and frame is drawn in 10ms.

    After frame is drawn we get here
    PHP Code:
        while(frameTime 40)
        {
            
    frameTime GetTickCount() - startDraw;
        } 
    for 30 ms we will use cpu just to check if 40ms have passed since frame started to draw.

    why we just don't go to sleep for a little and then check for the passed time? Let the system do useful things

    PHP Code:
        while(frameTime 40)
        {
            
    Sleep(1); // will sleep for 10-15 ms, depending on time accuracy
            
    frameTime GetTickCount() - startDraw;
        } 
    So the point is - don't waste cpu time if we have a simple frame that is drawn faster then 40 ms.




    How to add this thing in main using ollydbg:

    1. Search for SwapBuffers or glFlush (search for name/lable CTRL+N)

    and you will find this part of the code
    PHP Code:
        frameTime GetTickCount() - startDraw;

        while(
    frameTime 40)
        {
            
    frameTime GetTickCount() - startDraw;
        } 
    in 97d it will look like this:



    1.03.27 jpn:


    2. Modify the code by adding sleep function call:

    97d:


    1.03.27 jpn:







    Note: if main spends >= 40 ms for frame drawing, this thing won't save you from high cpu usage :D cpu will be busy in drawing frame


    this thing needs testings, i made some tests + thx to Dios he made little tests, so test and maybe it will be useful


  2. #2

    Re: Lower cpu usage

    It works. But as you said, if it needs more than 40ms to draw, the CPU usage is still high. For example in towns, where there are players.
    A normal main uses 47-50% of my CPU.
    With your solution, the main uses 18-23%. But unfortunately, not with many players around.

    Anyway, great help from you. As always.
    Last edited by _Gabriel_; 05-03-11 at 07:08 PM.

  3. #3
    Hybrid Gembrid is offline
    MemberRank
    Mar 2006 Join Date
    1,121Posts

    Re: Lower cpu usage

    gmo main has this thing included, interesting if it was added before or after my guide :D

  4. #4
    Enthusiast 8bitcore is offline
    MemberRank
    Oct 2009 Join Date
    UkraineLocation
    33Posts

    Re: Lower cpu usage

    with small numbers of monsters and characters on the screen the CPU usage to 10%
    awesome, thx

    1.07v+

    Code:
    BYTE FixCpuUsage[7] = { 0xE9, 0x99, 0x5A, 0x4C, 0x00, 0x90, 0x90 };
    BYTE FixCpuUsage2[13] = { 0x6A, 0x01, 0xFF, 0x15, 0x74, 0x51, 0x28, 0x09, 0xE9, 0x48, 0xA5, 0xB3, 0xFF };
    memcpy((int*)0x004A9A82, FixCpuUsage, sizeof(FixCpuUsage));
    memcpy((int*)0x0096F520, FixCpuUsage2, sizeof(FixCpuUsage2));

  5. #5
    Novice innorax is offline
    MemberRank
    Aug 2011 Join Date
    BulgariaLocation
    3Posts

    Re: Lower cpu usage

    Okay, so I know that newbies are annoying and I'm a newbie, so could you guys explain it like for a neanderthal please?

  6. #6
    Member dedpro is offline
    MemberRank
    Feb 2007 Join Date
    64Posts

    Re: Lower cpu usage

    Help me pls. i dont understand what to do.

    http://failiem.lv/down.php?i=ucvaboa&n=main.exe
    This is S6e2 main

  7. #7
    Enthusiast lovestealer is offline
    MemberRank
    Jul 2010 Join Date
    36Posts

    Re: Lower cpu usage

    How to do this for main 1.07V+? . Can anyone show me way to do this? . Thanks :D

  8. #8
    Proficient Member lokoes321 is offline
    MemberRank
    Nov 2007 Join Date
    174Posts

    Re: Lower cpu usage

    Already tried on a 97d main and i did it and looks exactly like yours, but when i get into the login screen, all freezes and i need to close the game.

  9. #9

    Re: Lower cpu usage

    If this won't work then go to task manager with process hacker or task manager idk , and set priority to your gameserver LOW.

  10. #10
    Proficient Member lokoes321 is offline
    MemberRank
    Nov 2007 Join Date
    174Posts

    Re: Lower cpu usage

    Quote Originally Posted by GanjaMUOnline View Post
    If this won't work then go to task manager with process hacker or task manager idk , and set priority to your gameserver LOW.
    Uhm, this is for main... some mains have a high cpu usage, im using core i7 ivy bridge and some 97d mains uses 15% of my cpu... thats insanely high for playing only mu online.

  11. #11
    Novice elite12sky is offline
    MemberRank
    Sep 2011 Join Date
    2Posts

    Re: Lower cpu usage

    i try same guide but can't find
    1. Search for SwapBuffers or glFlush (search for name/lable CTRL+N)

    Gembrid please answer my pm thank you.

  12. #12
    ^_^ ashlay is offline
    MemberRank
    Jun 2010 Join Date
    BrazilLocation
    875Posts

    Re: Lower cpu usage

    tested in main 1.03k jpn and works very nice.
    ty =D

  13. #13
    Account Upgraded | Title Enabled! ulfsark is offline
    MemberRank
    Nov 2010 Join Date
    ValhallaLocation
    1,276Posts

    Re: Lower cpu usage

    This is awesome, lowered from 25 to 17. :)

  14. #14
    Proficient Member lokoes321 is offline
    MemberRank
    Nov 2007 Join Date
    174Posts

    Re: Lower cpu usage

    Quote Originally Posted by ulfsark View Post
    This is awesome, lowered from 25 to 17. :)
    Mine from 15 to 4 :), its a very nice optimization.

  15. #15
    Account Upgraded | Title Enabled! ulfsark is offline
    MemberRank
    Nov 2010 Join Date
    ValhallaLocation
    1,276Posts

    Re: Lower cpu usage

    Yea, 17 was the login screen, in the game it's 5. :)



Page 1 of 4 1234 LastLast

Advertisement