perf: router wastes most of its runtime on creating debug strings which are not used in production
Closed this issue · 3 comments
The spanner router wastes most of its runtime on creating debug strings which are not used in production.
Explanation
As you can see here, the strings are always created even if the devlog is not printed. Besides this unneccesary string concatenation happening there, the equatable package used for the nodes makes this even slower since it is inherrently inperformant.
You can see this in the dart observatory output:
If you look at the Spanner specific benchmark I was testing, you can see how most of the time is spent either in the EquatableMixin, String concation and other debug related stuff.
Fixing this
- Just make the debug method use a function instead of finished strings (Still not optimal)
- Put the stuff in assert trap lambas ("In production code, assertions are ignored, and the arguments to assert aren’t evaluated.")
assert(() {
//you can execute debug-specific codes here
return true;
}());
- Just remove them
- Add a second tree that has debug output
@helightdev Could you provide a repo to this benchmark? I've never really had time to do in-depth benchmark on Spanner. Prolly worth dedicating a weekend to nailing perf issues.
Thanks alot @helightdev