Add %jinx hint to Vere.#648
Conversation
|
May want to improve the error message to provide guidance on why the crash takes place. |
| 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.
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.
Urbit time is bigger than that, though, so the u3r_safe_chub always fails.
There was a problem hiding this comment.
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 |
Implements [UIP-0124](https://github.com/urbit/UIPs/blob/main/UIPS/UIP-0124.md), replaces #648, supersedes #894. Moves Urbit time functions to `manage.c` and defines a per-road stack of absolute deadlines. Virtual timer is set or disarmed any time a new deadline is pushed onto the stack, popped off the stack or if a road is left with some deadlines on its stack. Defines a dynamic hint `%jinx`. If the product of the hint-formula is 0 or a cell, nothing happens, otherwise new deadline is pushed before the hinted formula is executed and popped once it is executed. #### Questions I had to mess with `noun/build.zig` and `jets/e/json_en.c` to make Windows build work, otherwise I was getting build errors. Why was that happening? Was there another, saner way to fix that? #### Warnings When playing around in a fakeship's dojo I saw a leak report once when I ran `|mass`. I then tried to reproduce it, including with `-Dmem-dbg` option and `-g` flag, to no avail.
|
Superseded by #910 |
Resolves proposed UIP (unnumbered).
Adds a
%jinxhint to Vere which permits a computation's timeout to be specified in Urbit time.