#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2005
    Posts
    9
    Rep Power
    0

    Keep jvm virtual machine running


    Hi,
    Apologises if this is a naive question...

    I've coded a mathematical model in java and compiled it as a jar file. The program takes some arguments (the model parameters) and produces some output (the model results). I need to compute the model for many many sets of parameters, and each realisation of the model takes only a few seconds. To loop through the parameter space, I've written a bash script that looks like:

    Code:
    for PARAMS in SET_OF_PARAMS
         do
         java -jar myjarfile.jar PARAMS
    done
    This script works fine, but is frustratingly slow. I think that more time is spent loading java (the jvm I suppose) that actually computing the model. Is there anyway I can keep the jvm loaded, preferably with the jar file also loaded, and then just keep restarting the program with the new parameters?

    I'm running OSX 10.4.9 with java 1.5.0_07.

    Thanks in advance.
  2. #2
  3. AYBABTU
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Here or There
    Posts
    1,256
    Rep Power
    380
    Why don't you put your many, many sets of parameters in a single file? When you start your java program you can read this file and loop through the parametersets inside your program. That way you can do it all in one JVM session.

    Comments on this post

    • Yawmark agrees
    A common mistake people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
    Douglas Adams
  4. #3
  5. No Profile Picture
    rebel with a cause
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2004
    Location
    The Batsh!t Crazy State.
    Posts
    5,814
    Rep Power
    3466
    Originally Posted by wsa1971
    Why don't you put your many, many sets of parameters in a single file? When you start your java program you can read this file and loop through the parametersets inside your program. That way you can do it all in one JVM session.
    What like a properties file?
    Dear God. What is it like in your funny little brains? It must be so boring.
  6. #4
  7. AYBABTU
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Here or There
    Posts
    1,256
    Rep Power
    380
    Originally Posted by crownjewel82
    Any structured file will do. To name a few: csv, xml or even Excel. My guess is the OP has the parameters in some sort of csv format already, so maybe that's the way to go for him/her.
    A common mistake people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
    Douglas Adams
  8. #5
  9. No Profile Picture
    rebel with a cause
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2004
    Location
    The Batsh!t Crazy State.
    Posts
    5,814
    Rep Power
    3466
    I just like properties files because they're fairly easy to create, load and use.
    Dear God. What is it like in your funny little brains? It must be so boring.
  10. #6
  11. AYBABTU
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Here or There
    Posts
    1,256
    Rep Power
    380
    Originally Posted by crownjewel82
    I just like properties files because they're fairly easy to create, load and use.
    Yes they are. But the OP probably already has the parameters in csv format. Might turn out to be quite some work to convert this to a properties file.
    A common mistake people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
    Douglas Adams
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2005
    Posts
    9
    Rep Power
    0
    Hi all,
    Thanks for the replies. Yes, its a sensible suggestion; I should have a single instance of the program read each set of parameters from an input file.

    I suppose my question was just laziness; rather than having to do some java coding to make a file parser, I wondered if the virtual machine could save me the bother. But I'll get coding...!

    Best wishes,
    complextt
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2006
    Location
    Victoria, Australia
    Posts
    458
    Rep Power
    88
    Or you could recode the program to keep running once its finished a model, and have it wait for either A) A new set of params to process B) an exit command

IMN logo majestic logo threadwatch logo seochat tools logo