fix(codegen): route hour()/minute()/... to engine pine_* helpers (KI-35)#42
Merged
Merged
Conversation
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>
This was referenced Jul 7, 2026
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.
Problem (KI-35)
The time/date builtins (
hour,minute,second,dayofmonth,dayofweek,month,year,weekofyear) were emitted as an inlinesetenv("TZ")+tzset()+localtime_rlambda evaluated once per bar. On macOS thattzset()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:BAR_BUILTINSintables.py), andvisit_call.py).Value-identical: same
tmfields and Pine offsets (dayofweek=tm_wday+1,month=tm_mon+1,year+1900), DST-exact — the engine applies the offsets internally, sofield_expris dropped in the call form.setenv("TZ")lambdas.Dependency
Requires
pineforge-enginewith the pairedpine_*symbols — merged first (pineforge-engine#70).🤖 Generated with Claude Code