Add device/edge CPU, network latency, switch penalty to offloading_decisions#68
Open
ff225 wants to merge 7 commits into
Open
Add device/edge CPU, network latency, switch penalty to offloading_decisions#68ff225 wants to merge 7 commits into
ff225 wants to merge 7 commits into
Conversation
…alty to offloading_decisions The offloading_decisions document lacked device/edge CPU load, network latency, and switch penalty, and duplicated the selected layer as a per-candidate boolean instead of relying on the existing top-level selected_layer field. Add the four missing top-level metrics (edge CPU sampled server-side via psutil, mirroring the existing device-side metric) and drop the redundant per-candidate boolean, with backward-compatible lookup for older documents. Closes #61
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #61.
The
offloading_decisionsJSON/CSV document was missing several fields the issue asked for, and had a redundant per-candidateselectedboolean instead of relying on the document's existing top-levelselected_layer:device_cpu_percent(already computed client-side, just not surfaced at the document's top level) and newedge_cpu_percent, sampled server-side viapsutil.cpu_percent()inrequest_handler.get_edge_cpu_percent()— mirrors the existing device-side pattern inhttp_client.py(module-level warm-up call, clamped to[0, 100],0.0fallback ifpsutilis unavailable or errors).network_latency_ms(from the already-computed request round-trip time) alongside the existingavg_speed_bytes_per_second.switch_penalty: promoted to the top level from the selected candidate (only populated for strategies with switch hysteresis, e.g.adaptive_risk;0.0forstatic).selected_layerfield already existed — removed the redundant per-candidate"selected"boolean inbuild_offloading_decision_event().selected_candidate()(used bysummarize_prediction_errorand the analysis notebooks) now derives the selected candidate fromselected_layerinstead, with backward-compatible fallback to the boolean for older exported documents.scripts/analysis/telemetry_notebook_utils.py::selected_candidate()already had this fallback, so the analysis notebooks are unaffected.Decision notes
edge_cpu); added it using the samepsutil-optional pattern already used fordevice_cpu_percentclient-side, rather than inventing a new dependency or config surface.offloading-decision.v1), and all other fields unchanged — this is an additive/cleanup change to the existing schema, not a new schema version.Test plan
test_offloading_decision_event_includes_load_and_network_metricsandtest_offloading_decision_event_defaults_load_and_network_metrics_to_zerointests/unit/test_offloading_decision_events.py; updated the existing selected-candidate test to assert the boolean is gone andselected_candidate()still resolves correctly.get_edge_cpu_percentunit tests intests/unit/test_request_handler_helpers.py(clamping, missingpsutil,psutilraising).docs/OFFLOADING_DECISION_EVENTS.mdschema table and CSV example.uv run pytest tests/unit -q— 150 passed, 1 skippedtests/unit, integration subset, mqtt, offloading_algo) — 208 passed, 1 skipped, no regressions