Skip to content
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

FEAT: Parallelize the creation and addition of builders to the Pipeline. #160

Draft
wants to merge 5 commits into
base: version/4.5
Choose a base branch
from

Conversation

Jamesr51d
Copy link
Contributor

No description provided.

Copy link

Unit Tests - Ubuntu_AnyCPU_Debug

 10 files  ± 0   10 suites  ±0   1m 29s ⏱️ -8s
615 tests +10  608 ✅ +3  0 💤 ±0  7 ❌ +7 
628 runs  +10  621 ✅ +3  0 💤 ±0  7 ❌ +7 

For more details on these failures, see this check.

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

This pull request removes 8 and adds 16 tests. Note that renamed tests count towards both.
,APV_JavaScript)
,APV_List)
,APV_String)
,JavaScript)
,List)
,String)
FiftyOne.Pipeline.JsonBuilderElementTests.JsonBuilderElementTests ‑ JsonBuilder_Serialization_Text (
carriage return and new line  
FiftyOne.Pipeline.CloudRequestEngine.Tests.CloudRequestEngineTests ‑ ValidateErrorHandling_RetryAfterNotJson_AfterRecovery
FiftyOne.Pipeline.CloudRequestEngine.Tests.CloudRequestEngineTests ‑ ValidateErrorHandling_RetryAfterNotJson_RetryWhileRecovering
FiftyOne.Pipeline.CloudRequestEngine.Tests.CloudRequestEngineTests ‑ ValidateErrorHandling_RetryAfterNotJson_WithinRecovery
FiftyOne.Pipeline.CloudRequestEngine.Tests.RecoveryStrategyTests ‑ InstantRecoveryStrategyShouldReturnTrue
FiftyOne.Pipeline.CloudRequestEngine.Tests.RecoveryStrategyTests ‑ InstantRecoveryStrategyShouldReturnTrueAfterFailure
FiftyOne.Pipeline.CloudRequestEngine.Tests.RecoveryStrategyTests ‑ NoRecoveryStrategyShouldReturnTrue
FiftyOne.Pipeline.CloudRequestEngine.Tests.RecoveryStrategyTests ‑ NoRecoveryStrategyShouldReturnTrueAfterFailure
FiftyOne.Pipeline.CloudRequestEngine.Tests.RecoveryStrategyTests ‑ SimpleRecoveryStrategyShouldReturnFalseAfterFailure
FiftyOne.Pipeline.CloudRequestEngine.Tests.RecoveryStrategyTests ‑ SimpleRecoveryStrategyShouldReturnTrue
FiftyOne.Pipeline.CloudRequestEngine.Tests.RecoveryStrategyTests ‑ SimpleRecoveryStrategyShouldReturnTrueAfterRecovery
…

Copy link

Integration Tests - Ubuntu_AnyCPU_Debug

0 tests   - 5   0 ✅  - 5   0s ⏱️ ±0s
0 suites  - 2   0 💤 ±0 
0 files    - 2   0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Unit Tests - macos_AnyCPU_Debug

52 tests   52 ✅  2m 3s ⏱️
 1 suites   0 💤
 1 files     0 ❌

Results for commit a997fb4.

Copy link

Unit Tests - Windows_AnyCPU_Core_Release

0 files   -  10  0 suites   - 10   0s ⏱️ - 4m 52s
0 tests  - 605  0 ✅  - 605  0 💤 ±0  0 ❌ ±0 
0 runs   - 618  0 ✅  - 618  0 💤 ±0  0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Unit Tests - Windows_AnyCPU_Core_Debug

0 files   -  10  0 suites   - 10   0s ⏱️ - 5m 8s
0 tests  - 605  0 ✅  - 605  0 💤 ±0  0 ❌ ±0 
0 runs   - 618  0 ✅  - 618  0 💤 ±0  0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Unit Tests - macos_AnyCPU_Release

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit a997fb4.

Copy link

Unit Tests - Windows_AnyCPU_Release

0 files   -  12  0 suites   - 12   0s ⏱️ - 4m 40s
0 tests  - 613  0 ✅  - 613  0 💤 ±0  0 ❌ ±0 
0 runs   - 626  0 ✅  - 626  0 💤 ±0  0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Integration Tests - Windows_AnyCPU_Core_Release

0 tests   - 5   0 ✅  - 5   0s ⏱️ -1s
0 suites  - 2   0 💤 ±0 
0 files    - 2   0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Integration Tests - Windows_AnyCPU_Core_Debug

0 tests   - 5   0 ✅  - 5   0s ⏱️ -1s
0 suites  - 2   0 💤 ±0 
0 files    - 2   0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Unit Tests - Windows_AnyCPU_Debug

0 files   -  10  0 suites   - 10   0s ⏱️ - 4m 45s
0 tests  - 605  0 ✅  - 605  0 💤 ±0  0 ❌ ±0 
0 runs   - 618  0 ✅  - 618  0 💤 ±0  0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Integration Tests - macos_AnyCPU_Debug

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit a997fb4.

Copy link

Integration Tests - macos_AnyCPU_Release

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit a997fb4.

Copy link

Integration Tests - Windows_AnyCPU_Release

0 tests   - 5   0 ✅  - 5   0s ⏱️ -1s
0 suites  - 2   0 💤 ±0 
0 files    - 2   0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Performance Tests - Windows_AnyCPU_Core_Release

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Integration Tests - Windows_AnyCPU_Debug

0 tests   - 5   0 ✅  - 5   0s ⏱️ ±0s
0 suites  - 2   0 💤 ±0 
0 files    - 2   0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link

Performance Tests - Windows_AnyCPU_Release

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit a997fb4. ± Comparison against base commit 51e6b47.

Copy link
Contributor

@justadreamer justadreamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the order of the elements no longer corresponds to the order of them in the configuration, and the test failures might be indicating it too: https://github.com/51Degrees/pipeline-dotnet/pull/160/checks?check_run_id=34471477263
Please check the comments, and make sure the order is preserved and the tests pass.

@@ -402,7 +410,7 @@ private void AddElementToList(
/// The index of the element within the <see cref="PipelineOptions"/>.
/// </param>
private void AddParallelElementsToList(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cosmetics, but I would rename this method into EnqueParallelElements since now it is not adding to the list but adding to the queue

@@ -222,7 +230,7 @@ private void GetAvailableElementBuilders()
/// <see cref="PipelineOptions"/> instance.
/// </param>
private void AddElementToList(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cosmetics, but I would rename this method into EnqueueElement now since it is no longer adding to the list, but adding to the queue.


// Add created builders to flow elements
FlowElements.AddRange(flowElementQueue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We constructed the elements in parallel and they were added in the chronological order of construction completion into the flowElementQueue, but we expect that they should be added into the FlowElements in the order in which they were specified in the configuration, not in the chronological order of construction completion... So perhaps we need to associate an index with each of them during construction - to place into the right position..

… limit the processor count so that it doesnt use up all resources on start up.
…ch parallel interation and insert each element at the respective index. This preserves the element order that is declared in the configuration.
… List runs into Out of Index exceptions because of how lists are created.
Copy link
Contributor

@justadreamer justadreamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It seems there are no order-checking tests. We probably need to add some and verify that the order of elements corresponds to the one in the configuration.
  2. One more issue that we run into with this change is that we are breaking the exception contract. If you run tests locally (which you should do in any case before pushing code, to make sure they pass) - you will find that they fail, because ForEach throws an AggregateException, while the tests expect PipelineConfigurationException. This actually leads to another problem - that ForEach will construct all of the elements - regardless of whether any of them have failed... While it would be ideal to cancel the construction when at least one of them have failed... So we have to tie together catching the exception, firing the cancellation token, rethrowing the exception. This may become a pretty complicated implementation, but we need to implement it in the way that if one of the parallel tasks fails - we don't complete (or start if we haven't yet started) all others.

@justadreamer justadreamer marked this pull request as draft December 16, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Parallel.ForEach to build the elements in parallel reducing the time taken to complete the build task
2 participants