Need to make this better, and then split out remaining items into additional TODOs
P1: The interactive workflow is too slow. The following 10 rotation chain takes 4.8 seconds to generate
2.9 seconds is rendering template, of which 2 seconds is calling black (lol), .8 seconds is calling string join inside of the template, and a small fraction is actually rendering
We’re calling black.format_str 38 times. we should probably disable this for interactive use - flag in the language args of codegen?
I made an option to LanguageArgs to not autoformat. Perhaps controversial, but I’d propose to turn it off for the python Factor by default.
Now str join is taking all the time of render template. What’s up with that?
Why 38 times? We have 19 factors, so must be twice per factor.
What’s the second python file per factor? An __init__.py file from symforce/symforce/codegen/python_templates/function/__init__.py.jinja. Gross.
All prior and between factors should be the same expression. Can we only generate two?
2 seconds is in codegen_util.print_code. Seems like a lot of subs operations and list comprehensions, as well as some time in the sympy printer tree. Probably lots to optimize.
A ton of time is being spent in subs in codegen_util.perform_cse, basically all initialization._get_subs_dict → _flatten_storage_type_subs → mostly python_util.scalar_like. We should work on reducing the calls to these or making them faster.
Need to make this better, and then split out remaining items into additional TODOs
P1: The interactive workflow is too slow. The following 10 rotation chain takes 4.8 seconds to generate
2.9 seconds is rendering template, of which 2 seconds is calling black (lol), .8 seconds is calling string join inside of the template, and a small fraction is actually rendering
__init__.py
file fromsymforce/symforce/codegen/python_templates/function/__init__.py.jinja
. Gross.codegen_util.perform_cse
, basically allinitialization._get_subs_dict
→_flatten_storage_type_subs
→ mostlypython_util.scalar_like
. We should work on reducing the calls to these or making them faster.