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.
When to use it
Section titled “When to use it”- 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_TICKcallback.
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.
Example
Section titled “Example”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.tomlviatick_budget_us.