nodejs / uvwasi

WASI syscall API built atop libuv
MIT License
225 stars 49 forks source link

Increase precision of clocks in clock_time_get on Windows #182

Closed ospencer closed 1 year ago

ospencer commented 1 year ago

This PR is rebased on #181.

This increases the precision of the UVWASI_CLOCK_PROCESS_CPUTIME_ID and UVWASI_CLOCK_THREAD_CPUTIME_ID clocks on Windows. The raw values from GetProcessTimes and GetThreadTimes are in units of 100 nanoseconds, which matches the reported resolution returned from uvwasi_clock_time_get.

I can't find any documentation on it, but in my testing I only saw an actual precision of about 1000 nanoseconds, which I suppose makes sense if the process/thread times are counted as microseconds.

cjihrig commented 1 year ago

This has a conflict now.

ospencer commented 1 year ago

@cjihrig This should be all set, thanks.

phated commented 1 year ago

@cjihrig Will you be able to cut a release with both these fixes and get them upstreamed into node 19? We're planning to recommend node 19+ WASI support in Grain.

sunfishcode commented 1 year ago

As a heads up here, the process and thread clocks are currently planned to be removed from future versions of WASI, because on implementations where there is not a one-to-one relationship between a wasm instance and a host process, it's prohibitively expensive to implement them. If you have use cases which depend on these clocks, please consider filing an issue in the wasi-clocks repo, where we can discuss how we might accomodate such use cases in a way that all WASI implementations can support.

phated commented 1 year ago

@sunfishcode I don't think we have any direct need for them, but Grain is a WASI-compatible language so we have bindings for all of preview1 and discovered this bug. Updating uvwasi to preview2 is outlined in #59

phated commented 1 year ago

(It also looks like someone needs to kick the CI because it's been running for 3 hours)

cjihrig commented 1 year ago

Regarding the CI - I kicked the CI. It looks like GitHub Actions had some issue earlier on Windows. It looks like everything is fine now.

Regarding the release - yes, I can cut a new release and update Node. It will be released in Node 19 (either the next version or the one after, I'm not sure what the release calendar currently looks like).

Regarding the next WASI snapshot - someone needs to step up and do the work. There is a WIP branch here, but it hasn't been updated since Sept 2020. I'm happy to review code, cut releases, etc. but I no longer work on this project. I'm also happy to give the commit bit to anyone working on the project.

phated commented 1 year ago

Thanks! We didn't know about that. This project is widely used (nodejs, WAMR, Wasm3) so we thought it was actively maintained. I'll try to figure out how we can keep this maintained! Thank you for all your hard work 🙇