[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Why gc sweepstep() doesn't return the real free bytes?
- From: 张伟智 <robotk@...>
- Date: Sat, 19 Dec 2015 21:18:44 +0800 (CST)
At 2015-12-19 02:57:41, "Roberto Ierusalimschy" <firstname.lastname@example.org> wrote:
>> If I adjust GCSWEEPCOST to a larger value,
>> the time of sweep state becomes long,
>> and CPU's usage becomes lower.
>> But it is a little difficult to adjust GCSWEEPCOST to a fit value;
>> I am curious about why sweepstep() doesn't return the real free bytes, i.e, olddebt - g->GCdebt ?
>In most (all?) systems, the time to free a block does not depend on its
>size. More important, we waste time doing a sweep even if we do not
>release any memory. So, I do not see why the measure of "work" done
>during a sweep should be related to how much memory was freed.
>(We could use the size of object being sweeped, but that increases the
>work done during a sweep, and again, the time to sweep an object does
>not depend on its size.)
>That said, all these constants (like GCSWEEPCOST, STEPMULADJ) are rough
>guesses, and substantiated suggestions for better values are more
>> In our program, collectgarbage("count") is 10G at the end of propagate state,
>> while gc switch to sweep state, gc system free 5G bytes in only 30 seconds,
>> and the usage of CPU is 99.9% during the whole 30 seconds sweep state;
>Is that a problem? Is your program too slow during that period? If you
>just feel the sweep is too fast, you can compensate it by setting a
>longer pause after the sweep.
My program is a MMORPG(massively multiplayer online role-playing game) server.
It sometimes has 10 thousands players online.
You can think of it as a half real-time system.
I hope the delay time of player's operation can be low,
and the CPU's usage is smooth in all the time.
In propagate state, it is OK.
But in sweep state, the delay time increases obviously.
It usually take a few seconds for player to see the menu content after click the menu on client.
This is boring.
Actually, I set the "setpause" value to a small value to avoid the memory usage increase to a large value,
once the memory usage increase , the total execute time of atomic() function becomes long,
it will also increase the delay time of player's operation.
Whether it is a solution to change the sweepstep() to return the real free bytes,
so the CPU's usage is smooth in sweep state like the propagate state.