Xarray optimizations
Some of our xarray handling is taking a lot of the total simulation time in the minimal runs in benchmarking and profiling.
Potential optimization candidates:
-
to_xarray()
- Partially done in !222 (merged) (800 us -> 180 us)
- Further optimized in !223 (merged) and !224 (merged) (-> 90 us)
-
check()
(30%)- Partially done in !222 (merged) (500 us -> 170 us)
- Further optimized in !223 (merged) and !224 (merged) (-> 80 us)
- No call to
equivalent_units()
in !228 (merged) (-> 35 us)
-
get_time()
(12%) (>10% fromto_datetime()
)- Done in !222 (merged) (230 us -> 16 us)
-
assign_time()
(37%) (used in component)- Done in !222 (merged) (680 us -> 16 us with existing axis)
-
to_units()
- Done in !222 (merged) (320 us -> 12 us for no-op conversion)
-
equivalent_units()
(13%)- Partially done in !222 (merged) (150 us ->
10570 us) - Reduced number of calls in !228 (merged)
- Partially done in !222 (merged) (150 us ->
-
_get_pint_units()
(7%) -
is_quantified()
(7%) -
Component.logger
(5%) -> full name could be cached instead of repeatedly reconstructed,logging.getLogger()
also takes 3.6%
Further optimization ideas:
- Store units in info as pint objects instead of strings -> avoid re-constructing