Skip to content

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

Description

@encukou

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

Activity

  1. encukou commented on Feb 20, 2024

    @encukou
    MemberAuthor

    @brettcannon, your thoughts on this?

  2. brettcannon commented on Feb 20, 2024

    @brettcannon
    Member

    We should just remove it.

  3. brettcannon commented on Feb 20, 2024

    @brettcannon
    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.

  4. self-assigned this
    on Feb 21, 2024
  5. encukou commented on Feb 21, 2024

    @encukou
    MemberAuthor

    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.

  6. added 2 commits that reference this issue on Feb 21, 2024
  7. brettcannon commented on Feb 22, 2024

    @brettcannon
    Member

    Thanks!

  8. added a commit that references this issue on Mar 4, 2024
  9. added a commit that references this issue on Apr 17, 2024
  10. added a commit that references this issue on Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

OS-wasitype-bugAn unexpected behavior, bug, or error

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions