-
Notifications
You must be signed in to change notification settings - Fork 872
Support for pg_service.conf #4962
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
base: main
Are you sure you want to change the base?
Conversation
445bfdf to
21e195f
Compare
src/Npgsql/PostgresEnvironment.cs
Outdated
|
|
||
| static string? GetDefaultSystemPostgresDir() => ExecuteCommandSync("pg_config", "--sysconfdir"); | ||
|
|
||
| static string? ExecuteCommandSync(string command, string arguments) |
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.
Since this already contains 'Sync' and uses APIs that can block I guess that you also plan an Async variant (also for GetConfigFromIniFile()) - no?
The internal part could use a boolean async flag like we do it all the time in Npgsql (e. g. see KerberosUsernameProvider for how to do this for Process)
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.
Done.
I have shared the code between both usages.
4a98532 to
5492bb9
Compare
|
The CI checks seem blocked in an infinite wait, even after a new commit on the PR branch... |
It's probably because of merge conflict. |
61ddce6 to
0607b3e
Compare
Yes, my local git repo was corrupted, so I was not able to pull from upstream and so see the conflict... |
|
@manandre Great, I'll take a look tomorrow. |
| UseShellExecute = false | ||
| }; | ||
| return includeRealm ? _principalWithRealm : _principalWithoutRealm; | ||
|
|
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.
Maybe leave the part above here as sync function and move the part below to a local async function (as it was before).
That way access to the cached values works without async state machine.
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.
Fixed.
vonzshik
left a comment
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.
Looks quite good.
@roji whenever you have a time.
6c78361 to
4b6a2a4
Compare
|
@roji Can you please tell me whether something prevents this PR from being merged? |
4b6a2a4 to
adafb88
Compare
|
@NinoFloris to verify that there are no size regressions for NativeAOT. |
NinoFloris
left a comment
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.
Unfortunately we're pulling in FileStream again with this PR.
Could you copy the workaround from #5234 to break the internal dependency on FileStream that the convenience File apis like File.ReadAllLines have? (FileStream itself references System.Uri again and so on. It's quite wasteful)
You know it's gone by looking at the NativeAOT github action summary and opening our Size by Namespace panel. System.IO should be around 30kb.
Alternatively you can use sizoscope https://github.com/MichalStrehovsky/sizoscope and load in the mstat file attached to the action run.
I'd be happy to help if you run into any issues.
adafb88 to
2c3f2fe
Compare
|
@NinoFloris I have applied the same workaround, please tell me whether it solves the issue here. I am not sure how to read the sizoscopeX output... |
|
@manandre to get the dependency analysis going you should also download the npgsql.scan.dgml.xml. Then in sizoscope -> open you select both the mstat and the xml. Once you're in double clicking a type should pop up another window allowing you to traverse to roots keeping the type alive. If you want to know what this PR added compared to baseline you can take an mstat & .xml from an actions run on main, then in sizoscope(X) load it via the tools -> diff option in the menu. In either case I took a look and it seems we're now always rooting System.Diagnostics.Process, which itself brings in a lot, including filestream it seems. This PR is adding about 400kb to the minimal binary just to read Would we be able to get that info some other way, or be able to make reading it via pg_config optional? |
|
@NinoFloris Thanks for the tutorial ;) |
|
We're only conditionally referencing it via this mechanism
So as long as a project using the NpgsqlSlimDataSourceBuilder doesn't call EnableIntegratedSecurity() we don't reference the code that ends up using Process. |
|
Oh! I was not aware that NativeAOT is able to optimize such paths. |
|
So the idea is that the NativeAOT scanner figures out whether these derived types are actually constructed. As long as there is no reachable path to a concrete constructor call of the derived type it can trim its code and its dependencies as well.
These things can only be reasoned about at runtime, at which point the code has to be included, just in case. |
|
We're aiming to release Npgsql and EFCore.Pg tomorrow so I'm going to move it out to 9.0. We'll have a bit more time to think about workarounds. Though I hope we see more size improvements in .NET 9.0, ideally when System.Diagnostics.Process is pulled in as well (at least we'll have time to raise the issue as well). |
Closes #4950