Improve dependency file generation - #1815
Conversation
|
Hi @danrosen25 I see your point, and I reverted my changes. I wonder if it is worth changing the compile script to check if any .d files exist, and if not, call 'make depend' before calling 'make -f Makefile $njobs'. That would avoid use of that shell function, though it could be kept as a fail-safe. |
|
@emkemp That would work. The only caveat I can see is that the logic here specifically checks for any of the .d files listed in $(DEPS). So if there is a |
|
Hi @danrosen25 I want to discuss this with @jvgeiger before making a final decision on this. But my thinking is that, if no .d files are available, it's probably safest to just do a complete rebuild from scratch. |
danrosen25
left a comment
There was a problem hiding this comment.
@emkemp
I'm suggesting the following changes to the compile script for POSIX-shell compatibility. Do these work for you? The old changes were causing an error.
|
@danrosen25 I like your suggestions, and committed them to the PR. |
|
Regarding "Generate all dependencies files together if first time compiling", I believe that this is not needed. You can run the Would you please make case folding opt-in instead of default? The |
|
@jvgeiger The reason I even started this work is because I know it's not a high priority to run on Mac OS systems but I can't even run in a container on a Mac OS system if the volume from the Mac OS system is bind mounted into the container, which is how Dev Containers work. I'm looking to enhance the development portability so that development and testing don't have to happen on a small set of HPCs. |
|
Just to be clear, I like your changes to Yes, we only support Unix/Linux systems with case-sensitive file systems, but I understand your need to support a case-insensive file system. I ask that you make the case folding opt-in because I cannot control the development of third-party models that we incorporate into LIS. I like the performance improvements in By the way, you can combine the |
|
@jvgeiger Okay, I'll have to make some makedep.py changes to make it more efficient in the single dependency generation case if that's going to be the default. What I'll do when there is a single file is call Path(d).glob('.f90|.F90') for the directory of the current file and search for the module then Path(d).glob('.f90|.F90') for other directories. Path(d).glob is slow but supports case-insensitive file systems. The performance improvements in this PR come from calling glob as few times as possible. The code I'm replacing called os.path.isfile followed by glob.glob for each module search in each directory. |
|
Hello Dan, I apologize for my confusion. I do not understand your response. Please correct me where I am wrong. To me, your changes to Is |
|
@jvgeiger
If you're running makedep.py for a single file then you'd want to sort the directories by most likely and run Path.glob() then check the files in that directory then run Path.glob() on the next directory. This reduces the Path.glob calls depending on where it finds the module. os.path.isfile(), which is what is being replaced because it can't handle case insensitive file systems, takes 0.00005 seconds. Although os.path.isfile was only finding files sometimes and then it would go to .glob afterwards. |
* search for module in most likely directories first * search for module by matching filename first * cache f90 files for each searched directory * cache previously found module locations * fixex issue generating dependencies on case insensitive file systems
|
@emkemp @jvgeiger I started over in 14fb62a and I built a file search cache and a module search cache system. There's also a directory search ordering system. The first time through it will search files matching the module name in the core directory files followed by each parent directory of the current file being processed, then all other directories. Then it will search files not matching the module name in the core directory files followed by each parent directory of the current file being processed, then all other directories. There's no performance advantage until you start caching, which happens with Let me know your thoughts and I can move this from draft to ready. Dependency generation time and compile times noted in details. |
* improve directory sorting for finding modules
|
@emkemp @jvgeiger And remember that the primary purpose is to support case insensitive file systems but in order to do so I needed to speed up the performance of dependency generation so that it didn't quadruple in time. As a benefit |
Description
Fixes issue generating fortran file dependencies on case-insensitive file systems.
In the existing code the os.path.isfile(filename) will return true when filename doesn't match the case on the file system. This causes a problem later on because the dependency in the .d file doesn't match the case on the file system.
The old code also makes up to
(number of files) * (each modules in a file) * (each search dirs) * ((files in each search dir) + 4)calls to search for module definitions. The new code reduces this through caching and ordering the search directories. The performance enhancement is needed because Path(search directory).glob("*.[fF]90") is much slower than the previous os.path.isfile call.Resolves #1814
Change Log
Performance Comparison
Testcase
Tested on Discover using lisf_7.5_intel_2023.2.1_s2s with the following user.cfg settings