timeline.rs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //! Diagnostics: a timeline of a few frames. `VICTORY_TIMELINE=<file>` writes
  2. //! one, from the first present after `VICTORY_TIMELINE_AT` seconds (60) on
  3. //! and for `VICTORY_TIMELINE_FRAMES` frames (3);
  4. //! `VICTORY_TIMELINE=<from s>[+<from s>..],<frames>,<file>` one for each of
  5. //! the times (each in a file of its own, the second in its name): a Chrome trace (JSON, for
  6. //! `chrome://tracing` or Perfetto) and beside it a text summary (`.txt`)
  7. //! with the chain of work and waits each frame's present came out of.
  8. //!
  9. //! What is recorded while it runs, by every thread:
  10. //! - spans of ours ([`span`]): the title's calls, the submitting thread's
  11. //! stages, the relay's, the pools' jobs, texture and streaming work;
  12. //! - waits and the wake-ups that end them ([`hooks`]): the functions the
  13. //! title's threads wait with (its imports are bound to wrappers) and those
  14. //! our own code does (the entries of our own import table: every contended
  15. //! lock, condition and park of the standard library is a `WaitOnAddress`),
  16. //! each with the thread that woke it and where it waited;
  17. //! - kernel calls on the address space that took long;
  18. //! - the card: when each submission began and ended on it (timestamps).
  19. //!
  20. //! Without the variable nothing is wrapped and a span is one load of a
  21. //! flag; a build without `diagnostics` has nothing of it.
  22. #[cfg(all(windows, feature = "diagnostics"))]
  23. mod hooks;
  24. #[cfg(all(windows, feature = "diagnostics"))]
  25. mod record;
  26. #[cfg(all(windows, feature = "diagnostics"))]
  27. mod report;
  28. #[cfg(all(windows, feature = "diagnostics"))]
  29. pub use hooks::import;
  30. #[cfg(all(windows, feature = "diagnostics"))]
  31. pub use record::{Span, span};
  32. #[cfg(all(windows, feature = "diagnostics"))]
  33. pub(crate) use record::{called, card_wait, on, polled, presented, sent, ticks, title_thread, told};
  34. /// A span of ours: from where it is made until it is dropped.
  35. #[cfg(not(all(windows, feature = "diagnostics")))]
  36. pub struct Span;
  37. #[cfg(not(all(windows, feature = "diagnostics")))]
  38. impl Span {
  39. /// The span ends here and another begins.
  40. #[inline(always)]
  41. pub fn next(&mut self, _name: &'static str) {}
  42. /// The span ends here.
  43. #[inline(always)]
  44. pub fn end(self) {}
  45. }
  46. /// A span named `name`.
  47. #[cfg(not(all(windows, feature = "diagnostics")))]
  48. #[inline(always)]
  49. pub fn span(_name: &'static str) -> Span {
  50. Span
  51. }