Skip to content

perf(flowc): avoid dormant profiler clock calls at compiler startup (#735) - #1415

Closed
godofecht wants to merge 6 commits into
mainfrom
fix/735-no-unconditional-profile-startup-clock
Closed

godofecht wants to merge 6 commits into
mainfrom
fix/735-no-unconditional-profile-startup-clock

Conversation

@godofecht

@godofecht godofecht commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Part of #735. Does not close it.

Change

compiler/src/profile.flow embeds a GCC constructor, flowc_prof_ctor, that called clock_gettime before main on every flowc run, even with FLOWC_PROFILE unset. It now calls it only when flowc_prof_mode_c() is non-zero. The mode is read once from the environment and cached, so a disabled run costs one getenv. docs/project/compile-profile.md says so. No speedup is claimed.

Evidence

Rebased onto main 948ae09. Bootstrap regenerated in its own commit.

  • compile_profile/ctor_clock_gated (added in this rebase) checks that the constructor in compiler/bootstrap/flowc_stage_a.c is gated. It fails against main's bootstrap and passes here. The constructor cannot be observed from outside the process, so the test reads the C that the shipped compiler is built from.
  • compile_profile/explicitly_disabled checks that 0, false, off and no print no profile.
  • ./flow tool tests/scripts/compile_profile.flow: 7 passed.
  • Edited compiler selftest: flowc: PASS. bootstrap_from_c.sh --regen: fixed point at gen2; --verify: PASS.
  • self_host_full.flow: ALL PASS. roundtrip.flow: ALL PASS. ./flow tool tests/cgen/run.flow: 130/0.
  • ./flow test-lang 274/0, ./flow test-runtime 34/0, ./flow tool tests/cli/run.flow 152 passed, 2 failed (jit_hello, test_mlir: golden drift on main).

Merge notes: tests/scripts/compile_profile.flow is also edited by #1401; the two merge cleanly (git merge-tree). As a compiler/src PR it needs its own bootstrap regeneration at merge time.

@godofecht
godofecht marked this pull request as ready for review October 6, 2026 23:18
@godofecht
godofecht marked this pull request as draft October 6, 2026 23:19
@godofecht
godofecht force-pushed the fix/735-no-unconditional-profile-startup-clock branch from 5d050d5 to e37b212 Compare October 7, 2026 12:38
@godofecht
godofecht marked this pull request as ready for review October 7, 2026 12:38
@godofecht

Copy link
Copy Markdown
Contributor Author

Landed in #1429 as 3891827 (lane C train).

@godofecht godofecht closed this Oct 7, 2026
@godofecht
godofecht deleted the fix/735-no-unconditional-profile-startup-clock branch October 12, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant