Skip to content
Permalink
Browse files

Avoid saving program.dat if we are about to run another chunk anyway.

Reverts this aspect of behavior to that prior to the fix of JENKINS-25623.
Also logging time spent saving.
  • Loading branch information...
jglick committed Dec 6, 2016
1 parent bea88ca commit 22fa38ac38ea8fd61c9b615779f5b793cd381214
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java
@@ -355,7 +355,7 @@ private boolean run() {
}
}

if (changed) {
if (changed && !stillRunnable) {
try {
saveProgram();
} catch (IOException x) {
@@ -420,6 +420,9 @@ void saveProgram() throws IOException {

@CpsVmThreadOnly
public void saveProgram(File f) throws IOException {
boolean logging = LOGGER.isLoggable(Level.FINER);
long start = logging ? System.nanoTime() : 0;

File dir = f.getParentFile();
File tmpFile = File.createTempFile("atomic",null, dir);

@@ -452,6 +455,11 @@ public void saveProgram(File f) throws IOException {
PROGRAM_STATE_SERIALIZATION.set(old);
Util.deleteFile(tmpFile);
}

if (logging) {
long end = System.nanoTime();
LOGGER.log(FINER, "saved {0} of size {1}Kb in {2}ms", new Object[] {f, f.length() / 1000, (end - start) / 1000 / 1000});
}
}

/**

0 comments on commit 22fa38a

Please sign in to comment.
You can’t perform that action at this time.