rust-lang / rust-lang/libs-team

Feature: A separate type for measuring thread time in std::time module

Open
#345 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
178
Forks
28
Avg merge
15m
Merged PRs (30d)
1

Description

Had this thought regarding if we can infer the time it takes for object to be executed in a given OS thread context, instead of relying on the std::time::Instant to obtain the time elapsed which won't take into account things such as context switch etc etc, therefore I would like to propose a thought ThreadTime a type which may keep track of the time spent by itself on a given thread context excluding all the context switching mechanism..

internally it may look like so

pub struct ThreadTime { 
    duration: ThreadDuration, 
    thread: SomeThreadTypeRecorder
}

through this we can avoid using ThreadLocal<T> types directly which may wrap duration between itself, and then maybe we continue the computation, this can be especially useful if you wish to use it in the some struct where you wish to track time in precision.
and should have !Sync enabled, let me know is it a useful idea ?

Iam not sure though whether this can be made platform agnostic ? and also O.S agnostic too.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by reviewing the existing std::time::Instant and thread-local timing facilities, then investigate whether per-thread CPU time can be exposed across supported operating systems. Done would require an agreed, platform-agnostic API design and a decision on its thread-safety and portability.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.