Replaying a Log in Order

A reported assessment problem asks you to parse execution logs and compute statistics from them, and it is representative of a family. You are given a record of what happened, and you must reconstruct a state or a summary. What makes these problems hard is never the arithmetic. It is that "the order things happened in" is more ambiguous than it sounds.

Timestamps tie, and a tie is not a coin flip

Two events carry the same microsecond. Your program has to process them in some order, and if the order changes the answer, then your answer is not determined by the data. That is the property to be afraid of: not wrongness, but non-reproducibility. Run the same file twice, get two results, and no amount of debugging converges.

The fix is a total order: a tie-break that is part of the data rather than part of the runtime.

The rest of this lesson is for subscribers

Unlock every lesson in Programming for Quantitative Developers, and every other premium course.

Subscribe to continue

Test your knowledge

Questions are only available to subscribers.

Keep reading Programming for Quantitative Developers

25 lessons in this course, and every other premium course, on one subscription.

  • Every lesson in every course, with the worked examples and interactive simulators
  • Graded questions on every lesson, with explanations for the wrong answers as well as the right one
  • The trainers, timed assessments and brainteaser library that go with them