M12.4: keep cellular wildlife ticking and retain scheduling debt
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m35s
Foundation / checks (tsan) (push) Failing after 17m51s
Foundation / checks (network) (push) Successful in 21m13s
Foundation / checks (client) (push) Successful in 22m19s
Foundation / checks (postgres) (push) Successful in 48m25s
Foundation / checks (checks) (push) Failing after 50m8s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m35s
Foundation / checks (tsan) (push) Failing after 17m51s
Foundation / checks (network) (push) Successful in 21m13s
Foundation / checks (client) (push) Successful in 22m19s
Foundation / checks (postgres) (push) Successful in 48m25s
Foundation / checks (checks) (push) Failing after 50m8s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
This commit is contained in:
+31
-17
@@ -55,6 +55,7 @@
|
||||
#include "evo/biology/founder.hpp"
|
||||
#include "evo/processes/development_opening.hpp"
|
||||
#include "evo/server/cellular_session_batch.hpp"
|
||||
#include "evo/server/lifecycle/cellular_schedule.hpp"
|
||||
#include "evo/server/lifecycle/primitive_lives.hpp"
|
||||
#include "evo/server/lifecycle/wildlife_controller.hpp"
|
||||
#include "evo/server/ops_http.hpp"
|
||||
@@ -927,7 +928,7 @@ int serve_cellular(Options& o) {
|
||||
}
|
||||
bool ready = false;
|
||||
std::optional<server::HostPhase> phase;
|
||||
std::optional<std::chrono::steady_clock::time_point> next_tick;
|
||||
server::CellularTickSchedule schedule;
|
||||
std::vector<network::CarriedAction> awaiting_outcomes;
|
||||
// A tick that cannot be built is retried every 50 ms; name each distinct cause once.
|
||||
std::optional<std::pair<std::string_view, server::CellularSessionBatchError>> stalled;
|
||||
@@ -1022,8 +1023,14 @@ int serve_cellular(Options& o) {
|
||||
: server::OpsResponse{
|
||||
503, std::string("not ready: ") +
|
||||
server::phase_name(current.phase) + "\n"};
|
||||
if (path == "/metrics")
|
||||
return {200, server::render_metrics(current, {})};
|
||||
if (path == "/metrics") {
|
||||
auto paced = current;
|
||||
paced.tick_debt = schedule.status().debt;
|
||||
paced.max_tick_debt = schedule.status().max_debt;
|
||||
server::OpsCounters counters;
|
||||
counters.checkpoint_age_ms = schedule.status().head_age_us / 1000;
|
||||
return {200, server::render_metrics(paced, counters)};
|
||||
}
|
||||
return {404, "not found\n"};
|
||||
};
|
||||
ops->serve(handler);
|
||||
@@ -1033,15 +1040,11 @@ int serve_cellular(Options& o) {
|
||||
|
||||
const auto* state = host.state();
|
||||
bool player_present = false;
|
||||
// ADR-0128: a lingering life keeps the region ticking until its linger completes.
|
||||
bool lingering_present = false;
|
||||
if (status.ready && state) {
|
||||
for (const auto& life : state->lives()) {
|
||||
network::AccountId account;
|
||||
account.bytes = life.account;
|
||||
player_present = player_present || bridge->sessions().holder(account);
|
||||
lingering_present =
|
||||
lingering_present || life.presence == server::CellularPresence::lingering;
|
||||
}
|
||||
}
|
||||
// A queued birth publishes only while its account holds a session here: the
|
||||
@@ -1057,11 +1060,23 @@ int serve_cellular(Options& o) {
|
||||
held_births.push_back(birth);
|
||||
}
|
||||
const bool birth_waiting = !held_births.empty();
|
||||
if (status.ready && state && (player_present || birth_waiting || lingering_present)) {
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
if (!next_tick)
|
||||
next_tick = now + std::chrono::milliseconds{50};
|
||||
if (now >= *next_tick && state->tick() != UINT64_MAX) {
|
||||
const bool needed = state && (player_present || birth_waiting ||
|
||||
server::cellular_unattended_tick_needed(*state));
|
||||
const auto monotonic_us = [] {
|
||||
return static_cast<std::uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch())
|
||||
.count());
|
||||
};
|
||||
const auto paced = schedule.observe(monotonic_us(), status.epoch,
|
||||
state ? state->tick() : status.committed_tick, needed,
|
||||
status.ready && state);
|
||||
if (!paced) {
|
||||
std::puts("error cellular-schedule");
|
||||
return finish(4);
|
||||
}
|
||||
if (status.ready && state && needed) {
|
||||
if (paced->due && state->tick() != UINT64_MAX) {
|
||||
const auto tick = state->tick() + 1;
|
||||
std::vector<server::CellularLifeIntent> baseline;
|
||||
baseline.reserve(state->lives().size());
|
||||
@@ -1150,12 +1165,11 @@ int serve_cellular(Options& o) {
|
||||
deliver_finalized();
|
||||
}
|
||||
}
|
||||
*next_tick = std::chrono::steady_clock::now() +
|
||||
std::chrono::microseconds{static_cast<std::chrono::microseconds::rep>(
|
||||
biology::cellular_motion_tick_microseconds)};
|
||||
// Only a confirmed head consumes pacing debt. Retry failures with bounded
|
||||
// frequency while retaining debt; never reset a deadline to now + quantum.
|
||||
if (!host.state() || host.state()->tick() < tick)
|
||||
schedule.defer(monotonic_us());
|
||||
}
|
||||
} else {
|
||||
next_tick.reset(); // A disconnected life does not accumulate offline ticks.
|
||||
}
|
||||
if (const auto* committed_state = host.state(); committed_state)
|
||||
bridge->replicate(*committed_state);
|
||||
|
||||
Reference in New Issue
Block a user