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

Fix too large dense matrix allocation issue #822

Merged
merged 7 commits into from
Aug 22, 2023

Conversation

geofjamg
Copy link
Member

@geofjamg geofjamg commented Aug 9, 2023

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?

No

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When running a sensitivity analysis with too many contingencies we get the following exception:

Exception in thread "main" java.util.concurrent.CompletionException: java.lang.IndexOutOfBoundsException
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1311)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1841)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1806)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.lang.IndexOutOfBoundsException
	at java.base/java.nio.Buffer.checkIndex(Buffer.java:749)
	at java.base/java.nio.DirectByteBuffer.putDouble(DirectByteBuffer.java:1028)
	at com.powsybl.math.matrix.DenseMatrix.setUnsafe(DenseMatrix.java:123)
	at com.powsybl.math.matrix.DenseMatrix.set(DenseMatrix.java:129)
	at com.powsybl.openloadflow.sensi.DcSensitivityAnalysis.fillRhsContingency(DcSensitivityAnalysis.java:422)
	at com.powsybl.openloadflow.sensi.DcSensitivityAnalysis.initContingencyRhs(DcSensitivityAnalysis.java:429)
	at com.powsybl.openloadflow.sensi.DcSensitivityAnalysis.calculateContingenciesStates(DcSensitivityAnalysis.java:434)
	at com.powsybl.openloadflow.sensi.DcSensitivityAnalysis.analyse(DcSensitivityAnalysis.java:878)
	at com.powsybl.openloadflow.sensi.OpenSensitivityAnalysisProvider.lambda$run$0(OpenSensitivityAnalysisProvider.java:196)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)

This is because we try to allocate a too big dense matrix with a size >= max integer.

What is the new behavior (if this is a feature change)?
We throw a clear error message warning the user that there is too many contingencies defined.

Does this PR introduce a breaking change or deprecate an API?

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

Other information:

Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
@geofjamg geofjamg added the bug Something isn't working label Aug 9, 2023
# Conflicts:
#	src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
geofjamg added a commit that referenced this pull request Aug 16, 2023
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
@geofjamg geofjamg requested a review from annetill August 19, 2023 19:35
@sonarcloud
Copy link

sonarcloud bot commented Aug 22, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@annetill annetill left a comment

Choose a reason for hiding this comment

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

I am okay with this message clarification but I wonder about the fact that we have a duplication of code here, no?

@geofjamg
Copy link
Member Author

I am okay with this message clarification but I wonder about the fact that we have a duplication of code here, no?

Sonar do not report any duplication

@annetill annetill merged commit 5af951a into main Aug 22, 2023
@annetill annetill deleted the dense_matrix_overflow_issue branch August 22, 2023 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants