antarctica / PolarRoute

Long-distance maritime polar route planning, taking into account complex changing environmental conditions.
https://antarctica.github.io/PolarRoute/
MIT License
17 stars 3 forks source link

Refactor branch significantly slower than main #290

Closed hjabbot closed 3 months ago

hjabbot commented 3 months ago

The runtime of optimise_routes appears to be around 33% slower on 0.6.x as compared to main. With the waypoints file I've been using, 0.6.x takes ~2400 seconds to run, whereas main runs in ~1750 seconds.

Waypoints being tested

Possibly could be improved by the suggestions provided in #280

Ulvetanna commented 3 months ago

280 only refers to path smoothing fixes, not the Dijkstra path creation. Would be interesting to compare the compute time just for the dijkstra section of PolarRoute. Might be worth creating a cli update to compute just dijkstra paths and look at difference first 🙂

gecoombs commented 3 months ago

I ran an initial test using the waypoints and mesh I'd been looking at for Medhi's glider example. The first thing that I noticed in the profile for this case was the is_visited method of SourceWaypoint was taking up a huge chunk of time. I switched the list of visited_nodes for a set and that seems to have sped things up considerably (265s -> 167s). Can you try running again with latest version I've pushed @hjabbot? There are a few other things I might look at but it would be good to understand the effect of this particular change.

Initial profile from snakeviz: Screenshot from 2024-08-19 14-05-09

After change: Screenshot from 2024-08-19 15-19-55

hjabbot commented 3 months ago

That appears to have fixed it, now refactor sitting around 1850 seconds :+1: Nicely done