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

editoast: infra: order objects when downloading a railjson #6728

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

Castavo
Copy link
Contributor

@Castavo Castavo commented Feb 23, 2024

This PR is there to compensate the fact that railjson import loads objects (track sections, signals, ...) in a random order in the db.

Then, if you import and export a railjson, the order of the objects change randomly. This randomness affects the results of the circulation import benchmark (today if you import the same railjson twice, and run the circulation import benchmark on each, the results aren't the same). This PR tries to fix that.

I ran this code before and after.

INFRA_ID = 3  # France
url = f"http://localhost:8090/infra/{INFRA_ID}/railjson"

# first call
start = time()
response = requests.get(url)
first_call_time = time() - start

# run ten times
times = []
for _ in tqdm(range(100)):
    start = time()
    response = requests.get(url)
    times.append(time() - start)

Before:
first call: 2.50 seconds
mean: 2.11 seconds
stdev: 0.05 seconds

After:
first call: 2.65 seconds
mean: 2.34 seconds
stdev: 0.04 seconds

I'm not 100% certain that the results can be trusted, the performance of the endpoint seems very variable depending on the context.

So there is a bit more than a 10% of time increase with this PR, do you think it's acceptable ? If not, I can try adding indexes to the obj_id columns and run another benchmark.

@Castavo Castavo self-assigned this Feb 23, 2024
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 27.93%. Comparing base (689d6c3) to head (52d835e).

Additional details and impacted files
@@            Coverage Diff            @@
##                dev    #6728   +/-   ##
=========================================
  Coverage     27.92%   27.93%           
  Complexity     2172     2172           
=========================================
  Files          1041     1041           
  Lines        128661   128661           
  Branches       2567     2567           
=========================================
+ Hits          35928    35937    +9     
+ Misses        91250    91241    -9     
  Partials       1483     1483           
Flag Coverage Δ
core 79.36% <ø> (ø)
editoast 75.38% <100.00%> (-0.01%) ⬇️
front 8.41% <ø> (ø)
gateway 2.50% <ø> (ø)
railjson_generator 87.26% <ø> (ø)
tests 83.07% <ø> (+1.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Castavo Castavo marked this pull request as ready for review February 23, 2024 12:48
@Castavo Castavo requested a review from a team as a code owner February 23, 2024 12:48
@Castavo Castavo requested a review from flomonster February 23, 2024 12:48
Copy link
Contributor

@flomonster flomonster left a comment

Choose a reason for hiding this comment

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

LGTM

@Castavo Castavo added this pull request to the merge queue Feb 23, 2024
Merged via the queue into dev with commit 3e4be17 Feb 23, 2024
22 checks passed
@Castavo Castavo deleted the bpt/editoast/osrd-railjson-download branch February 23, 2024 14:24
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.

2 participants