-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
Parallelize for performance, relationship resolver improvements #3917
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HebaruSan
added
Bug
Something is not working as intended
Enhancement
New features or functionality
GUI
Issues affecting the interactive GUI
Cmdline
Issues affecting the command line
Core (ckan.dll)
Issues affecting the core part of CKAN
Tests
Issues affecting the internal tests
Relationships
Issues affecting depends, recommends, etc.
labels
Sep 29, 2023
HebaruSan
changed the title
Parallize for performance improvements, relationship resolver improvements
Parallelize for performance improvements, relationship resolver improvements
Sep 29, 2023
HebaruSan
changed the title
Parallelize for performance improvements, relationship resolver improvements
Parallelize for performance, relationship resolver improvements
Sep 29, 2023
HebaruSan
force-pushed
the
feature/PLINQ
branch
2 times, most recently
from
September 29, 2023 01:48
a83391f
to
1f67431
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
HebaruSan
force-pushed
the
feature/PLINQ
branch
from
October 3, 2023 22:54
1f67431
to
aa35639
Compare
OK, the recommendations stuff is in pretty good shape now. ✔️ |
HebaruSan
force-pushed
the
feature/PLINQ
branch
from
October 5, 2023 21:53
aa35639
to
57ef6db
Compare
HebaruSan
force-pushed
the
feature/PLINQ
branch
3 times, most recently
from
October 6, 2023 21:17
5af1848
to
dada9f1
Compare
HebaruSan
force-pushed
the
feature/PLINQ
branch
2 times, most recently
from
October 10, 2023 23:30
6a07ffd
to
e64252c
Compare
techman83
approved these changes
Oct 11, 2023
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.
I've given it a read over, nothing stands out across the change sets. I did make one comment, but I'll leave that up to your judgement @HebaruSan
Really cool set of work, and can see a bunch of tests included 👏
HebaruSan
force-pushed
the
feature/PLINQ
branch
from
October 11, 2023 12:09
e64252c
to
4c10b68
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug
Something is not working as intended
Cmdline
Issues affecting the command line
Core (ckan.dll)
Issues affecting the core part of CKAN
Enhancement
New features or functionality
GUI
Issues affecting the interactive GUI
Relationships
Issues affecting depends, recommends, etc.
Tests
Issues affecting the internal tests
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Somehow I found the documentation for Parallel LINQ and got excited:
Parallel processing is powerful but tricky, so it is nice to have a framework that takes care of the difficult parts for you. Some of the slower parts of CKAN happen to be what that documentation calls "delightfully parallel", so a survey of opportunities to apply PLINQ is in order.
Problems
While working on this, I found several issues:
identifier=version
syntax for specifying , but even though neither ConsoleUI nor GUI nor NetKAN uses it, it's implemented in Core. This really belongs in CmdLine.InconsistentKraken
uses a property calledInconsistenciesPretty
to return a text description of the problems it represents, meanwhile not even setting theException.Message
property at all even though it serves the same purpose. When standard mechanisms likeException.Message
are available, we should use them rather than creating something redundant.RelationshipResolver.ConflictList
included key-value pairs with the value set to null, which meant that when we tried to use it to generate a description of the conflicts, we got a spurious conflict with "an unmanaged DLL or DLC"GUIMod
is missing and theHideEpochs
setting is passed in theincompatible
parameter.suppress_recommendations
metadata property doesn't do anything for CmdLine. Arguably it should, especially given its behavior of automatically pulling in all recommendations by default.ListView
for every row added while loading, running and re-running its conflicts check, which can take a long time for a large changeset. A similar problem happens when you click the checkbox at the lower-left; checkboxes are changed one by one, and conflicts are re-checked after every such change.Changes
Each change is nicely split up into its own independent commit, which compiles and passes all tests.
Logging.WithTimeElapsed
is now a warpper aroundSystem.Diagnostics.Stopwatch
for easily printing how long a particular piece of code takes to run. This was used to measure all parallelization changes to confirm that they improved performance.(The first thing I tried to parallelize was the test from Add test to check GUI thread safety #3914, which consistently ran slower instead. Figuring out the reasons for that was very helpful in getting familiar with PLINQ.)
Dictionary<string, T>
objects inRegistry
andRepositoryData
is parallelized by a newJsonParallelDictionaryConverter
. The actual loading from the file has to be done sequentially because of how disks work, but if we take aJObject
as the output of that, we can turn the values of its properties intoAvailableModule
orInstalledModule
objects in parallel. Preserving the progress bar updates during loading was tricky, but I ended up using a newWithProgress
function to inject that capability into the PLINQ pipeline, and treating theJObject
step and the parallelized step as about 50% each seemed to give the smoothest continuity.CompatibilitySorter
now performs its compatible-providers search, initial simple compatibility checks, and dependency checks in parallel.GUIMod
objects from repo/registry data is now done in parallelGUIMod
objects is now done in parallel.Visible
property of) grid rows is now done in parallel.tar.gz
files is also now parallelized. Again the file contents have to be loaded sequentially, but once that's done, we hand off to multiple threads to turn them intoCkanModule
objects.identifier=syntax
is moved from Core to CmdLine. This relieves Core from the burden of providing it, and makes it easier to understand in the context where it applies. A test for the old code is removed, and tests for the new code are added.InconsistentKraken.InconsistenciesPretty
is replaced byException.Message
.RelationshipResolver.ConflictList
returns the user's choices as the keys of its pairs, so every mod that has a conflict or a conflicting dependency will be highlighted.RelationshipResolver.ConflictDescriptions
is added to give a full, readable description of the conflicts.(needed for: ModZ 1.1)
appended to it so the user can understand which mods brought the conflict into the changeset.suppress_recommendations
set to true in the metadata will also have their recommendations and suggestions skipped when installing viackan install modname
.