Skip to content

Naive cache implementation in case-datasource#175

Open
antoinebhs wants to merge 1 commit intomainfrom
cache-case-datasource
Open

Naive cache implementation in case-datasource#175
antoinebhs wants to merge 1 commit intomainfrom
cache-case-datasource

Conversation

@antoinebhs
Copy link
Contributor

@antoinebhs antoinebhs commented Dec 10, 2025

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)
  • A PR or issue has been opened in all impacted repositories (if any)

Does this PR already have an issue describing the problem?

What kind of change does this PR introduce?

When importing a CGMES file, we get multiples "input stream" from the case server. This downloads the requested file each time (example for a CGMES):

path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SV.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_EQ.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_TP.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SSH.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SV.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_EQ.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_TP.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SSH.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SV.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_EQ.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_TP.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SSH.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SV.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_EQ.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_TP.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SSH.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SV.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_EQ.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_TP.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SSH.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SV.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_EQ.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_TP.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SSH.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SV.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_EQ.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_TP.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SSH.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_SV.xml
path: /v1/cases/01766b1e-7b25-4869-84da-08a046cc37d6/datasource?fileName=testCase_EQ.xml

So we download about 8 times the complete uncompressed file which corresponds to big network exchanges. It's also a problem because using restTemplate exchange, we store the downloaded files in memory. These files can be >500mb which requests a lot of memory.
I implemented a cache to discuss the issue, this avoid excessive downloads and to store the files in memory.
The drawback is that we need big /tmp volume to store the files and we need a robust cleaning logic to avoid orphan files in /tmp.

In addition to that, we need to quantify how much memory we need to import these file using powsybl-core only.

What is the current behavior?

What is the new behavior (if this is a feature change)?

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

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:

Signed-off-by: BOUHOURS Antoine <antoine.bouhours@rte-france.com>
Copy link
Contributor Author

@antoinebhs antoinebhs left a comment

Choose a reason for hiding this comment

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

if we GZ
=> it would be better to download the gz from case-server directly instead of downloading the plain file then GZ

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.

1 participant