Skip to content

Conversation

@aiAdrian
Copy link
Contributor

@aiAdrian aiAdrian commented Oct 8, 2025

Description

Graphical Timetable Performance Optimization

The calculation time for the extractSectionTracks method has been significantly reduced:

  • Google Chrome: Improved by a factor of 3 (from ~75ms to ~25ms)
  • Microsoft Edge: Improved by a factor of 5 (from ~620ms to ~115ms)

These optimizations enhance responsiveness and reduce latency across browsers, especially for Edge users.

Performance Improvement: extractSectionTracks Method

Goal: Improve rendering performance of the graphical timetable by introducing caching and more efficient data structures.

Extended Functionality

Caching introduced: Added getTrainrunSectionFromCacheDuringRendering() method using a Map<number, TrainrunSection> to avoid redundant service calls.

Cache integration: The cache is now used across multiple methods:

  • render()
  • extractStreckenGleis()
  • extractSectionTracks()
  • calculateMinimumHeadwayTimeAtNode()
  • computeTrackAlignments()
  • setMaxTrackMap()

 Performance Improvements

  • Optimized data structure: Replaced number[][] with Uint8Array for dataMatrix to reduce memory usage and improve access speed.

  • Frequency unrolling refactored: New method extractSectionTracksUnrollFreq() handles train frequency loops more efficiently.

  • Occupation band optimization: extractSectionTracksFillOccupationBand() fills occupancy data with bounds checking and performance tuning.

 Logic Enhancements

  • headwayTime calculation now uses the cache.

  • Precomputations like travelTimeIdxPart and baseTimeCellIdx improve loop performance

Issues

#553

Checklist

  • This PR contains a description of the changes I'm making
  • I've read the Contribution Guidelines
  • I've added tests for changes or features I've introduced
  • I documented any high-level concepts I'm introducing in documentation/
  • CI is currently green and this is ready for review

@aiAdrian aiAdrian linked an issue Oct 8, 2025 that may be closed by this pull request
3 tasks
@aiAdrian aiAdrian self-assigned this Oct 8, 2025
@aiAdrian aiAdrian added the enhancement New feature or request label Oct 8, 2025
…. To improve rendering performance, we’ve introduced a lookup cache that handles frequent access more efficiently.
@aiAdrian aiAdrian added this to the 2.10 milestone Oct 10, 2025
Copy link
Contributor

@shenriotpro shenriotpro left a comment

Choose a reason for hiding this comment

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

I can't say I understand the logic, but I love the result :)

@aiAdrian aiAdrian requested a review from shenriotpro October 10, 2025 14:42
@aiAdrian aiAdrian marked this pull request as draft November 19, 2025 15:08
@aiAdrian
Copy link
Contributor Author

There to many changes in sg6 - made every very bugy while rebasing. Thus i will make a new branch and merge the changes manually into. The reported bug is related to the bug we fixed

@aiAdrian
Copy link
Contributor Author

After extended testing with the latest version of Netzgrafik-Editor, I came to the conclusion that the additional complexity introduced is not justified. The expected performance gain could no longer be demonstrated in a significant way. Therefore, I propose not to merge this. Many thanks to all reviewers and contributors. I believe it is always worthwhile to weigh increased complexity against actual benefit. At this moment, I don’t think there is sufficient gain.

@aiAdrian aiAdrian closed this Nov 19, 2025
@aiAdrian aiAdrian deleted the 553-feature-request-graphical-timetable-streckengrafik-performance-optimisation branch November 19, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request]: Graphical Timetable (Streckengrafik) performance optimisation

5 participants