Skip to content

Xarray optimizations

Martin Lange requested to merge xarray-optimization into main

Brings the baseline runtime for the most simple (single link) 365-days simulation from 850 ms to 180 ms (no unit conversion) / from 870 ms to 430 ms (with unit conversion).

Push&pull with numpy data goes from 2 ms to 1.4 ms, for xarray data from 2 ms to 0.37 ms.

  • Avoid conversion in to_units() if not reqiured
    • No-op from 400us to 16us
  • Assign time in assign_time() inplace if axis exists
    • From 800us to 25us
    • From 37% of simple run to 3%
    • Breaks indexing with time values via xdata.loc[t]
      • Will leave as is for now, as we don't use indexing anywhere, and make an issue for it.
  • Add a simplified implementation for to_datetime, without all the overhead
    • From 260us to 25us
    • From 20% of simple run to 3%
Edited by Martin Lange

Merge request reports