Post AP8C5lL4Li9OODh4CG by jyasskin@mastodon.social
 (DIR) More posts by jyasskin@mastodon.social
 (DIR) Post #AP8C5lL4Li9OODh4CG by jyasskin@mastodon.social
       2022-10-29T17:41:24Z
       
       0 likes, 0 repeats
       
       Over the last week, I proposed a more formal way to describe #time in #WebStandards. I started with https://github.com/whatwg/infra/pull/491, proposing the simplest thing that could possibly work: points in time and lengths of time, borrowing terms from the JS Temporal library: Instants and Durations.The reviewers argued that we should have specs be consistent with the mechanisms in https://w3c.github.io/hr-time/... 1/7
       
 (DIR) Post #AP8C5lkEq8HdeHTAQa by jyasskin@mastodon.social
       2022-10-29T17:41:56Z
       
       0 likes, 0 repeats
       
       https://w3c.github.io/hr-time/ currently expresses time in ms-since-something-vague-but-the-Unix-epoch-in-practice or ms-since-navigation-start, both sharing a type of DOMHighResTimeStamp with other durations. Its algorithms for other specs to use are also confusing, reflecting the fact that it grew over time. E.g. the "current high resolution time" is ms-since-navigation-start, but the "shared current time" is ms-since-the-epoch. (They have the same resolution.) 2/7
       
 (DIR) Post #AP8C5mEj0mfbApjVwm by jyasskin@mastodon.social
       2022-10-29T17:42:17Z
       
       0 likes, 0 repeats
       
       So I rewrote the system by simplifying some lessons I learned discussing the C++ <chrono> library. I suggest we have 2 "clocks" on the web platform: the wall clock, which is what Date uses to match human time, and the monotonic clock, which is what performance measurement and some other uses need to ignore users resetting their clocks and time slew from NTP and leap seconds. 3/7
       
 (DIR) Post #AP8C5mh5JLM4an0A9Q by jyasskin@mastodon.social
       2022-10-29T17:42:42Z
       
       0 likes, 0 repeats
       
       Both clocks have their own kind of instant, which has been renamed to "moment" to make a reviewer happy. These can be unsafe and precise or safe-for-#Spectre and coarse. Durations are shared and always coarse, which makes it possible to approximately transfer moments from one clock to another. 4/7
       
 (DIR) Post #AP8C5n9Rbu2Y0kGoM4 by jyasskin@mastodon.social
       2022-10-29T17:42:58Z
       
       0 likes, 0 repeats
       
       Specs have 3 ways to create times: the "current wall time", the "current monotonic time", and the "current relative timestamp". That last is the way to get at the common ms-since-navigation-start measurement that's directly useful to Javascript. The others have to be explicitly converted to a duration (or Date for wall times) before they're given to JS. Check out the full proposal at https://github.com/w3c/hr-time/pull/140. 5/7
       
 (DIR) Post #AP8C5nb5x69rOVCtSC by ondra@social.unextro.net
       2022-10-31T15:58:23Z
       
       0 likes, 0 repeats
       
       @jyasskin What if I comment on a post of a moved account?
       
 (DIR) Post #AP8C5wCbxUvA5Aoy2a by jyasskin@mastodon.social
       2022-10-29T17:43:25Z
       
       0 likes, 0 repeats
       
       This intentionally ignores wall time details like UTC vs UT1–4 vs TAI and the treatment of leap seconds. It also doesn't yet fix problems with the monotonic clock around how it's affected by time slew and system sleep. We'll also have to rethink it once travel at relativistic speeds becomes common or if our #Spectre mitigations ever get good enough to allow resolutions fine enough to notice that a single computer's CPUs can have different speed clocks. 6/7
       
 (DIR) Post #AP8C5xnW1m2F1v5xCa by jyasskin@mastodon.social
       2022-10-29T17:43:39Z
       
       0 likes, 0 repeats
       
       Let me know what you think, and remember to #TipYourServer. (https://patreon.com/mastodon for mine) 7/7