[Swift-commit] r4463 - in SwiftApps/SwiftR/Swift: R exec

tga at ci.uchicago.edu tga at ci.uchicago.edu
Tue May 10 11:31:36 CDT 2011


Author: tga
Date: 2011-05-10 11:31:36 -0500 (Tue, 10 May 2011)
New Revision: 4463

Modified:
   SwiftApps/SwiftR/Swift/R/Apply.R
   SwiftApps/SwiftR/Swift/exec/rserver.swift
   SwiftApps/SwiftR/Swift/exec/start-swift
Log:
Refactored so that there is a response fifo created per request, to enable concurrent apply calls.  Need to work out what is still preventing concurrent requests.


Modified: SwiftApps/SwiftR/Swift/R/Apply.R
===================================================================
--- SwiftApps/SwiftR/Swift/R/Apply.R	2011-05-09 19:41:27 UTC (rev 4462)
+++ SwiftApps/SwiftR/Swift/R/Apply.R	2011-05-10 16:31:36 UTC (rev 4463)
@@ -98,7 +98,7 @@
     swiftServerDir = getWorkerDir(server) 
 
     requestPipeName=file.path(swiftServerDir,"requestpipe")
-    resultPipeName=file.path(swiftServerDir,"resultpipe")
+    resultPipeName=file.path(reqdir,"resultpipe")
     # Try sending: this function will cause error if it fails
     sendServiceRequest(requestPipeName, reqdir, server, timeout=timeout)
     
@@ -209,6 +209,9 @@
   options(.swift.requestid=requestid)
   reqdir = file.path(requestdirbase, sprintf("R%.7d",requestid))
   dir.create(reqdir,recursive=TRUE,showWarnings=FALSE,mode=kDIR_MODE)
+
+  # Create a fifo that we can block on to get a response
+  system(paste("mkfifo", shQuote(file.path(reqdir, "resultpipe"))))
   
   return (reqdir)
 }

Modified: SwiftApps/SwiftR/Swift/exec/rserver.swift
===================================================================
--- SwiftApps/SwiftR/Swift/exec/rserver.swift	2011-05-09 19:41:27 UTC (rev 4462)
+++ SwiftApps/SwiftR/Swift/exec/rserver.swift	2011-05-10 16:31:36 UTC (rev 4463)
@@ -14,17 +14,19 @@
             stdout=@stout stderr=@sterr;
 }
 
-app ack (external e[])
-{
-#  bash "-c" "echo SIGNAL DONE >/dev/tty; echo done > /tmp/SwiftR/swiftserver/resultpipe";
-   bashlocal "-c" @strcat("echo done > ",resultPipeName);
-}
-
 app passivate ()
 {
   bash "-c" "echo dummy swift job;";
 }
 
+process_async(string runDir) {
+  external wait[];
+  wait = apply(runDir);
+
+  string resultPipeName = @strcat(runDir,"/resultpipe");
+  fprintf(resultPipeName, "%kdone\n", wait);
+}
+
 (external e[]) apply (string runDir)
 {
   RData rcalls[]  <simple_mapper; location=runDir, prefix="cbatch.", suffix=".Rdata", padding=0>;
@@ -48,29 +50,16 @@
 
 string pipedir = @arg("pipedir");
 global string requestPipeName = @strcat(pipedir,"/requestpipe");
-global string resultPipeName = @strcat(pipedir,"/resultpipe");
 
 iterate serially {
   boolean done;
   string dir;
 
-  # FIXME: read swiftserver dir via @args
   trace("top of loop: rserver waiting for input on", requestPipeName);
   dir = readData(requestPipeName); # Reads direct from this local pipe. Assumes Swift started in right dir.
+  if (dir=="done") { done=true; } else { done=false;}
   trace("rserver: got dir", dir);
 
-  external wait[];
-  wait = apply(dir);
-
-  if (dir=="done") { done=true; } else { done=false;}
-
-  #  file f<"/tmp/SwiftR/swiftserver/resultpipe">;
-  #  f = writeData("completed\n");  # Doesnt work: runs as soon as the block is entered.
-  #  want: tracef("%k completed\n", "my/responsepipe.fifo", wait);
-  #  %k waits for wait to be fully closed; then sends formatted string to specified file(doing open, write, close).
-
-  // ack(wait);
-
-  fprintf(resultPipeName, "%kdone\n", wait);
-
+  # fork off thread
+  process_async(dir);
 } until (done);

Modified: SwiftApps/SwiftR/Swift/exec/start-swift
===================================================================
--- SwiftApps/SwiftR/Swift/exec/start-swift	2011-05-09 19:41:27 UTC (rev 4462)
+++ SwiftApps/SwiftR/Swift/exec/start-swift	2011-05-10 16:31:36 UTC (rev 4463)
@@ -617,8 +617,7 @@
 # needed, and to copy in the R prelude for the R server processes (to
 # include for example the OpenMx library)  NOTE: Both were done in older version of this script.
 
-# rm -f requestpipe resultpipe
-mkfifo requestpipe resultpipe
+mkfifo requestpipe 
 
 out=swift.stdouterr
 touch $out
@@ -766,7 +765,8 @@
         echo "Turn on keep work option to retain logs"
     fi
 
-    (   echo "error: swift exited unexpectedly with return code $exitcode" > resultpipe &
+    # TODO: resultpipe used togo somewhere need to handle some other way
+    (   echo "error: swift exited unexpectedly with return code $exitcode" > swift.error &
         echopid=$!
         sleep 5
         kill $echopid 




More information about the Swift-commit mailing list