New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework server stepping and dtime calculation #13370
Conversation
2a742d5
to
86c651e
Compare
86c651e
to
92a2631
Compare
(Rebased.) |
src/server.cpp
Outdated
// Already break if there's 1ms left, as ReceiveTimeoutMs is too coarse | ||
// and a faster server-step is better than busy waiting. | ||
if (remaining_time_us() < 1000.0f) | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this mean the server step will randomly jitter from 0-999us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does. And I'd use µs precision here. But to do that, Semaphore::wait
would need to be changed accordingly, and win32's WaitForSingleObject
only accepts ms.
e91036a
to
6f9a78b
Compare
Rebased. |
522897e
to
fcee6ef
Compare
Rebased. |
ead94df
to
bd17ea4
Compare
Trivially rebased, and comments addressed (last commit). Thx for reviewing. |
@Desour rebase needed |
bd17ea4
to
e43263e
Compare
e43263e
to
9cfd511
Compare
Rebased. And tested again. Everything works as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server and client steps still run. Looks good.
I did not check against the time stop issue when no-one is online but given the timeout code in Server::Receive
.
Haven't had a chance to try. Looks right. |
Old:
runs in a loop in which it receives for at least 30 ms (hardcoded in
Server::start()
via
m_con->SetTimeoutMs(30);
), and then reads and resets the dtime counter.If the counter is >= 1ms, it does a server-step (AsyncRunStep).
0ms (0 frames, server-step skipped), 16ms (1 frame) and 33ms (2 frames), and
the actual times between the server-steps are >30ms or >60ms.
New:
if there are more packets), and calculates dtime itself.
Effects:
doesn't cause coarse server-steps).
Note that pause and unfocus are now handled explicitly. But the results are
similar to before.
(In master, the receive of the first packet has a timeout of 30 ms.)
To do
This PR is a Ready for Review.
How to test
Server::AsyncRunStep
to errorstream.To test the #14093 issue:
dedicated_server_step
to0.016
./lua local function f() core.sound_play("item_drop_pickup_1") core.after(0, f) end f()
(Sound from here: https://github.com/minetest-mods/item_drop/blob/master/sounds/item_drop_pickup.1.ogg Other short sounds might work as well.)
Server::AsyncRunStep
to errorstream.