8000 On WASI, time.process_time is not in seconds · Issue #115714 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

On WASI, time.process_time is not in seconds #115714

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

Closed
encukou opened this issue Feb 20, 2024 · 5 comments
Closed

On WASI, time.process_time is not in seconds #115714

encukou opened this issue Feb 20, 2024 · 5 comments
Assignees
Labels
OS-wasi type-bug An unexpected behavior, bug, or error

Comments

@encukou
Copy link
Member
encukou commented Feb 20, 2024

In a fresh WASI build, time.process_time, which should be in seconds, counts 10⁶ times faster than time.time:

>>> import time
>>> time.time(); time.process_time()
1708435312.596558
4775079350.12
>>> time.time(); time.process_time()
1708435313.0949461
4780063256.54
>>> time.get_clock_info('process_time')
namespace(implementation='clock_gettime(CLOCK_PROCESS_CPUTIME_ID)', monotonic=True, adjustable=False, resolution=1e-09)

It looks like WASI might remove CLOCK_PROCESS_CPUTIME_ID. Should we wait for that? Remove it from Python sooner? Work around the issue?

(Codespaces has an “unexpected error” for me right now, so I built the container from .devcontainer/Dockerfile directly. Hope that doesn't affect the result.)

Linked PRs

@encukou
Copy link
Member Author
encukou commented Feb 20, 2024

@brettcannon, your thoughts on this?

@brettcannon
Copy link
Member

We should just remove it.

@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label Feb 20, 2024
@brettcannon
Copy link
Member

I built the container from .devcontainer/Dockerfile directly. Hope that doesn't affect the result.

It shouldn't. All Codespaces does on top of that container is inject a git checkout and configures VS Code automatically.

@encukou encukou self-assigned this Feb 21, 2024
@encukou
Copy link
Member Author
encukou commented Feb 21, 2024

It turns out the return value of sysconf(_SC_CLK_TCK) (number of clock ticks per second) is incorrect, at least for scaling times from CLOCK_PROCESS_CPUTIME_ID and times().

I'll prepare a PR that avoids calling them in time.

@brettcannon
Copy link
Member

Thanks!

woodruffw pushed a commit to woodruffw-forks/cpython that referenced this issue Mar 4, 2024
…SI (pythonGH-115757)

* pythongh-115714: Don't use CLOCK_PROCESS_CPUTIME_ID and times() on WASI

* Add blurb
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…SI (pythonGH-115757)

* pythongh-115714: Don't use CLOCK_PROCESS_CPUTIME_ID and times() on WASI

* Add blurb
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this issue Jan 22, 2025
…SI (pythonGH-115757)

* pythongh-115714: Don't use CLOCK_PROCESS_CPUTIME_ID and times() on WASI

* Add blurb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-wasi type-bug An unexpected behavior, bug, or error
Projects
Archived in project
Development

No branches or pull requests

2 participants
0