Add Source Note about main loop performance (#3243)

The main loop's code is performance-critical, and this has implications
on tasks design and planning. Knowing this earlier would help me avoid
some major workflow inefficiencies while working on tasks touching this
code.
This commit is contained in:
Mateusz Czapliński 2022-02-02 12:30:26 +01:00 committed by GitHub
parent b5fc87e618
commit b6cf6b93eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,6 +85,8 @@ impl World {
let main_loop_frame = main_loop.on_frame( let main_loop_frame = main_loop.on_frame(
f!([stats_monitor,on_before_frame,on_after_frame,uniforms,scene_dirty,scene] f!([stats_monitor,on_before_frame,on_after_frame,uniforms,scene_dirty,scene]
(t:animation::TimeInfo) { (t:animation::TimeInfo) {
// Note [Main Loop Performance]
stats_monitor.begin(); stats_monitor.begin();
on_before_frame.run_all(&t); on_before_frame.run_all(&t);
@ -113,6 +115,19 @@ impl World {
.init() .init()
} }
// Note [Main Loop Performance]
// ============================
// Any code repeated on each iteration of the Main Loop (each "frame") must be written with
// high care for performance. Any changes that has a chance of negatively impacting the
// constant overhead of the main loop needs *explicit* explanation, review, and acceptance *at
// design stage* of the proposed new implementation, from performance perspective, with an
// explicit note of the fact of Main Loop impact.
//
// Rationale: the "Main Loop" contains the code comprising a GUI rendering "frame" (term
// originating from a "still frame" term in filmmaking). The speed at which the Main Loop
// executes directly translates to the perceived performance of the GUI, and the FPS (frames
// per second) metric, impacting Users' experience with the application.
fn init(self) -> Self { fn init(self) -> Self {
self.init_composer(); self.init_composer();
self.init_hotkeys(); self.init_hotkeys();