this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add phase timing instrumentation (unmarshal/read_impl/compile)

Emit ODOC_PHASE_TIME lines on stderr when ODOC_GC_STATS=1 is set,
breaking down the compile command into unmarshal (Cmt_format.read_cmt),
read_impl (Cmt.read_implementation), and compile (Xref2.Compile)
phases. Useful for identifying which phase dominates on large files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+20
+10
src/loader/odoc_loader.cppo.ml
··· 153 153 | _ -> raise Not_an_interface 154 154 155 155 let read_cmt ~make_root ~parent ~filename ~warnings_tag () = 156 + let t_unmarshal = Sys.time () in 156 157 match Cmt_format.read_cmt filename with 157 158 | exception Cmi_format.Error (Not_an_interface _) -> 158 159 raise Not_an_implementation ··· 214 215 make_compilation_unit ~make_root ~imports ~interface ~sourcefile ~name 215 216 ~id content 216 217 | Implementation impl -> 218 + (match Sys.getenv_opt "ODOC_GC_STATS" with 219 + | Some s when s <> "" && s <> "0" -> 220 + Printf.eprintf "ODOC_PHASE_TIME unmarshal=%.3f\n%!" (Sys.time () -. t_unmarshal) 221 + | _ -> ()); 217 222 Cmt.cmt_builddir := cmt_info.cmt_builddir; 218 223 Cmti.cmti_builddir := cmt_info.cmt_builddir; 224 + let t0 = Sys.time () in 219 225 let id, sg, canonical = 220 226 Cmt.read_implementation parent name ~warnings_tag impl 221 227 in 228 + (match Sys.getenv_opt "ODOC_GC_STATS" with 229 + | Some s when s <> "" && s <> "0" -> 230 + Printf.eprintf "ODOC_PHASE_TIME read_impl=%.3f\n%!" (Sys.time () -. t0) 231 + | _ -> ()); 222 232 compilation_unit_of_sig ~make_root ~imports ~interface ~sourcefile 223 233 ~name ~id ?canonical sg 224 234 | _ -> raise Not_an_implementation)
+10
src/odoc/compile.ml
··· 142 142 |> Error.raise_errors_and_warnings 143 143 in 144 144 let unit = { unit with hidden = hidden || unit.hidden } in 145 + let t_load = Sys.time () in 146 + (match Sys.getenv_opt "ODOC_GC_STATS" with 147 + | Some s when s <> "" && s <> "0" -> 148 + Printf.eprintf "ODOC_PHASE_TIME loader=%.3f\n%!" t_load 149 + | _ -> ()); 145 150 if not unit.Lang.Compilation_unit.interface then 146 151 Printf.eprintf "WARNING: not processing the \"interface\" file.%s\n%!" 147 152 (if not (Filename.check_suffix filename "cmt") then "" (* ? *) ··· 150 155 (* Resolve imports, used by the [link-deps] command. *) 151 156 let unit = { unit with imports = resolve_imports resolver unit.imports } in 152 157 let env = Resolver.build_compile_env_for_unit resolver unit in 158 + let t_compile_start = Sys.time () in 153 159 let compiled = 154 160 Odoc_xref2.Compile.compile ~filename env unit |> Error.raise_warnings 155 161 in 162 + (match Sys.getenv_opt "ODOC_GC_STATS" with 163 + | Some s when s <> "" && s <> "0" -> 164 + Printf.eprintf "ODOC_PHASE_TIME compile=%.3f\n%!" (Sys.time () -. t_compile_start) 165 + | _ -> ()); 156 166 (* [expand unit] fetches [unit] from [env] to get the expansion of local, previously 157 167 defined, elements. We'd rather it got back the resolved bit so we rebuild an 158 168 environment with the resolved unit.