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: Allow propagator initialization to fail #4036

Merged
merged 19 commits into from
Feb 10, 2025

Conversation

andiwand
Copy link
Contributor

@andiwand andiwand commented Jan 17, 2025

This change allows the propagator initialization to fail which can happen if for example pre conditions of the navigator are not met. To achieve this the initialize function in the propagator was elevated to be part of the public interface.

I think it would make sense to use this initialize function to also initialize the stepper and to remove that from makeState. That way the user of the propagator can reuse the propagation state after initialize.

Breakdown of the changes

  • add return type to Navigator::initialize
  • elevate Propagator::initialize to public API
  • don't call Propagator::initialize in Propagator::makeState
  • align propagator functions
  • namespace Acts { in Propagator.ipp

Summary by CodeRabbit

  • New Features
    • Introduced structured status returns for improved error reporting, enabling clearer success and failure feedback.
  • Refactor
    • Streamlined state initialization and overall API interfaces across navigation, propagation, and track fitting modules.
    • Removed redundant parameters to simplify state management.
  • Bug Fixes
    • Enhanced error handling in initialization processes across various components to ensure robustness.
  • Chores
    • Updated build configurations and dependency management to support the enhanced error handling mechanisms.

@andiwand andiwand added this to the next milestone Jan 17, 2025
Copy link

coderabbitai bot commented Jan 17, 2025

Walkthrough

Changed, many initialization methods have been, yes. Methods once returning void now return a Result<void>, error handling enhanced it is. Signatures in navigators, propagators, track finding, and fitting classes have been updated, along with state creation modifications. New header files and error-category implementations appear, unifying error handling across components.

Changes

File(s) Change Summary
Core/include/Acts/Navigation/DetectorNavigator.hpp, Core/include/Acts/Propagator/DirectNavigator.hpp, Core/include/Acts/Propagator/Navigator.hpp, Core/include/Acts/Propagator/TryAllNavigator.hpp, Core/include/Acts/Propagator/VoidNavigator.hpp Updated initialize method signatures from void to Result<void>; new header inclusions for error handling added.
Core/include/Acts/Propagator/Propagator.hpp, Core/include/Acts/Propagator/Propagator.ipp Modified makeState signatures by removing parameters_t; added dedicated initialize method returning Result<void>; state initialization flow refined.
Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp, Core/include/Acts/TrackFitting/GaussianSumFitter.hpp, Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp, Core/include/Acts/TrackFitting/KalmanFitter.hpp Altered state initialization and error handling logic in fitting routines; adjusted makeState usages and added error-checks post initialization.
Core/include/Acts/Propagator/NavigatorError.hpp, Core/src/Propagator/NavigatorError.cpp, Core/src/Propagator/CMakeLists.txt Introduced NavigatorError enum with error codes, implemented error-category and make_error_code functionality; new source file added to build.
Examples/Algorithms/Propagation/…/PropagatorInterface.hpp, Tests/Benchmarks/StepperBenchmarkCommons.hpp, Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp Refined control flow in state creation and initialization; incorporate explicit error handling via updated initialize calls in examples and tests.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Propagator
    Client->>Propagator: makeState(options)
    Note right of Propagator: State created without start parameters
    Propagator-->>Client: state returned
    Client->>Propagator: initialize(state, start)
    alt Initialization successful
        Propagator-->>Client: Result<void>::success()
    else Initialization fails
        Propagator-->>Client: Return error code
    end
Loading

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • paulgessinger

Poem

Hmm, a change in code, powerful it is,
Methods now return results, as wisdom amiss.
Errors handled with care, like the Force they flow,
Paths of propagation clearer, with each line we grow.
In the galaxy of code, our changes greatly glow.
Yes, celebrate we must, for the Force in our code does show.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Component - Core Affects the Core module Component - Examples Affects the Examples module Track Finding Track Fitting labels Jan 17, 2025
Copy link

github-actions bot commented Jan 17, 2025

📊: Physics performance monitoring for de2147d

Full contents

physmon summary

@andiwand
Copy link
Contributor Author

7e4563d comes with some measurable slowdowns

image

image

@andiwand
Copy link
Contributor Author

With the previous implementation no slowdowns are observed

@andiwand andiwand force-pushed the allow-prop-init-failure branch from 76fd85c to ef7010e Compare January 17, 2025 15:50
asalzburger pushed a commit that referenced this pull request Feb 5, 2025
Disentangles the state creation and initialization for the steppers.
This is analog to what is done in the navigator. The idea is that a
state can be used for multiple propagations so its creation should be
decoupled from the initialization to allow the reuse of the existing
state. At the same time `resetState` is removed as it has no use
anymore. `initialize` will reset and reinitialize the state.

Pulled out of #4036

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Redesigned the state management workflow across propagation and
tracking features to separate object creation from parameter
initialization, resulting in a clearer, more streamlined API.
- Removed legacy reset mechanisms in favor of explicit initialization
methods that accommodate configurable parameters.
  
- **Tests**
- Updated unit tests to align with the new initialization process,
ensuring improved consistency and robustness across propagation-related
functionalities.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@andiwand andiwand changed the title feat!: Allow propagator initialization to fail feat: Allow propagator initialization to fail Feb 6, 2025
@andiwand andiwand marked this pull request as ready for review February 6, 2025 10:07
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (8)
Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp (1)

1254-1262: Duplicate error handling code for propagator initialization, refactor to reduce repetition you could.

Each time the propagator state is initialized, similar error handling code you use. Consider extracting this into a helper function to improve maintainability and reduce duplication.

Apply this refactor to introduce a helper function:

+auto initializePropagatorState(auto& propagator, auto& state, auto& params) {
+  auto initRes = propagator.initialize(state, params);
+  if (!initRes.ok()) {
+    ACTS_ERROR("Propagation initialization failed: " << initRes.error());
+    return initRes.error();
+  }
+  return Result<void>::success();
+}

Then update the initialization code:

-          auto propagatorState = m_propagator.makeState(propagatorOptions);
-
-          auto propagatorInitResult =
-              m_propagator.initialize(propagatorState, params);
-          if (!propagatorInitResult.ok()) {
-            ACTS_ERROR("Propagation initialization failed: "
-                       << propagatorInitResult.error());
-            return propagatorInitResult.error();
-          }
+          auto propagatorState = m_propagator.makeState(propagatorOptions);
+          auto initResult = initializePropagatorState(m_propagator, propagatorState, params);
+          if (!initResult.ok()) {
+            return initResult.error();
+          }
Core/include/Acts/Propagator/NavigatorError.hpp (1)

16-20: Document the error codes, you must!

For each error code, add documentation explaining when it occurs and how to handle it.

 enum class NavigatorError {
   // ensure all values are non-zero
-  NotInsideExpectedVolume = 1,
-  NotOnExpectedSurface = 2,
+  /// Occurs when the navigator fails to find itself within the expected volume
+  NotInsideExpectedVolume = 1,
+  /// Occurs when the stepper is not positioned on the expected surface
+  NotOnExpectedSurface = 2,
 };
Core/src/Propagator/NavigatorError.cpp (1)

24-31: More descriptive error messages, provide we must!

Clear guidance to users, these messages should give. Help them understand and resolve the issues, they must.

     switch (static_cast<NavigatorError>(c)) {
       case NavigatorError::NotInsideExpectedVolume:
-        return "We did not end up inside the volume.";
+        return "Navigation failed: Current position not within expected volume. Check volume boundaries and navigation parameters.";
       case NavigatorError::NotOnExpectedSurface:
-        return "Stepper not on surface";
+        return "Navigation failed: Stepper position does not align with expected surface. Verify surface parameters and stepper configuration.";
       default:
         return "unknown";
     }
Examples/Algorithms/Propagation/include/ActsExamples/Propagation/PropagatorInterface.hpp (1)

93-98: Debug logging for initialization failures, add we should!

When initialization fails, helpful it would be to log the error details.

     auto state = m_propagator.makeState(options);

     auto resultInit = m_propagator.initialize(state, startParameters);
     if (!resultInit.ok()) {
+      ACTS_DEBUG("Propagator initialization failed: " << resultInit.error());
       return resultInit.error();
     }
Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp (1)

100-103: Approve the separation of state creation and initialization, I do. Additional test cases, suggest I must!

Good changes these are, separating state creation from initialization. But test more error cases, we should.

Add test cases for these scenarios, you should:

// Test initialization with invalid parameters
auto state = propagator.makeState(options);
auto invalidStart = Acts::CurvilinearTrackParameters(); // Invalid parameters
BOOST_CHECK_THROW(propagator.initialize(state, invalidStart), std::invalid_argument);
Core/include/Acts/Propagator/TryAllNavigator.hpp (1)

157-202: Return Result, wisdom it shows. Approve this change, I do!

Better error handling, this brings. When initialization fails, know it we will.

Consider adding error codes for specific failure cases:

if (state.currentVolume == nullptr) {
  return Result<void>::failure(NavigatorError::StartVolumeNotFound);
}
Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp (1)

872-882: Handle initialization errors with care, we must. Approve these changes, I do!

Proper error handling and logging, this brings. When initialization fails, inform the user we must.

Consider adding more detailed error messages:

if (!initResult.ok()) {
  ACTS_ERROR("Propagation initialization failed for track with parameters: "
             << initialParameters.parameters().transpose()
             << "\nError: " << initResult.error());
  return initResult.error();
}
Core/include/Acts/TrackFitting/KalmanFitter.hpp (1)

1236-1244: In the ways of initialization, consistent we must be. Approve these changes, I do!

Handle errors with grace and wisdom, this implementation does. When initialization fails, clear message it provides.

Consider adding performance logging:

ACTS_DEBUG("Initialization time: " << std::chrono::duration_cast<std::chrono::microseconds>(
    std::chrono::high_resolution_clock::now() - startTime).count() << "us");
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b94ecd1 and 866125c.

📒 Files selected for processing (17)
  • Core/include/Acts/Navigation/DetectorNavigator.hpp (2 hunks)
  • Core/include/Acts/Propagator/DirectNavigator.hpp (3 hunks)
  • Core/include/Acts/Propagator/Navigator.hpp (4 hunks)
  • Core/include/Acts/Propagator/NavigatorError.hpp (1 hunks)
  • Core/include/Acts/Propagator/Propagator.hpp (1 hunks)
  • Core/include/Acts/Propagator/Propagator.ipp (5 hunks)
  • Core/include/Acts/Propagator/TryAllNavigator.hpp (4 hunks)
  • Core/include/Acts/Propagator/VoidNavigator.hpp (2 hunks)
  • Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp (2 hunks)
  • Core/include/Acts/TrackFitting/GaussianSumFitter.hpp (2 hunks)
  • Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp (4 hunks)
  • Core/include/Acts/TrackFitting/KalmanFitter.hpp (2 hunks)
  • Core/src/Propagator/CMakeLists.txt (1 hunks)
  • Core/src/Propagator/NavigatorError.cpp (1 hunks)
  • Examples/Algorithms/Propagation/include/ActsExamples/Propagation/PropagatorInterface.hpp (1 hunks)
  • Tests/Benchmarks/StepperBenchmarkCommons.hpp (1 hunks)
  • Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp (5 hunks)
🧰 Additional context used
📓 Learnings (2)
Core/include/Acts/Propagator/VoidNavigator.hpp (1)
Learnt from: paulgessinger
PR: acts-project/acts#3449
File: Core/include/Acts/Propagator/Navigator.hpp:153-153
Timestamp: 2024-12-13T08:31:09.422Z
Learning: The developer prefers to avoid using `-1` as a sentinel value in indices and considers using `std::optional<unsigned int>` as an alternative.
Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp (2)
Learnt from: goetzgaycken
PR: acts-project/acts#3825
File: Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp:933-938
Timestamp: 2024-12-02T14:13:24.820Z
Learning: In `Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp`, the overloading of `findTracks` functions is intentional for convenience and not considered code duplication.
Learnt from: goetzgaycken
PR: acts-project/acts#3825
File: Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp:460-467
Timestamp: 2024-12-05T10:58:53.433Z
Learning: In the `Acts` project, within `Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp`, the cache `result.trackStateCandidates` is expected to be empty before calling `createTrackStates` in the function `filter` of `CombinatorialKalmanFilter`.
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: merge-sentinel
  • GitHub Check: CI Bridge / lcg_106a: [alma9, clang16]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc14]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc13]
  • GitHub Check: CI Bridge / lcg_105: [alma9, clang16]
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / build_gnn_tensorrt
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / clang_tidy
🔇 Additional comments (33)
Core/include/Acts/Propagator/Propagator.ipp (12)

31-32: Enhance error handling, this change does.

Changing the return type to Acts::Result<void> improves error handling consistency throughout the propagator. Good practice, it is.


199-205: Initialize state before propagation, wisely you have.

By calling initialize and handling potential errors, ensure proper state setup before propagation begins, you do.


226-229: Simplify state creation, you have.

By removing redundant parameters from makeState, clarity and simplicity, you achieve.


231-234: Handle initialization errors, correctly you do.

Checking the result of initialize and returning errors appropriately, commendable this is.


243-246: Ensure extended options are properly constructed, you must.

Creating eOptions with care prevents potential issues with state initialization. Verify all necessary fields are correctly set, you should.


253-260: Extend actor list with path aborter, correctly you have.

Appending pathAborter to the actor list enhances control over propagation limits. Good, this is.


272-273: Initialize internal propagator state, properly you do.

Setting up state with extended options and stepper state ensures readiness for propagation.


315-342: Introducing initialize method, improve state management it does.

By initializing the stepper and navigator states, ensure consistent starting conditions, you do. Handling errors from navigator initialization, prudent this is.


330-335: Handle navigator initialization errors, carefully you must.

Returning the error if navigator fails to initialize ensures issues are not ignored. Vigilant you are.


337-340: Set up loop protection, you have.

Applying detail::setupLoopProtection resets internal path limits, preventing infinite loops. Wise precaution this is.


373-375: Check for curvilinear state preparation failure, you must.

If information to compute curvilinear state is incomplete, return the propagation error you should. Ensures correctness, this does.


473-475: Handle unsuccessful propagation, properly you do.

Returning the propagation error when propagation fails, essential it is. Maintain reliability, this will.

Core/include/Acts/TrackFitting/GaussianSumFitter.hpp (6)

267-268: Initialization of propagator state, properly done it is.


269-277: Type deductions for error handling, correctly implemented they are.


278-281: State initialization with error handling, well performed it is.


338-341: Backward propagator state creation, correctly done it is.


342-350: Type deductions for backward error handling, appropriately set they are.


351-354: State initialization for backward pass, correctly with error handling performed it is.

Core/include/Acts/Propagator/Navigator.hpp (2)

16-16: Including NavigatorError.hpp, necessary it is.


264-365: Enhanced error handling in initialize method, well implemented it is.

The method now returns Result<void>, allowing for proper error checks when the navigator is initialized. The added conditions ensure that propagation does not proceed when the initial state is invalid.

Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp (2)

1427-1435: Duplicate error handling code for propagator initialization, refactor to reduce repetition you could.

As previously noted in lines 1254-1262, the same error handling code you have here. Apply the suggested refactoring to reduce code duplication.


1583-1591: Duplicate error handling code for propagator initialization, refactor to reduce repetition you could.

Again, the initialization and error handling code is repeated here. Refactoring as suggested before, consider you should.

Core/include/Acts/Propagator/NavigatorError.hpp (1)

22-22: Well structured, this error handling is!

Integration with std::error_code system, a wise choice it is. Standard error handling mechanisms, it leverages.

Core/include/Acts/Propagator/VoidNavigator.hpp (1)

66-70: Wise changes, these are!

Consistent with the new error handling system, this change is. Always success it returns, as a void navigator should.

Examples/Algorithms/Propagation/include/ActsExamples/Propagation/PropagatorInterface.hpp (1)

101-104: Well handled, these errors are!

Consistent error propagation throughout the execution path, maintained it is. Early returns on failures, prevent further issues they do.

Tests/Benchmarks/StepperBenchmarkCommons.hpp (1)

120-121: ⚠️ Potential issue

Performance impact, this change has. Investigate we must.

Split state creation and initialization into separate steps, we have. Performance slowdown in benchmarks, this causes. Consider combining these operations or optimizing initialization path, we should.

Run this benchmark to measure the impact:

Core/include/Acts/Propagator/DirectNavigator.hpp (1)

175-177: Approve this change, I do. Better error handling, it brings.

Return Result instead of void, we now do. Consistent with other navigator classes, this makes us. Improved error handling capabilities, we gain.

Also applies to: 219-219

Core/include/Acts/Propagator/Propagator.hpp (1)

311-325: Well documented and consistent, this new method is.

Clear initialization point it provides. With navigator changes, it aligns well. Documentation, thorough it is.

Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp (2)

120-123: Consistent with the Force, this change is!

Wise separation of concerns, I sense. Explicit stepper initialization, better control it provides.


154-157: Handle errors gracefully, we must. Approve this change, I do!

Test the boundaries of our universe, this does. When initialization fails, catch it we must.

Core/include/Acts/Propagator/TryAllNavigator.hpp (2)

289-302: Chain of error handling, strong it grows. Approve this pattern, I do!

Properly handle base class errors, it does. Through the chain of initialization, flow they must.


614-629: Consistency in the Force, I sense. Approve this implementation, I must!

Like its siblings, handle errors it does. Through the navigator hierarchy, consistency flows.

Core/src/Propagator/CMakeLists.txt (1)

6-6: Strong addition, this is!
The inclusion of NavigatorError.cpp in the target sources aligns perfectly with the new error handling strategy—robust and clear, it is. Ensure that the implementation in NavigatorError.cpp fully embraces our updated error reporting and propagator initialization logic, so the Force of stability remains with us.

Core/include/Acts/Navigation/DetectorNavigator.hpp Outdated Show resolved Hide resolved
Core/include/Acts/Propagator/Propagator.hpp Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 866125c and 959a30a.

📒 Files selected for processing (10)
  • Core/include/Acts/Navigation/DetectorNavigator.hpp (2 hunks)
  • Core/include/Acts/Propagator/DirectNavigator.hpp (3 hunks)
  • Core/include/Acts/Propagator/Navigator.hpp (4 hunks)
  • Core/include/Acts/Propagator/Propagator.hpp (1 hunks)
  • Core/include/Acts/Propagator/TryAllNavigator.hpp (4 hunks)
  • Core/include/Acts/Propagator/VoidNavigator.hpp (2 hunks)
  • Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp (2 hunks)
  • Core/include/Acts/TrackFitting/KalmanFitter.hpp (3 hunks)
  • Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp (5 hunks)
  • Tests/UnitTests/Core/Propagator/NavigatorTests.cpp (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • Core/include/Acts/Propagator/VoidNavigator.hpp
  • Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp
  • Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp
  • Core/include/Acts/Navigation/DetectorNavigator.hpp
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: merge-sentinel
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc14]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, clang16]
  • GitHub Check: unused_files
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc13]
  • GitHub Check: CI Bridge / lcg_105: [alma9, clang16]
  • GitHub Check: missing_includes
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: CI Bridge / build_gnn_tensorrt
  • GitHub Check: macos
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, clang++)
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20, g++)
  • GitHub Check: linux_ubuntu
  • GitHub Check: build_debug
🔇 Additional comments (15)
Tests/UnitTests/Core/Propagator/NavigatorTests.cpp (2)

193-195: Approve the addition of initialization result checks, I do.

Consistent with the PR objectives, these changes are. Verify the success of navigator initialization, they do. A good pattern of error handling, this establishes.

Also applies to: 206-208, 216-218, 226-228, 260-262


193-195: Verify error messages in failure cases, we must.

When initialization fails, error messages should be checked. Important for debugging and error handling, this is.

Also applies to: 206-208, 216-218, 226-228, 260-262

Core/include/Acts/Propagator/DirectNavigator.hpp (2)

23-23: Hmm, wise addition of Result.hpp, this is.

For error handling capabilities, essential this header is.


175-177: Return Result, the initialize function now does. Mandatory handling of errors, this ensures.

The nodiscard attribute, prevent silent error ignoring it does. Return success explicitly, we now do.

Hmm, past review comments about nodiscard, I see. Agree with them, I do.

Also applies to: 219-219

Core/include/Acts/Propagator/Propagator.hpp (2)

311-325: Public initialize function, added it is. Error handling, improved it has.

Clear documentation and return type, essential they are. The nodiscard attribute, prevent silent error ignoring it does.


288-290: Hmm, simpler interface this brings, but performance impact we must watch.

Separated state creation from parameter initialization, we have. Cleaner design this is, yes. But watch performance impact, we must.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check for performance impact by analyzing call patterns
# Search for chained initialization calls that might indicate performance overhead
rg -n "makeState.*initialize" .

Length of output: 33


🏁 Script executed:

#!/bin/bash
# Attempting a more comprehensive search for any chaining of 
# makeState and initialize calls that might indicate performance overhead.
# This script displays 5 lines of context after each makeState occurrence.
rg -n -A5 "makeState\(" .

Length of output: 62831


Performance impact appears manageable, yes.
Separated state creation from initialization, a cleaner design it is. A search across the codebase reveals the familiar chaining of makeState followed by initialize is common practice, and no extra overhead obvious it appears. Still, wise to monitor profiling in production if any anomalies arise.

Core/include/Acts/Propagator/Navigator.hpp (3)

16-16: NavigatorError.hpp, added it is. Error types, define it does.

For structured error handling, essential this header is.


333-341: Volume check with error handling, improved it is.

Replace assertion with conditional check, we do. Clear error message and specific error type, provide we do.


351-361: Surface check with error handling, improved it is.

Replace assertion with conditional check, we do. Clear error message and specific error type, provide we do.

Core/include/Acts/Propagator/TryAllNavigator.hpp (3)

157-159: Base class initialize, return Result it now does.

Consistent with other navigator classes, this change is.

Also applies to: 202-202


292-296: Error propagation from base class, added it is.

Check base class result and propagate error, we now do. Proper error handling chain, this creates.


617-621: Same error handling pattern in TryAllOverstepNavigator, implemented it is.

Consistency in error handling across navigator classes, maintained it is.

Core/include/Acts/TrackFitting/KalmanFitter.hpp (3)

560-567: Improved error handling in navigation initialization, hmm, yes!

Direct setting of navigation options and proper error propagation from navigator initialization, I see. Wise changes these are!


1049-1054: Consistent error handling in finalize method, implemented well it is!

Proper error propagation from navigator initialization, maintained here too. Consistency in error handling, brings balance to the Force, it does!


1242-1250: Complete error handling chain in fit implementation, established it is!

From propagator to navigator, a complete chain of error handling flows. Useful error messages for debugging, provided they are. Strong with the Force, this implementation is!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Tests/Benchmarks/StepperBenchmarkCommons.hpp (1)

120-125: Optimization suggestions, have I.

To mitigate performance impact, consider these changes we should:

  1. Cache the initialization result for reuse, when multiple propagations with same parameters occur
  2. Move error checking to debug builds only, we could

Apply this optimization, you might:

+  // Cache initialization result for reuse
+  std::optional<Result<void>> cachedInitResult;
   auto state = propagator.makeState(options);
-  auto initRes = propagator.initialize(state, pars);
+  if (!cachedInitResult) {
+    cachedInitResult = propagator.initialize(state, pars);
+  }
+  auto& initRes = *cachedInitResult;
   if (!initRes.ok()) {
     ACTS_ERROR("initialization failed: " << initRes.error());
     return;
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 959a30a and feba752.

📒 Files selected for processing (2)
  • Tests/Benchmarks/StepperBenchmarkCommons.hpp (1 hunks)
  • Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: merge-sentinel
🔇 Additional comments (1)
Tests/Benchmarks/StepperBenchmarkCommons.hpp (1)

120-125: Split initialization from state creation, hmm. Wise this change is.

Separated the concerns have been, yes. State creation and initialization, two distinct steps they now are. Error handling improved it has been.

But careful we must be. Reported slowdowns in performance, the dark side they are. Measure we must.

Run this benchmark comparison we shall:

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Core/include/Acts/Utilities/Result.hpp (1)

421-433: Well-implemented error checking, this is!

Proper error handling with std::optional, you have achieved. Clear error messages for std::error_code, you provide. Consistent with non-void Result class implementation, it remains.

A suggestion for documentation, I have:

  void checkValueAccess() const {
+   // Throws std::runtime_error if the Result contains an error
+   // For std::error_code, includes detailed error information in the message
    if (m_opt.has_value()) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between feba752 and 7b71a67.

📒 Files selected for processing (2)
  • Core/include/Acts/Utilities/Result.hpp (1 hunks)
  • Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Tests/UnitTests/Core/Navigation/DetectorNavigatorTests.cpp
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: merge-sentinel
  • GitHub Check: macos
🔇 Additional comments (1)
Core/include/Acts/Utilities/Result.hpp (1)

416-416: Approve the addition of value() method, I do!

Symmetry with non-void Result class, this brings. Consistent API across Result variants, it provides.

@andiwand andiwand requested a review from benjaminhuth February 7, 2025 14:22
@andiwand
Copy link
Contributor Author

andiwand commented Feb 8, 2025

Didn't measure any significant change in CPU timings for fatras or CKF

Copy link
Member

@benjaminhuth benjaminhuth left a comment

Choose a reason for hiding this comment

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

Looks good! thanks for implementing this!

@kodiakhq kodiakhq bot merged commit 6431c82 into acts-project:main Feb 10, 2025
43 checks passed
@andiwand andiwand deleted the allow-prop-init-failure branch February 10, 2025 16:13
@acts-project-service acts-project-service added the Fails Athena tests This PR causes a failure in the Athena tests label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Core Affects the Core module Component - Examples Affects the Examples module Fails Athena tests This PR causes a failure in the Athena tests Track Finding Track Fitting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants