Does System.Linq.Enumerable.Iterator<T>
still need _threadId
and .Clone()
?
#88001
Replies: 3 comments 1 reply
-
Linking issue you alluded to |
Beta Was this translation helpful? Give feedback.
-
Streamlining in general, sure. Removing this check, I don't think so. It could alternatively be an Interlocked.Exchange, but if memory serves it was explicitly changed away from that for perf reasons. While it may not be documented to be thread-safe, I expect too much code depends on it being so to warrant changing it, especially since if you're using the iterator types that derive from Iterator, you're already leaving some perf on the table vs just open-coding loops. What is the "overhead" you're referring to, other than the two calls to Environment.GetCurrentManagedThreadId? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
When looking at codegen emitted for LINQ iterator types, it appears that
protected Iterator()
.ctor andabstract Clone()
add overhead (hurts much more on NativeAOT, where in JIT DynamicPGO helps out quite a bit).Given the existing discussion on e.g. potentially eliding version checks in List and similar patterns in
Release
builds, I would like to ask if streamlining LINQ internals would be on the table too, since the expectation forIEnumerabe<T>
-returned types to be not thread-safe.Beta Was this translation helpful? Give feedback.
All reactions