-
Notifications
You must be signed in to change notification settings - Fork 2
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
FR (Performance): Refactor and replace TempPath with a native cache path #49
Comments
Prior Code: https://github.com/pwsh-cs-tools/core/tree/v0.5.4-beta TempPath generation:Import-Package.psm1:Module Initialization Garbage Collector (called once per PowerShell session):
Import-Package FunctionParameters block
TempPath path-string and mutex-lock generation
Runtime Garbage Collector (called on every Import-Package call)
The function also makes calls to $Bootstrapper.LoadNative() which actually handles the resource copying. Use Ctrl+Shift+F in VS Code and See below |
+1, sharing the temp path causes errors if two packages contain the same file eg large depencency trees like |
That's something else I will have to look at. The problem with native files, is that NuGet doesn't define how C# is supposed to load them, just that they are associated with the wrapping package. |
I really liked how temppath gen worked in my script. I put a lot of work and thought into it. Using cross-process mutex-locks for garbage collection was definitely one of my best pieces of work, considering the size of the gc code. I am sad to see it go, but it definitely needs to happen. I wrote a .psm1 gist that separates my temppath creation and gc in case I want to use it in a different module later: |
What error are you getting? I'm getting PackageManagement/Install-Package errors.
Opened a OneGet issue for my problem |
Another problem I am going to have to tackle is caching of dependency native dlls. How TempPath works right nowThe purpose of the TempPath was to provide each of the NuGet libraries a central place to deposit their native files. A lot of native files require that their dependencies be in the same root directory (this is a widely adopted practice in native C-based langs) So switching from a TempPath to a native cache may introduce a new and different file bloat problem. The Problem with The Solution:Each dependency in the dependency tree with native files would need to have its own implementation of the new TempPath. This would be a blessing and a problem.
Possible Solution:So what I'm thinking I do is:
|
Introduced the FullName field on the PackageData object generated by Build-PackageData This uses the LeafBase of the package's Source property. This should cover these cases:
This will not cover these 2 cases:
|
Holy moly! The last change has been implemented and the load performance from caching the native files is insane. Loading Avalonia.Desktop and Microsoft.ClearScript has been brought down from around 10-13 seconds to 2 and a half seconds according to the test script |
@pl4nty see #50, #51, and the OneGet Issue |
Thanks, you're right it's in OneGet. For now I'm loading the conflicting packages separately. The load time improvements are very noticeable by the way, well done! |
Also just introduced a -SkipDependencies switch with v0.6.1, so you can load each library (similarly to -Path), without having to separately download the library.
|
Thanks, much appreciated. For this bug I can just load the conflicting package first, but for others I've had to resort to |
btw - I used your package to port .NET OpenTelemetry to PowerShell! it was really useful for testing, and figuring out how to call C# extension methods |
It looks like for that problem, you could likely use a newer version of the package. Import-Package's version handling for NuGet version ranges is limited. It currently can't handle unbounded version ranges very well (which is likely why Import-Package is trying to use such an old version of that package). I'm working on that problem with #50 |
btw I started the repo split for New-ThreadController and Import-Package, since issues like #50 require a complete refactor: Once I can get a release published from the new repo, I will archive this one. The refactor is mostly targeted at the $bootstrapper variable which makes up a lot of Import-Package's underlying code. I've got most of the changes I want implemented done, I just have to port the rest of the code to the new $bootstrapper. |
As discussed in #46, deprecating the TempPath may be warranted.
There are 4 approaches considered to this problem:
Probably going to resort to the latter.
EDIT: Currently planned solution:
- #49 (comment)
The text was updated successfully, but these errors were encountered: