inducer / pymbolic

A simple package to do symbolic math (focus on code gen and DSLs)
http://mathema.tician.de/software/pymbolic
Other
107 stars 25 forks source link

get_cache_key: replace sorted() with immutable Map #133

Closed matthiasdiener closed 1 year ago

matthiasdiener commented 1 year ago

sorted() is currently the function with the highest impact on compile performance in a mirgecom-y3prediction rhs compile on M1 (i.e., it is the top entry in cProfile when sorting by tottime, just above islpy's casting wrapper). This PR reduces the number of calls to sorted by 80%.

Other options might be:

inducer commented 1 year ago

Wait... this change reduces compile time by 80%?

matthiasdiener commented 1 year ago

Wait... this change reduces compile time by 80%?

No, it reduces the number of calls to sorted by 80% (7.5 million to 1 Million). Overall compile time is improved by ~5%.

inducer commented 1 year ago

Sounds good. Every little bit helps! :slightly_smiling_face:

inducer commented 1 year ago

(And thanks!)

inducer commented 1 year ago

One additional item is that, in many situations, there won't be a **kwargs component to deal with, and @optimize_mapper could specialize that away. For expensive mappers, this may be a good idea.