Skip to content

Conversation

GioeleB00
Copy link
Collaborator

What we changed

  1. New FCFS implementation (central queue)
  • Rewrote LB FCFS to a token-based FIFO:

    • LoadBalancerRuntime._free_edges: simpy.Store holding one token per free LB→server edge.
    • On dispatch, LB get()s one token (blocking if none), then forwards the request to that edge.
    • Servers call notify_server_free → lb.mark_free(edge_id) to return the token when they finish.
    • Zero “thundering herd”: only one waiting request wakes up per free server.
    • Added LoadBalancerRuntime.on_edge_added(edge_id) so EventInjection can re-enable edges cleanly (push a token when a server comes back).
  1. Accurate FCFS waiting-time metric
  • LB now records per-request waiting times for FCFS in _lb_waiting_time and exposes them via lb_waiting_times
  • Arrival time at the LB is taken from the request’s last hop timestamp (history) at LOAD_BALANCER entry.
  • Ensured link edges deliver on the next tick (yield env.timeout(0)) to preserve causal order of timestamps.
  1. Results & analysis integration
  • SimulationRunner.run() now passes the LB runtime into ResultsAnalyzer (lb=self._lb_runtime).

  • ResultsAnalyzer exposes get_lb_waiting_times() and uses LB reference safely.

  • MMc analyzer:

    • Detects FCFS and uses Erlang-C formulas for theory.
    • For observed Wq under FCFS, it now uses LB waiting times (central queue), not per-server CPU wait.
    • Compatibility checks cleaned up (LB must be FCFS for pooled queue; RANDOM/RR still treated as split model).
  1. Event injection integration
  • EventInjectionRuntime re-adds edges (server up) and calls lb_on_edge_added(edge_id) (wired from the runner) so the token is immediately available again.
  • Removal of edges (server down) simply deletes from the LB’s OrderedDict; any stale tokens are discarded by the LB loop.
  1. Unit tests
  • New FCFS tests covering the token FIFO:

    • Immediate free edge ⇒ no wait recorded.
    • Wait until edge is added ⇒ Wq ≈ Δt.
    • Stale token discarded when edge removed, request waits for a valid edge.
    • FIFO order preserved across multiple edges & requests.
  • Adjusted annotations (mypy) and lints (no blind except).

@GioeleB00 GioeleB00 merged commit c5a8a52 into develop Sep 18, 2025
3 of 5 checks passed
@GioeleB00 GioeleB00 deleted the feature/FCFS-lb-algo branch September 18, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant