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 and others added 30 commits July 3, 2025 15:20
* setting up the generator

* poisson-poisson requests sampling

* Delete docker_fs/.env.dev

* Delete docker_fs/.env.test

* changes

* refactor for event generator

* added gaussian truncated generator and unit tests for helpers

* imprved documentantion and simulation time handling

* simulation start with the vent generator

* small refactor + tests for the generation of events

* minor changes

* Update src/app/schemas/simulation_input.py

Co-authored-by: Copilot <[email protected]>

* Update tests/unit/sampler/test_sampler_helper.py

Co-authored-by: Copilot <[email protected]>

* Update scripts/quality-check.sh

Co-authored-by: Copilot <[email protected]>

* Update tests/integration/db_initialization/test_init_models.py

Co-authored-by: Copilot <[email protected]>

* minor changes after PR review

---------

Co-authored-by: Copilot <[email protected]>
* moving file to correct folder

* Documentation added

* Update requests_generator.md

* test Added, introduced constants for the sampling window

* Update tests/unit/sampler/test_poisson_posson.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
* Introduction of the input structure for endpoints

* Documentation + foundation of topology input

* Improve Step validation, added unit test for the input

* improved documentation for the input
* Improved input structure and pytest

* Improved pytest structure accordingly to the new schema

* definition of the metrics to be measured and update of the simulation input

* improved documentations added rationale behind metrics

* improved pytest logic and code coherence

* Update src/app/core/helpers.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
* definition of state and RqsGeneratorRuntime

* defined edge runtime and more central logic for sampler

* minor changes

* minor changes

* minor bug fixed

* pytest adapted to the new structure, added pytest for rqs_state

* Update src/app/core/runtime/rqs_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/rqs_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/edge.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/runtime/edge.py

Co-authored-by: Copilot <[email protected]>

* Update tests/unit/runtime/test_requests_generator.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* Update src/app/core/event_samplers/common_helpers.py

Co-authored-by: Copilot <[email protected]>

* minor changes

---------

Co-authored-by: Copilot <[email protected]>
* defined client runtime + tests

* initiated the server runtime plus correction of tghe structure

* code refactor + test added for runtime + documentation

* Update tests/conftest.py

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
* defined architecture for the central collector + documentation

* server modification to collect metrics and updated docs

* Completed metric collector for server plus test

* remove web app dependencies and added metrics for rqs latency

* improved docs and improved metric collection

* changes to make the code compatible with new changes

* improved ci against toml changes

* update lock file

* minor change
* introduction to the analyzer class + tests

* refactor of the analyzer
* Added LB structure in the input for the simulation + tests

* introduced LB runtime + documentation

* Added test for LB and small refactor to define the SimRunner
* added the first method to the simulation runner

* added methods to handle nodes

* completed simulation runtime + integration test
* new integration test + bug fixing

* added integration and unit test

* first tests working

* minor change

* first working example, upgrade docs, upgrade docstrings

* improvements

* path bug fixed
* Changed name from fastsim to asyncflow app folder renamed in asyncflow

* improved docs
* Reafctor for the folder schemas + defined import for public api

* Defined public api, improved docs
GioeleB00 and others added 26 commits August 17, 2025 17:43
* Readme final, docs improved

* Docs improvement, refactor analyzer, example added

* Added scripts for setup, added pytest, improved readme

* Example LB improvements

* CI for main + system tests
# Conflicts:
#	pyproject.toml
# Conflicts:
#	pyproject.toml
* Structure defined for the pydantic model representing Event to be injected

* Pydantic validation in the payload for events part 1

* Definition of the input for the events injection part 2

* minor fixes ruff and mypy compliant

* full tests and docs added for input event injection

* fixed minor bugs
* Events injection for edges part 1

* Logic + docs for the event injection to simulate a server down

* Added pydantic validation + unit + int tests for eventinjection

* added exaple for event inj yaml + builder added int tests

* improved server model + system tests for eventinjection

* ruff small fix
* new readme, ci to have pycov badge, comment on server runtime

* small changes
# Conflicts:
#	.github/workflows/ci-main.yml
#	README.md
#	tests/system/test_sys_ev_inj_lb_two_servers.py
* added metric for server, added logic to collect them + tests

* add kpi to collect in settings default

* added metric plot for server and tests

* Sweep introduction + MM1 heory vs observation + tests

* analysis for sweep results + tests

* mm1 notebook complete + server latency
… and end-to-end comparison reports (#26)

* mmc split + notebook mmc split + random lb algo

* tests for mmc
* changing api per ArrivalsGenerator and implementing distrib for ArrivalRuntime

* Reafctoring API Arrival generator, tests integrations now working

* Api Arrival generator migration complete with tests
@GioeleB00 GioeleB00 merged commit a726a2a into main Sep 18, 2025
1 of 2 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.

2 participants