-
Notifications
You must be signed in to change notification settings - Fork 197
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
Improve CLI runtime? #3835
Comments
This might be due to grepping for the ruby gems on startup. We may be able to change this behavior and not look at the gems on load. |
Just tried the latest v3.0 beta build (OpenStudio-3.0.0-beta+644272d34e) and I'm seeing similar times on Windows (roughly 1.5 seconds). |
@kbenne suggested that I try commenting out these init statements: https://github.com/NREL/OpenStudio/blob/develop/src/cli/main.cpp#L221 Here's what happens when I comment out the first one and rebuild:
|
So, commenting out the @kbenne Any other ideas? |
I timed how long it takes to get through all the
|
Large factors:
@kbenne suggested to:
|
@lefticus I assigned this to you and sent you another email with a few more details concerning this. |
After a478258 time on my Linux box is: |
Windows best of 10 runs: 29% faster for Windows, 35% Linux |
Tested with LTO - no difference in load times (but much smaller memory footprint possible) The remaining work is mostly internal to SWIG and Ruby, and it is the registration of the 10's of thousands of functions we have. It is theoretically possible to set up lazy loading of the OpenStudio modules (everything after OpenStudio core/utilities). But it does not seem to me this would make any practical difference. That is, any meaningful use of openstudio_cli is going to want OpenStudioModel, which is by far the largest part of OpenStudio. If we lazy load OpenStudioModel, but it's always needed, then nothing has been gained. Re: @tijcolem @joseph-robertson Is the current ~30% improvement good? Do you think lazy loading of OpenStudioModel would have practical benefit? |
@lefticus do you have evidence from the profiler that most of the init time is related to OpenStudioModel? We are also initing a lot of extensions from the ruby standard library as well as a number of gems. I'm not disagreeing that Model is probably the biggest culprit, but it might be wise to quantify our suspicions. |
Yes, if I disable the model only the times go all the way down to something like .28s. It's by far the bulk of the work (and the profiler agrees). The reason you were seeing the load times increase for more embedded gems came down the all of the file string copies increasing as well. |
@lefticus Are you running it with the I feel like @joseph-robertson looked at this at one point and found a fairly significant amount of time spent in the ruby gem handling code. Not sure if he still has the numbers. |
If we take @lefticus data as truth. Are there use cases that would justify selectively disabling the the OpenStudio Model with a cli flag? Can we lazy load the model? |
what am I saying of course we can lazy the load openstudio. We have reimplemented |
This is really interesting. I just realized that we have situations where we use the OpenStudio CLI but don't do anything with the OS Model. We basically just use the CLI as a ruby processor. If it's easy to avoid loading the OpenStudio Model under these situations, I'd be very much in favor of that. Edit: And indeed we don't call |
" And indeed we don't call require 'openstudio' in these cases." I wouldn't expect that you require openstudio if you aren't using the openstudio api. but what about people who are using the openstudio api but forgot the require? Maybe those people don't exist. or if they do maybe it is ok to break their code |
We can use module autoload capability to load Openstudio when it's first used. There will be a few moving parts.
It should be stable, and doable, but will take some testing to make sure we don't break the various workflows used for openstudio/ruby. @shorowit I show ~0.2% perf difference between |
go forth @lefticus and make it so if you are able. |
@kbenne I'll give it a shot. |
* Module.autoload is used to load openstudio_init_extended.rb * Any access to any of the OpenStudio:: sub-namespaces triggers this load On test system "puts 'Hello World'" test decreases from .53s to .33s Addresses #3835
The CLI runtime takes ~1.5 seconds to run on Windows and ~1 second to run on Linux, using this command:
openstudio --no-ssl -e "puts 'hello'"
Without the
--no-ssl
argument, it's ~2.5 seconds on Windows (Linux is unchanged, still ~1 second).In some of our residential workflows on Windows, we have to call the CLI twice sequentially, which results in ~3 seconds of runtime for the CLI out of a total workflow runtime of ~10 seconds (which includes applying OS measures and running EnergyPlus). This is a significant percentage. We are trying very hard to reduce our workflow runtime as much as possible.
Can we profile the CLI to look for any obvious performance hot spots?
The text was updated successfully, but these errors were encountered: