Lower cpu usage

Page 1 of 3 123 LastLast
Results 1 to 25 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
    888Posts

    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. :)

  16. #16
    Trafalgar D. Water Law Dope Boy One is offline
    ModeratorRank
    Jun 2005 Join Date
    HellasLocation
    1,227Posts

    Re: Lower cpu usage

    Well that's f**ing awesome !!

  17. #17
    Proficient Member x00000 is offline
    MemberRank
    Jun 2012 Join Date
    MoldovaLocation
    160Posts

    Re: Lower cpu usage

    Please help me, i try solo, and i failed
    link to my main.exe

  18. #18
    Proficient Member x00000 is offline
    MemberRank
    Jun 2012 Join Date
    MoldovaLocation
    160Posts

    Re: Lower cpu usage

    up, if need be i pay this fo some $, contact me! (skype: firenight29)

  19. #19
    Alpha Member 2009x2014 is offline
    MemberRank
    Dec 2009 Join Date
    2,765Posts

    Re: Lower cpu usage

    Quote Originally Posted by x00000 View Post
    up, if need be i pay this fo some $, contact me! (skype: firenight29)
    just research offsets base on the main offsets of gembrid provided of 97 / 1.03.27 main or on 1.07v by 8bitcore
    close to ur main using ollydbg (compare code)

    then adapt changes / save & test.

  20. #20
    Proficient Member x00000 is offline
    MemberRank
    Jun 2012 Join Date
    MoldovaLocation
    160Posts

    Re: Lower cpu usage

    I don't understand, please help if you know this link to my main.exe

  21. #21
    Alpha Member 2009x2014 is offline
    MemberRank
    Dec 2009 Join Date
    2,765Posts

    Re: Lower cpu usage

    Quote Originally Posted by x00000 View Post
    I don't understand, please help if you know this link to my main.exe
    well idk what was the prob for you, it's 1 sec to find the right offset by searching Swap buffers or txt string - "Connection closed"

    so for ur main it's 006703E4

    now what u have to do i's call kernel sleep on 00670405 & nop useless line

    sleep for ur main = CALL DWORD PTR DS:[6E8148]

    so the final code shd lk like

    Code:
    00670405     6A 01          PUSH 1
    00670407     FF15 48816E00  CALL DWORD PTR DS:[<&KERNEL32.Sleep>]    ;  kernel32.Sleep
    0067040D     90             NOP
    0067040E     90             NOP
    0067040F     90             NOP
    00670410     90             NOP
    00670411     90             |NOP
    00670412     90             NOP
    00670413     90             NOP
    00670414     90             NOP
    00670415     90             NOP
    00670416     90             NOP

    HF ;)
    Last edited by 2009x2014; 12-11-13 at 09:03 PM.

  22. #22
    Proficient Member x00000 is offline
    MemberRank
    Jun 2012 Join Date
    MoldovaLocation
    160Posts

    Re: Lower cpu usage

    thx man, but is lagged after loading main... it's stop move animation and nothing happened.

    my code:
    Code:
    006703E4  |. FF15 74806E00  CALL DWORD PTR DS:[<&GDI32.SwapBuffers>] ; \SwapBuffers
    006703EA  |> FF15 44816E00  CALL DWORD PTR DS:[<&KERNEL32.GetTickCou>; [GetTickCount
    006703F0  |. 2B85 A0FEFFFF  SUB EAX,DWORD PTR SS:[EBP-160]
    006703F6  |. 8985 98FEFFFF  MOV DWORD PTR SS:[EBP-168],EAX
    006703FC  |> 83BD 98FEFFFF >/CMP DWORD PTR SS:[EBP-168],28
    00670403  |. 7D 14          |JGE SHORT Main.00670419
    00670405     6A 01          PUSH 1
    00670407     FF15 48816E00  CALL DWORD PTR DS:[<&KERNEL32.Sleep>]    ;  kernel32.Sleep
    0067040D     90             NOP
    0067040E     90             NOP
    0067040F     90             NOP
    00670410     90             NOP
    00670411     90             |NOP
    00670412     90             NOP
    00670413     90             NOP
    00670414     90             NOP
    00670415     90             NOP
    00670416     90             NOP
    00670417  |.^EB E3          \JMP SHORT Main.006703FC
    any idees ?
    Last edited by x00000; 12-11-13 at 09:04 PM.

  23. #23
    Alpha Member 2009x2014 is offline
    MemberRank
    Dec 2009 Join Date
    2,765Posts

    Re: Lower cpu usage

    Quote Originally Posted by x00000 View Post
    any idees ?
    Try

    00670417 |.^EB E3 \JMP SHORT Main.006703FC ---> 006703EA

  24. #24
    Proficient Member x00000 is offline
    MemberRank
    Jun 2012 Join Date
    MoldovaLocation
    160Posts

    Re: Lower cpu usage

    thx, man, I love you ! it's work

    new, tell me please how i find sleep in this main ?

  25. #25
    Alpha Member 2009x2014 is offline
    MemberRank
    Dec 2009 Join Date
    2,765Posts

    Re: Lower cpu usage

    Quote Originally Posted by x00000 View Post
    thx, man, I love you ! it's work

    new, tell me please how i find sleep in this main ?
    np & same, by searching Swap buffers (CTRL+N) or txt string - "Connection closed"

    anw offset of right sb for this main = 006B4A23

    ps: also dont forget about jmp to gettickcount next to swapbuffers (006B4A29)



Page 1 of 3 123 LastLast

Advertisement