-
Notifications
You must be signed in to change notification settings - Fork 545
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
Query compilation performance - Part 2 #971
Conversation
|
||
namespace System.Data.Entity.Utilities | ||
{ | ||
internal class IntegerSwitch : Switch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrfin, @ajcvickers do you know how usable is System.Diagnostics.Switch on .NET Core? From what I remember the last time I used one of these you configured in the app.config, but that isn't operational in .NET Core, so, are there other alternatives?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good point. I used a Switch
because the PlanCompiler
class already uses BooleanSwitch
(see _applyTransformationsRegardlessOfSize
)...
I'll check it and if not working on .NET Core replace all (incl. the "old one") of them and update the pull-request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajcvickers @divega I checked it and Diego is right. Switch
is useless in .NET Core as it is only working in-memory per instance.
Now I'm not sure in which direction I should go:
- Improve the
Switch
-implementation in CoreFX to be usable - Create a new
Switch
-implementation outside of CoreFX based onMicrosoft.Extensions.Configuration
(where could/should that be added? new package?) - Add
Microsoft.Extensions.Configuration
to EF6 and use the new config-system instead of the switches - Implement some global/static settings directly in EF6 changeable via code
What do you think?
The best solution IMO would be using Microsoft.Extensions.Configuration
in the CoreFX-Switch
, but that is not possible AFAIK, or is it somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajcvickers or @bricelam may have good suggestions for this. Just some toughs:
-
We cannot add anything that depends on Microsoft.Extensions.Configuration, because the package targets .NET Standard 2.0, and doesn't support .NET Framework 4.0 and 4.5. Also, EF6's design doesn't define a good place to pass something like a configuration instance.
-
A change to System.Diagnostics.Switch that would require taking a hard dependency on System.Configuration.ConfigurationManager is unlikely to be accepted because System.Diagnostics.Switch is part of the .NET Core shared framework and this doesn't depend on ConfigurationManager by design. We also don't have a mechanism to do this with a soft dependency.
-
Elsewhere we are using AppContext.TryGetSwitch() in particular for quirks you can use to opt out we usually add every time we change a behavior in a patch, but I think unfortunately that API doesn't exist prior to .NET Framework 4.6, so it wouldn't be an option for EF6.
-
All that said, EF6 already depends on System.Configuration.ConfigurationManager and we already have a few places in which we read flags from application settings:
https://github.com/aspnet/EntityFramework6/blob/8d2c24bc00aaa042a1e57eb1070f8ba23448e82a/src/EntityFramework/Core/Objects/ObjectContext.cs#L247
https://github.com/aspnet/EntityFramework6/blob/22a11d132306c257435fa7d6d75a31359cbbd05a/src/EFTools/EntityDesignerVersioningFacade/ReverseEngineerDb/SchemaDiscovery/EntityStoreSchemaGeneratorDatabaseSchemaLoader.cs#L59So I would suggest we go with that.
I am not sure why the code in PlanCompiler uses BooleanSwitch. It is a decision that was made a long time ago when we didn't envision the possibility of running on .NET Core (or we didn't envision .NET Core for that matter 😄), but also it sounds like a setting a user may want to change for non-diagnostic reasons. We could also add an AppSetting option for this one.
@divega @ajcvickers @bricelam I now changed it to use |
@divega May you can take another look? Thanks |
@divega @ajcvickers @bricelam Ping after preview 9 ☺ |
@chrfin sorry for not responding earlier. We looked superficially at the PR and it is looking good, though we may need to do another pass to provide feedback. I just wanted to answer if this will make it into 6.3: at this time in a release (i.e. with no more previews in sight) we tend not to take changes of this nature as a heuristic to avoid introducing regressions in the last minute. Based on this, I would like us to consider this for the next release. |
Thanks for the feedback and I completely understand your reasoning :-) |
@divega Sad to hear, but also understandable. Could you may keep the lowered |
cc @bricelam |
Thanks for the contribution! |
This is an update to #430 with the addition to be able to configure or completely disable the query optimizations as already discussed in the initial pull request.