Skip to content

fix(codegen): route hour()/minute()/... to engine pine_* helpers (KI-35)#42

Merged
luisleo526 merged 1 commit into
mainfrom
fix/ki35-route-time-builtins-to-engine
Jul 7, 2026
Merged

fix(codegen): route hour()/minute()/... to engine pine_* helpers (KI-35)#42
luisleo526 merged 1 commit into
mainfrom
fix/ki35-route-time-builtins-to-engine

Conversation

@luisleo526

Copy link
Copy Markdown
Contributor

Problem (KI-35)

The time/date builtins (hour, minute, second, dayofmonth, dayofweek, month, year, weekofyear) were emitted as an inline setenv("TZ")+tzset()+localtime_r lambda evaluated once per bar. On macOS that tzset() hits notifyd over Mach IPC (~173µs/call); across a full 1m feed it costs minutes of wall time that read as an engine hang.

Fix

Emit calls to the engine's cached pine_<field>() helpers (session_time.hpp) instead, for both:

  • the bare-variable forms (BAR_BUILTINS in tables.py), and
  • the explicit tz-arg call form (visit_call.py).

Value-identical: same tm fields and Pine offsets (dayofweek=tm_wday+1, month=tm_mon+1, year+1900), DST-exact — the engine applies the offsets internally, so field_expr is dropped in the call form.

  • Fresh transpile emits zero leftover setenv("TZ") lambdas.
  • lukeborgerding trades byte-identical to baseline.

Dependency

Requires pineforge-engine with the paired pine_* symbols — merged first (pineforge-engine#70).

🤖 Generated with Claude Code

The time/date builtins (hour, minute, second, dayofmonth, dayofweek, month,
year, weekofyear) were emitted as an inline setenv("TZ")+tzset()+localtime_r
lambda evaluated once per bar. On macOS that tzset() hits notifyd over Mach IPC
(~173us/call); across a full 1m feed it costs minutes of wall time that read as
an engine hang (KI-35).

Emit calls to the engine's cached pine_<field>() helpers (session_time.hpp)
instead, for both the bare-variable forms (BAR_BUILTINS in tables.py) and the
explicit tz-arg call form (visit_call.py). Value-identical: same tm fields and
Pine offsets (dayofweek=tm_wday+1, month=tm_mon+1, year+1900), DST-exact — the
engine applies the offsets internally, so field_expr is dropped in the call
form. Fresh transpile emits zero leftover setenv("TZ") lambdas; lukeborgerding
trades byte-identical to baseline.

Requires pineforge-engine with the paired pine_* symbols (merged first).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@luisleo526 luisleo526 merged commit dae26ff into main Jul 7, 2026
1 of 9 checks passed
@luisleo526 luisleo526 deleted the fix/ki35-route-time-builtins-to-engine branch July 7, 2026 04:51
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