-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add %jinx hint to Vere. #648
base: develop
Are you sure you want to change the base?
Conversation
May want to improve the error message to provide guidance on why the crash takes place. |
pkg/noun/nock.c
Outdated
if (c3y == u3a_is_atom(*clu)) { | ||
// clu is in Urbit time, but we need Unix time | ||
mpz_t clu_mp; | ||
u3r_mp(clu_mp, *clu); | ||
mpz_t urs_mp, tim_mp; | ||
mpz_init(urs_mp); | ||
mpz_init(tim_mp); | ||
mpz_tdiv_q_2exp(tim_mp, clu_mp, 48); | ||
mpz_mul_ui(tim_mp, tim_mp, 1000); | ||
mpz_tdiv_q_2exp(urs_mp, tim_mp, 16); | ||
c3_w mil_w = u3i_mp(urs_mp); | ||
u3m_timer_set(mil_w); // set ITIMER (mil_w is in microseconds) | ||
mpz_clear(clu_mp); | ||
mpz_clear(tim_mp); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace this math with u3_time_msc_out(c3_d)
.
c3_d tim_d;
if ( c3y == u3r_safe_chub(*clu, &tim_d) ) {
c3_w mic_w = u3_time_msc_out(tim_d);
c3_w mil_w = mic_w / 1000;
u3m_timer_set(mil_w);
}
(Or you could, if it was defined in pkg/vere
. I'd be inclined to copy it into this file as a static function rather than use gmp.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Urbit time is bigger than that, though, so the u3r_safe_chub
always fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could retrieve two chubs for the time, very unlikely to be too big for that.
notes from discussion today, for posterity:
one to set ITIMER like cm_signal_deep, one to cancel it using zeroed itervaltimerstruct |
Extremely based functionality |
From discussion ~2024.8.12, some thoughts on the interface:
So write a UIP to implement subsecond timing syntax?
|
Probably just stick with |
Ongoing support work for Urbit |
Also urbit/urbit#7067 for the parser. |
Should the nested timer be measured against the nominal outer timer or against the actual time remaining? I'm building the stack handler for the latter case, but worth thinking about. |
:: should fail (timeout)
~> %jinx.[~s0..8000] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i)))))
:: should succeed (normal)
~> %jinx.[~s1] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i)))))
:: should succeed (nested properly)
~> %jinx.[~s2..8000] ~> %jinx.[~s1] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i)))))
:: should fail (nested improperly)
~> %jinx.[~s1..8000] ~> %jinx.[~s5] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i)))))
:: should fail (nested improperly and timeout)
~> %jinx.[~s0..8000] ~> %jinx.[~s1] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i)))))
|
At this point, it would be helpful to have someone else verify the behavior. There seems to be an incorrect fall-through case on Test CasesSince the failure of a :: should fail (timeout)
~> %jinx.[~s1] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i)))))
:: should succeed (normal)
~> %jinx.[~s1] =|(i=@ |-(?:(=(10.000 i) i $(i +(i)))))
:: should succeed (nested properly)
~> %jinx.[~s3..8000] ~> %jinx.[~s3] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i)))))
:: should warn (nested improperly; will succeed on outer hint)
~> %jinx.[~s1..8000] ~> %jinx.[~s5] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i)))))
:: should warn (nested improperly; will timeout on outer hint)
~> %jinx.[~s0..8000] ~> %jinx.[~s1] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i)))))
:: should fail (timeout)
~> %jinx.[~s0] =|(i=@ |-(?:(=(10.000.000 i) i $(i +(i))))) Developer Notes
|
@pkova @mopfel-winrux wants me to bug you on this for 3.2 |
Resolves proposed UIP (unnumbered).
Adds a
%jinx
hint to Vere which permits a computation's timeout to be specified in Urbit time.