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

Does the test reactor need to be cached/pickled? #1636

Open
opotowsky opened this issue Jan 29, 2024 · 10 comments
Open

Does the test reactor need to be cached/pickled? #1636

opotowsky opened this issue Jan 29, 2024 · 10 comments
Labels
cleanup Code/comment cleanup: Low Priority enhancement New feature or request testing Related to tests

Comments

@opotowsky
Copy link
Member

loadTestReactor pickles the reactor. This caused a big bug in some downstream tests. Just wondering if this functionality is needed.

@opotowsky opotowsky added the testing Related to tests label Jan 29, 2024
@john-science
Copy link
Member

The reason for that is if you call loadTestReactor() and it has already been pickled, loading the test reactor is 20-50 times faster. It can really speed up unit tests.

What was the cause of the bug? What happened?

@john-science john-science added the optimization related to measuring and speeding up the code or reducing memory label Jan 29, 2024
@john-science
Copy link
Member

john-science commented Jan 29, 2024

Sigh...

Arrielle has isolated the following bad situation downstream:

  1. Someone builds the test reactor, and pickles it
  2. The global nuclides get tweaked by some test
  3. The test reactor gets unpickled
  4. The test reactor is unprepared for the change in global nuclides
  5. problems occur

In the long term, the solution to this issue is definitely to make the nuclides not global. We need to glue them onto the Operator and the Reactor, probably.

@ntouran
Copy link
Member

ntouran commented Jan 30, 2024

I agree that the caching is essential to run the tests in reasonable time. This is a legit issue for sure. Bringing nuclide data into the reactor would definitely work and is probably the best solution.

We could also cache a hash/checksum of the nuclide info and then check it upon unpack and invalidate/rebuild the cache if the hashes don't match.

Even shorter term though:

  1. The global nuclides get tweaked by some test

Sounds like a test bug! Sounds like that test should not re-pickle the reactor imho. If a set of tests needs a different fixture then it should be more isolated. In other words, it should untweak before being done.

@jakehader
Copy link
Member

This might be a crazy idea, but what if we aimed to not "pickle" the reactor/operator state for testing but we targeted being able to fully define the "state" in our database so that we are very specific on what data we are holding on to. I feel like this could tend us in the direction where we have the ability to isolate interface testing for unit tests (mocking), and have more robust restart capabilities.

Saving state seems like a good idea for testing but I think we'd be able to isolate bugs/issues if we could use our common db tooling that we built to inspect the state

@opotowsky
Copy link
Member Author

@ntouran, I have all the tests destroying the global nuclides after they are created (I've been rooting out these bugs over months as they appear). In this case, that did not solve the issue.

Downstream, the only reason we haven't hit this issue before is most tests use some custom settings to load the test reactor. This means most of these tests are NOT using the cached reactor. In ARMI, there would likely be a slowdown with the removal of pickling. But I do not believe we would see a slowdown in our plugins. I'm not necessarily advocating for the removal of the pickling. I just want to understand it and see if there's a better way to control it.

@john-science
Copy link
Member

We could also cache a hash/checksum of the nuclide info and then check it upon unpack and invalidate/rebuild the cache if the hashes don't match.

I could implement this as a stop-gap, as soon as we are past the code freeze.

And that would buy us some time for the longer-term "global nuclides" work.

@andfranklin andfranklin self-assigned this Aug 1, 2024
@john-science
Copy link
Member

I expect this ticket to be closed when this one is: #473

@andfranklin
Copy link

andfranklin commented Aug 1, 2024

I expect this ticket to be closed when this one is: #473

@john-science I disagree. That issue is orthogonal to this one.

I think @opotowsky's original question is great! I have a solution that makes all the spaghetti logic in loadTestReactor unnecessary. It will remove many downstream bugs, maintain the caching functionality, and make that function easier to maintain. It might even help solve #473.

If you want to close this issue when you close #473 with a stop-gap because you think you've solved all the world's problems that's fine by me 🤷‍♂️

@andfranklin
Copy link

I'd like to note that the global nuclides issue does not need to be solved before this one. They are orthogonal issues.

@andfranklin andfranklin added enhancement New feature or request cleanup Code/comment cleanup: Low Priority and removed optimization related to measuring and speeding up the code or reducing memory labels Aug 1, 2024
@jakehader
Copy link
Member

jakehader commented Aug 3, 2024

@andfranklin - There was a bug due to global nuclides and pickling. If you have a solution to that fixes or can show improvements on the pickling / caching then let's do a pull request and code review. If it doesn't address the global nuclides, I'm sure that's fine, we could separate out load reactor improvements from global nuclides improvements.

you think you've solved all the world's problems that's fine by me 🤷‍♂️

I believe @john-science is trying to keep you informed about the related global nuclides (#473) issue in case you were not aware / familiar. @john-science - Would you prefer a performance improvement ticket to be separate from this issue and this issue only he related to the global nuclides bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code/comment cleanup: Low Priority enhancement New feature or request testing Related to tests
Projects
None yet
Development

No branches or pull requests

5 participants