abstreet icon indicating copy to clipboard operation
abstreet copied to clipboard

Stop serializing turns. Generate them after loading the map. #746

Open dabreegster opened this issue 2 years ago • 2 comments

Turns can be generated from other data, so we can save space by not serializing them. Does it help?

  • huge_seattle, release mode, native
    • before: 258MB, 11.8s to load in UI (read the file, create DrawMap)
    • after: 218MB, 10.1s
  • central_seattle, debug mode, native
    • before: 54MB, 25.6s total
    • after: 43MB, 23.4s total
    • just deserializing the file drops from 8.4s to 6s
    • almost 1s spent reconstructing the turns

I'm now measuring on web. No parallelism there, so regenerating turns might be much slower.

Also need to silence the warnings when we generate turns; it's quite a spammy experience to just load a map.

dabreegster avatar Oct 21 '21 19:10 dabreegster

10% speed-up pretty impressive. Great work on diagnosing these areas where efficiency gains can be found!

Robinlovelace avatar Oct 21 '21 20:10 Robinlovelace

Awww, this is a no-go for now. Creating turns serially on web is too slow.

  • central_seattle: 4.2s before, 5s after
  • huge_seattle: 12s before, 16.8s after

If there's an easy way to use web workers, we could try subbing it in https://github.com/a-b-street/abstreet/blob/151ec7b167972363e3b662e783f278c56ec5d67d/abstutil/src/time.rs#L344. Looks like some crates require nightly rust: https://crates.io/crates/wasm-futures-executor, https://crates.io/crates/wasm-mt, https://crates.io/crates/wasm-bindgen-rayon. I think some of the approaches require browser support for modules in web workers or shared memory that isn't widely available: https://crates.io/crates/web_worker, https://crates.io/crates/wasm_thread. So... probably blocked.

dabreegster avatar Oct 21 '21 22:10 dabreegster