Skip to content
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

Add APIs for some threading metrics #35500

Open
kouvel opened this Issue Feb 21, 2019 · 7 comments

Comments

Projects
None yet
4 participants
@kouvel
Copy link
Member

commented Feb 21, 2019

From dotnet/coreclr#20372

    public static class ThreadPool
    {
        public static long CompletedWorkItemCount { get; }
        public static long PendingLocalWorkItemCount { get; }
        public static long PendingGlobalWorkItemCount { get; }
        public static long PendingWorkItemCount { get; }
        public static int ThreadCount { get; }
    }

    public static class Monitor
    {
        public static long LockContentionCount { get; }
    }
  • ThreadPool.CompletedWorkItemCount
    • Gets the number of work items that have been processed so far
    • For a thread pool implementation that may have different types of work items, the count includes all types (user work items including tasks, timer callbacks, wait callbacks, and IO completions)
    • Changes over units of time would be plottable and would allow calculating throughput and average work item duration
    • There is some overhead in tracking this information, but it seems to be negligible
  • ThreadPool.PendingLocalWorkItemCount
    • Gets the number of local work items that are currently queued to be processed
    • Local work items are work items queued in some fashion that has association with a particular thread or its execution environment, and are typically processed in last-in-first-out order. They may include tasks and work items queued with QueueUserWorkItem(..., preferLocal: true).
  • ThreadPool.PendingGlobalWorkItemCount
    • Gets the number of global work items that are currently queued to be processed
    • Global work items are shared by all thread pool worker threads and are typically processed in first-in-first-out order. See PendingWorkItemCount for other relevant remarks.
  • ThreadPool.PendingWorkItemCount
    • Gets the number of work items that are currently queued to be processed
    • For a thread pool implementation that may have different types of work items, the count may not include all types. The count may only include user work items including tasks. Some implementations may also include queued timer and wait callbacks in the count. On Windows, the count is unlikely to include the number of pending IO completions, as they get posted directly to an IO completion port.
  • ThreadPool.ThreadCount
    • Gets the number of thread pool threads that currently exist
    • For a thread pool implementation that may have different types of threads, the count includes all types
  • Monitor.LockContentionCount
    • Gets the number of times there was contention upon trying to take a Monitor's lock so far
    • Changes over units of time would be plottable and would allow calculating frequency of contention

CC @noahfalk @stephentoub @sywhang @vancem

@kouvel kouvel added this to the 3.0 milestone Feb 21, 2019

@kouvel kouvel self-assigned this Feb 21, 2019

kouvel added a commit to kouvel/coreclr that referenced this issue Feb 21, 2019

kouvel added a commit to kouvel/corert that referenced this issue Feb 21, 2019

Implement APIs for some threading metrics (CoreRT), fix `Timer` on Un…
…ixes

- API review: dotnet/corefx#35500
- May depend on dotnet/coreclr#22754
- Fixed `Timer` implementation on Unixes. Previously there was only ever one timer request from the upper-level implementation and that is not the case anymore, so the lower-level "app domain timer" implementation needed to handle multiple timer requests.

kouvel added a commit to kouvel/corefx that referenced this issue Feb 21, 2019

kouvel added a commit to kouvel/corert that referenced this issue Feb 21, 2019

Implement APIs for some threading metrics (CoreRT), fix `Timer` on Un…
…ixes

- API review: dotnet/corefx#35500
- May depend on dotnet/coreclr#22754
- Fixed `Timer` implementation on Unixes. Previously there was only ever one timer request from the upper-level implementation and that is not the case anymore, so the lower-level "app domain timer" implementation needed to handle multiple timer requests.
@danmosemsft

This comment has been minimized.

Copy link
Member

commented Feb 22, 2019

Since area owner is proposing this, I guess it is ready for review.

@kouvel

This comment has been minimized.

Copy link
Member Author

commented Feb 22, 2019

I think we have already discussed most of the things on the other issue, but if anyone has any suggestions on naming or behavior, please let me know.

kouvel added a commit to kouvel/corert that referenced this issue Feb 22, 2019

@kouvel

This comment has been minimized.

Copy link
Member Author

commented Feb 23, 2019

There is also this related request: #34277. Perhaps we could also add properties like PendingLocalWorkItemCount and PendingGlobalWorkItemCount in addition. In CoreCLR the global one can include work items from the unmanaged side. As for "local"/"global", that distinction in naming and behavior is already there in a QueueUserWorkItem overload. The total is probably also good to have.

kouvel added a commit to kouvel/coreclr that referenced this issue Mar 6, 2019

kouvel added a commit to kouvel/corert that referenced this issue Mar 6, 2019

kouvel added a commit to kouvel/corefx that referenced this issue Mar 6, 2019

kouvel added a commit to kouvel/coreclr that referenced this issue Mar 6, 2019

kouvel added a commit to kouvel/corert that referenced this issue Mar 6, 2019

@kouvel

This comment has been minimized.

Copy link
Member Author

commented Mar 6, 2019

Updated proposal inline to include PendingLocalWorkItemCount and PendingGlobalWorkItemCount

@kouvel

This comment has been minimized.

Copy link
Member Author

commented Mar 18, 2019

@terrajobst, would it be possible to review this soon? The work to expose these is currently targeted for 3.0 and there is other 3.0 work to expose event counters that depends on this.

@ghuntley

This comment has been minimized.

Copy link
Member

commented Mar 19, 2019

@terrajobst

This comment has been minimized.

Copy link
Member

commented Mar 19, 2019

Looks good.

The only concern is about local vs. global. Unless there is a specific scenario needing the differentiation. If there isn't we should just expose the total.

kouvel added a commit to kouvel/coreclr that referenced this issue Apr 2, 2019

kouvel added a commit to kouvel/corert that referenced this issue Apr 2, 2019

kouvel added a commit to kouvel/corefx that referenced this issue Apr 2, 2019

kouvel added a commit to kouvel/coreclr that referenced this issue Apr 2, 2019

@noahfalk noahfalk referenced this issue Apr 19, 2019

Open

Add Runtime Performance Counters #20372

7 of 19 tasks complete

kouvel added a commit to kouvel/coreclr that referenced this issue Apr 19, 2019

kouvel added a commit to dotnet/coreclr that referenced this issue Apr 20, 2019

Implement APIs for some threading metrics (CoreCLR) (#24113)
Implement APIs for some threading metrics (CoreCLR)

API review: dotnet/corefx#35500

Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this issue Apr 22, 2019

Implement APIs for some threading metrics (CoreCLR) (dotnet/coreclr#2…
…4113)

Implement APIs for some threading metrics (CoreCLR)

API review: dotnet/corefx#35500

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>

Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this issue Apr 22, 2019

Implement APIs for some threading metrics (CoreCLR) (dotnet/coreclr#2…
…4113)

Implement APIs for some threading metrics (CoreCLR)

API review: dotnet/corefx#35500

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>

kouvel added a commit to kouvel/corefx that referenced this issue Apr 22, 2019

jkotas added a commit to dotnet/corert that referenced this issue Apr 22, 2019

Implement APIs for some threading metrics (CoreCLR) (dotnet/coreclr#2…
…4113)

Implement APIs for some threading metrics (CoreCLR)

API review: dotnet/corefx#35500

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>

kouvel added a commit to kouvel/corert that referenced this issue Apr 23, 2019

jkotas added a commit to dotnet/corert that referenced this issue Apr 23, 2019

Implement APIs for some threading metrics (CoreRT) (#7066)
* Implement APIs for some threading metrics (CoreRT)

- API review: dotnet/corefx#35500
- May depend on dotnet/coreclr#22754

* Use thread-locals for counting, use finalizer instead of runtime to detect thread exit

* Don't let the count properties throw OOM

* Remove some flushes

Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/coreclr that referenced this issue Apr 23, 2019

Implement APIs for some threading metrics (CoreRT) (dotnet/corert#7066)
* Implement APIs for some threading metrics (CoreRT)

- API review: dotnet/corefx#35500
- May depend on dotnet#22754

* Use thread-locals for counting, use finalizer instead of runtime to detect thread exit

* Don't let the count properties throw OOM

* Remove some flushes

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>

Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this issue Apr 23, 2019

Implement APIs for some threading metrics (CoreRT) (dotnet/corert#7066)
* Implement APIs for some threading metrics (CoreRT)

- API review: dotnet#35500
- May depend on dotnet/coreclr#22754

* Use thread-locals for counting, use finalizer instead of runtime to detect thread exit

* Don't let the count properties throw OOM

* Remove some flushes

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>

stephentoub added a commit that referenced this issue Apr 23, 2019

Implement APIs for some threading metrics (CoreRT) (dotnet/corert#7066)
* Implement APIs for some threading metrics (CoreRT)

- API review: #35500
- May depend on dotnet/coreclr#22754

* Use thread-locals for counting, use finalizer instead of runtime to detect thread exit

* Don't let the count properties throw OOM

* Remove some flushes

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>

jkotas added a commit to dotnet/coreclr that referenced this issue Apr 23, 2019

Implement APIs for some threading metrics (CoreRT) (dotnet/corert#7066)
* Implement APIs for some threading metrics (CoreRT)

- API review: dotnet/corefx#35500
- May depend on #22754

* Use thread-locals for counting, use finalizer instead of runtime to detect thread exit

* Don't let the count properties throw OOM

* Remove some flushes

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.