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

timetable performance #10371

Merged
merged 3 commits into from
Jan 20, 2025
Merged

timetable performance #10371

merged 3 commits into from
Jan 20, 2025

Conversation

anisometropie
Copy link
Contributor

@anisometropie anisometropie commented Jan 13, 2025

closes #10377

Performance improvement with a 1000 trains timetable on a short path. Every single train was being re-rendered on every single frame.

improvements:

  • virtualizing list of trains to only have elements that are actually displayed in the DOM.
  • using useCallback on two props to prevent of re-renders on TimetableTrainCard
    Screenshot_20250113_210147

the 2 useCallbacks on their own prevent any re-render of TimetableTrainCard that are already painted.

adding VList on top of the 2 useCallbacks makes an anonymous wrapper of TimetableTrainCard re-render (internal stuff of the library (z prop)) but it’s still an improvement from using useCallback alone.

Timing

case timer
base 4:27 https://github.com/user-attachments/assets/23e89906-72c4-43d3-81dc-3336af39c6f6
VList only 1:13 https://github.com/user-attachments/assets/36366f06-c0ce-46c4-aaca-b61f1ea29984
useCallback only 1:25 https://github.com/user-attachments/assets/238d8dc5-a106-4904-a7b3-a0f23671c068
Both 1:00 https://github.com/user-attachments/assets/bbb3e9d6-fa5a-4816-b6d3-432d2a064cd6

a bit of improvement for #8575, but still slow on a click

@anisometropie anisometropie force-pushed the vcs/virtualize-list branch 2 times, most recently from 431c250 to 8333785 Compare January 14, 2025 10:50
@anisometropie anisometropie marked this pull request as ready for review January 14, 2025 10:50
@anisometropie anisometropie requested a review from a team as a code owner January 14, 2025 10:50
@github-actions github-actions bot added the area:front Work on Standard OSRD Interface modules label Jan 14, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.79%. Comparing base (c4c4c58) to head (dd0588c).
Report is 7 commits behind head on dev.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #10371   +/-   ##
=======================================
  Coverage   81.79%   81.79%           
=======================================
  Files        1073     1073           
  Lines      106543   106549    +6     
  Branches      727      727           
=======================================
+ Hits        87147    87154    +7     
+ Misses      19357    19356    -1     
  Partials       39       39           
Flag Coverage Δ
editoast 74.21% <ø> (+<0.01%) ⬆️
front 89.37% <100.00%> (+<0.01%) ⬆️
gateway 2.18% <ø> (ø)
osrdyne 3.28% <ø> (ø)
railjson_generator 87.50% <ø> (ø)
tests 87.05% <ø> (ø)

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.

@bloussou
Copy link
Contributor

Nice, will you change the way trains are added in the list (currently 10 after 10) in a following PR ? The backend is ready to accept first train list loading and then the remaining parts and this with parallelized batches.

@anisometropie anisometropie force-pushed the vcs/virtualize-list branch 2 times, most recently from f139527 to 9bc5044 Compare January 15, 2025 08:51
Copy link
Contributor

@RomainValls RomainValls left a comment

Choose a reason for hiding this comment

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

I'm not familiar with the virtualizer solution, but performances and code LGTM

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

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

Nice and simple!

Testing with a timetable with 4k trains, the next bottleneck seems to be the conflict list. Real world data seems to contain a lot of these (I get ~15k) and it slows down the whole page significantly.

@emersion
Copy link
Member

Other nit for the commit message title: "performance" is uncountable in this context.

@anisometropie anisometropie force-pushed the vcs/virtualize-list branch 2 times, most recently from 6c95476 to f58f67c Compare January 20, 2025 12:58
@anisometropie anisometropie changed the title timetable performances timetable performance Jan 20, 2025
timetable with virtualized list to limit the number of elements in the DOM

Signed-off-by: Valentin Chanas <[email protected]>
@anisometropie anisometropie added this pull request to the merge queue Jan 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 20, 2025
@anisometropie anisometropie added this pull request to the merge queue Jan 20, 2025
Merged via the queue into dev with commit 4354cfb Jan 20, 2025
27 checks passed
@anisometropie anisometropie deleted the vcs/virtualize-list branch January 20, 2025 15:12
@Maymanaf Maymanaf restored the vcs/virtualize-list branch January 27, 2025 16:12
@clarani clarani deleted the vcs/virtualize-list branch February 4, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front Work on Standard OSRD Interface modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Large timetable loading performance
5 participants