Profiling:Added I/O profiling tooling#242
Profiling:Added I/O profiling tooling#242Labreo wants to merge 2 commits intoPecanProject:masterfrom
Conversation
|
This is interesting and useful information, in that it suggests that input is much less of a bottleneck than output (which makes sense). That said, I feel like #237 may have been misleading about what the underlying question is, which is more about how long job.sh spends on I/O than how much SIPNET does. In particular. Right now SIPNET writes out it's output to a text file, which model2netCDF.SIPNET reads in and writes back out as netCDF. Informal observations have suggested that the latter step takes just as much time, if not more, than actually running the model. It was proposed to profile this overall script to assess how much benifit we'll get if we modify SIPNET to natively output netCDF. It's hard to estimate a priori how much it will change SIPNET itself (in theory the write should be quicker, but we'd probably have to implement and test to be sure), but it would completely eliminate the subsequent R-based text read and netCDF write. |
|
This looks nice and provides the information I was looking for in 237. As far as what goes into this codebase and where it belongs i.e. reviewing your implementation, I'll defer to @Alomir. @mdietze thanks for clarifying where the bottleneck in the pecan workflow is. @Labreo with apologies for scope creep, I've updated #237 by adding another step:
If you would prefer to defer that step that is understandable - I can close 237 and split this into a separate issue. |
|
Sure @dlebauer that is something i can definitely do and provide the results of. |
4000929 to
ea3d75a
Compare
To be clear, I do not intend for this PR to be merged. I opened it primarily to share the methodology and reproduce the profiling results discussed in #237. (In hindsight, I should have opened this as a Draft PR apologies for the confusion). I couldn't run the full run.sh stack locally, so I created a simplified wrapper of the PEcAn model2netcdf.R file. This wrapper replicates the exact I/O logic (parsing headers, mapping columns, and writing the full standard set of NetCDF variables) to measure conversion latency.Also since i run have an apple environment and the docker container would use emulation it would put off the true profiling results instead of running it locally. Result: Result of profiling of model over 56 years: |
|
Any feedback on this? |
|
Since the two tests were of different lengths (16 vs 56 years) they're not directly comparable, but to a first approximation, I wanted to make sure I've got the following approximately right 56 yr costs All of this seems to support making #239 a higher priority -- post-hoc conversion seems to be ~2x as time consuming as the model itself, and the actual underlying model compute is a tiny fraction of the overall job.sh execution. |
Summary
tests/smoke/niwot/sipnet.climto the required data years till the amount of years is greater than target year(So if 10 is the target it will generate 16 years of date by duplicating by twice since sipnet.clim has 8 years).Modified
src/sipnet/sipnet.c: Added manual clock() timers wrapped in #ifdef PROFILING guards to measure Read, Compute, and Write phases without affecting production builds.Note:I didnt use gprof as i initially proposed since it was unreliable on my local development environment (Apple Silicon).
Results of profiling for 10 target years(16 years)
Conclusion:The program spends 89 percent of it's time either reading or writing.
How to test
Steps to reproduce and verify the change locally:
Related issues
Checklist
docs/CHANGELOG.mdupdated with noteworthy changesclang-format(rungit clang-formatif needed)For model structure changes:
\frakturfont formatting fromdocs/model-structure.mdfor implemented featuresNote: See CONTRIBUTING.md for additional guidance. This repository uses automated formatting checks; if the pre-commit hook blocks your commit, run
git clang-formatto format staged changes.