-
Notifications
You must be signed in to change notification settings - Fork 193
Make IFeatureCollection have generic<T> accessor #522
Comments
Also the runtime As its 84% of "own time" cost of the Get call on FeatureCollection is only this line
Which would become no cast or runtime |
+1 for education, convenience, and extending GOOD patterns and practices. |
Updated results and methods https://gist.github.com/benaadams/c6c109982f50c6f69af2#gistcomment-1657847
|
Actually, might be able to work round this with |
@benaadams So where did you land on this? If we we change
Will the JIT compiler perform branch elimination despite |
Still working on it; the jit does do the branch elimination if the method is extracted locally rather than a call (i.e. inlined) regardless of them being reference types. However; it won't inline via an interface. Nor will it inline a virtual method (so subclassing won't work either). Can't use a value type with a generic as it makes the value type bit concrete and leaves the generic bit shared. Will add going via an interface to the tests and see if generics are still faster. Also have an idea on how to get the branch elimination working still; but it would mean creating a specific valuetype wrapper for each "named" feature. |
The changed interface implementation of FeatureCollection seems to cause the Jit to change inlining, and no longer inline the agressive inline method :-/
Fastest now being Generic's via the interface without extension (IGetGenericCast) are 13.5% faster. Wrapping in a non-generic struct via interface is 222.1% faster; think can get there via the generic interface method. |
Hmm... no, as you'd need to lookup the concrete struct to use, which would put you back in the original situation :-/ Though using a GenericStruct as implementation in |
Rather than have it as an Extension; so the type of checks in
Frame.FastFeatureGet(Type key)
becomestypeof
checks ofT
inFrame.FastFeatureGet<T>()
At that point they also become compile time constants meaning 90% of the time the entire method will be Jitted away - as per the
typeof
checks in System.Numerics.VectorsThe text was updated successfully, but these errors were encountered: