CST stage always regenerates all files

Create issue
Issue #2051 closed
Erik Schnetter created an issue

I notice that since recently, the Cactus CST stage always regenerates all files, which means that any change to a ccl file or the thorn list will recompile all source files, which is very slow.

I find that this patch resolves the problem:

$ git diff CSTUtils.pl
diff --git a/lib/sbin/CSTUtils.pl b/lib/sbin/CSTUtils.pl
index 532f6a77..209b9352 100644
--- a/lib/sbin/CSTUtils.pl
+++ b/lib/sbin/CSTUtils.pl
@@ -182,8 +182,8 @@ sub WriteFile
   if (-e $filename)
     # only read the file if it its size equals the length of the rdata string
-    my @fileinfo = stat ($filename);
-    if ($fileinfo[7] == length ($$rdata))
+    my $filesize = -s $filename;
+    if ($filesize == length ($$rdata))
       open(IN, "< $filename");
       $data_in = join ('', <IN>);

Apparently, something fishy is happening when calling stat.


Comments (8)

  1. Steven R. Brandt
    • removed comment

    This change should be harmless, however, I can't see why these two methods of determining a file size should be different. They return the same number everywhere I've tested it. Where are you seeing this problem?

  2. Erik Schnetter reporter
    • removed comment

    I see this problem on my laptop as well as on Stampede2.

    The expression @fileinfo returns a value that prints as File::Stat=0xabcd0123 instead of as a Perl array. The resulting comparison with $fileinfo[7] is then always false.

    This is Perl 5.24.1.

  3. Erik Schnetter reporter
    • removed comment

    If there is a bug, then it must be a non-local consequence of changes elsewhere, maybe a Perl import statement or function definition that changes how `stat}} works here.

  4. Log in to comment