-
Notifications
You must be signed in to change notification settings - Fork 395
Lazy initialization of subcommands #1956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@adamsitnik could say more about whether this was a performance issue. I suspect it's not a bottleneck at this point. That said, lazy initialization is used in |
Our startup scenario (https://github.com/adamsitnik/commandline-perf/tree/update) is mostly dominated by JITing and type loading (I've verified that with a profiler). If we take a look at the following benchmark results we can see that:
That is why I've been pushing so hard on removing all redundant types. I don't expect us to gain a lot by making more things lazy. Our next perf goal is to include a precompiled version of S.CL in .NET SDK, so everybody would use a pre-compiled version out of the box. Having said that, I am going to close the issue. Thank you for your feedback @KalleOlaviNiemitalo ! |
The benchmark apps don't have any subcommands, do they? So they don't show how much time would be spent constructing the subcommands and their options and arguments. The descriptions of options and arguments are not localised either so the benchmark does not include a resource lookup cost that could be skipped when a different subcommand is used, or when help is not requested. |
All the major allocations were already removed and those which remained are lazy (collections are allocated when needed, not up-front).
The resource lookup should be cheap. @KalleOlaviNiemitalo I encourage you to take one of your real life apps and profile it and share the findings. I always happy to improve perf, I just don't believe that the parts that you have mentioned are major perf bottlenecks. |
Is there a way to save startup time by not initializing subcommands other than the one chosen by the user? The parser surely needs the name and aliases of every subcommand, but I hope the following could be skipped:
OTOH, I have not measured how much time these actually cost.
Might help with #1008 as well.
The text was updated successfully, but these errors were encountered: