Debug Window in RenderPipelines.Core takes four seconds on reload due to ... input registering?

I’ve noticed slowdown when compiling script changes and finally got annoyed enough to investigate it. Turns out that there’s an O(n^2) (or something similarly bad, I’m not good with big O) lurking; nearly two seconds of the compile time is spent doing basically nothing inside the RenderPipelines debug window code.

I have Rewired in my project, and if you know Rewired, you know that it adds 500+ input axes to the manager. Every time the assemblies are reloaded, the debug window attempts to add several axes to the input manager:

6896489--806978--upload_2021-3-3_1-0-18.png

For every one of these axes it scans the entire input array via SerializedProperty calls, resulting in severely degrading performance as the number of axes in the manager increases. I’m using 7.3.1 in 2019.4, but I verified that the offending code is still present up to at least 10.2. It’s in the InputRegistering class and is called by DebugWindow’s [DidReloadScripts] callback.

This is exacerbated by AssetDatabase V2, as it reloads the assemblies both before and after compilation – for some reason – meaning that this actually becomes a 4 second penalty. (Is there a way for that not to happen, by the way? I don’t understand the necessity to reload the assembly and then immediately throw it away to recompile.)

I’ve attached the logs gathered by the Iteration Profiler for reference.

6896489–806993–rpc_trace.zip (3.83 MB)

I have worked around this issue temporarily by moving the axes to the front of the list, which drops the time cost down to a mere 15ms.