Audit trails for model decisions in MLOps - Time & Space Complexity
Tracking audit trails for model decisions helps us know how long it takes to record each decision.
We want to see how the time to save logs grows as more decisions happen.
Analyze the time complexity of the following code snippet.
for decision in model_decisions:
log_entry = create_log(decision)
save_to_audit_trail(log_entry)
This code saves each model decision to an audit trail one by one.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping over each model decision to create and save a log.
- How many times: Once for every decision in the input list.
Each new decision adds one more log entry to save, so the work grows steadily.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 log saves |
| 100 | 100 log saves |
| 1000 | 1000 log saves |
Pattern observation: The time grows directly with the number of decisions.
Time Complexity: O(n)
This means the time to save audit logs grows in a straight line as decisions increase.
[X] Wrong: "Saving audit logs happens instantly no matter how many decisions there are."
[OK] Correct: Each decision adds work to save logs, so more decisions mean more time needed.
Understanding how logging scales helps you design systems that keep track of decisions without slowing down.
"What if we batch multiple decisions before saving logs? How would the time complexity change?"