Add OT_TRACE_TIMER and wire timing into import / export / mesh paths#4
Merged
Conversation
Extends the trace infra from v0.2.0 with a RAII wall-clock timer and covers the file I/O and mesh extraction entry points so a real Templot workload can be profiled end-to-end with OCCT_TEMPLOT_TRACE=1. Trace surface added: - ot_import_stl, ot_import_stl_robust - ot_import_step, ot_import_step_robust, ot_import_step_with_diagnostics - ot_import_iges, ot_import_iges_robust - ot_import_obj - ot_export_stl, ot_export_step, ot_export_iges, ot_export_obj, ot_export_ply - ot_mesh_shape, ot_mesh_shape_separate, ot_mesh_shape_fill - ot_edge_mesh_shape Each function emits an enter line, a phase trace around heavy OCCT calls (ReadFile / TransferRoots / Sewing::Perform / ShapeFix::Perform / BRepMesh_IncrementalMesh::Perform / writer.Write), and an exit line with output counts where applicable. The new OT_TRACE_TIMER(label) RAII guard reports total wall time on every return path including exception unwind. Sample output on bearing.stl (24,680 triangles, OCCT 8.0.0-beta1, macOS arm64): ot_import_stl: 454 ms ot_export_stl (mesh + write): 2,436 ms ot_export_step: 5,795 ms ot_mesh_shape: 1,979 ms (cold mesh) ot_mesh_shape_separate: 1,256 ms (warm cache) Tracing remains off by default; ctest 4/4 green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Extends the v0.2.0 trace infrastructure with a RAII wall-clock timer and wires per-call timing + phase boundaries into the file I/O and mesh extraction paths so a real Templot workload can be profiled end-to-end with
OCCT_TEMPLOT_TRACE=1.What landed
New
OT_TRACE_TIMER(label)macro insrc/occt_templot_trace.h. Place near the top of a function (after the NULL guard) — emits[ot] label: <ms> mson every return path including exception unwind. Cost is onesteady_clock::now()on entry plus one on exit; effectively free when tracing is off (the destructor short-circuits onenabled()).Wired into 16 entry points:
ot_import_*+_robustvariants +_with_diagnostics)ot_mesh_shape,_separate,_fill,ot_edge_mesh_shape)Each function emits enter / phase / exit traces around the OCCT-heavy work (
ReadFile,TransferRoots,BRepBuilderAPI_Sewing::Perform,ShapeFix_Shape::Perform,BRepMesh_IncrementalMesh::Perform,writer.Write).Sample output on bearing.stl (24,680 triangles, macOS arm64, OCCT 8.0.0-beta1)
Why
v0.2.0 tracing covered analyze / heal / sew / make_solid (and surfaced an O(N^4) wire-matching bug). This PR extends the same pattern to import / export / mesh — the next likely suspects when "the Templot viewer feels slow" doesn't bottom out in the heal path. With this in place we can profile a representative workload and see where wall time actually goes before deciding whether the GL-on-Metal translation overhead is even worth pursuing.
Test plan
OCCT_TEMPLOT_TRACE=1 ./test_io bearing.stlproduces complete enter/phase/exit/timing traces for every code path it exercises.