Skip to content

Tick budget

TickBudget wraps a server-tick handler and warns when it exceeds the per-subsystem budget configured by ConduitConfig.tickBudgetUs() (default 1000 μs). Each subsystem name has its own warn cooldown so a steadily-slow handler doesn’t flood the log. Cost when under budget is one System.nanoTime call.

  • You’re registering a server-tick handler and want a smoke alarm if it gets slow.
  • You’re investigating a stutter and want greppable per-subsystem warnings rather than a profiler dump.
  • You’re wrapping a Fabric ServerTickEvents.END_SERVER_TICK callback.
package me.zlex.conduit.util;
public final class TickBudget {
public static void measure(String subsystem, Runnable body);
public static Runnable wrap(String subsystem, Runnable body);
}

Warnings go through ConduitLog.TICK_BUDGET and are throttled to one every five seconds per subsystem name.

import me.zlex.conduit.util.TickBudget;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
public final class MyMod implements ModInitializer {
@Override
public void onInitialize() {
ServerTickEvents.END_SERVER_TICK.register(TickBudget.wrap("my-game.round",
server -> RoundController.tick(server)));
}
}

A typical warning line:

[conduit.TickBudget] my-game.round tick took 4123μs (budget 1000μs)
  • Pick subsystem names that are stable strings, not lambdas — they’re used as the cooldown key.
  • The cooldown is per-name, not global, so two genuinely-different slow systems both warn.
  • The budget can be tuned in conduit.toml via tick_budget_us.