
Mesquite Software Newsletter
Volume 7 - Fall 2007
Newsletter Contents
Introduction
We've Extended the Support "Synchronization" Special
Tech Tip - Optimizing CSIM Run-time
CSIM for Java Now Available for Online Purchase
Request a Free Electronic Evaluation Version of CSIM for Java
As the cold weather sets in, our thoughts turn towards the holidays and the new year… and of course how best to spend the cold winter days programming with CSIM! At least that's what we'll be doing for the rest of the year as we work on CSIM 20.
We're also excited that our founder, Dr. Herb Schwetman, has been chosen to be Co-Chair for the SimulationWorks industry track for the SIMUTools 2008 conference. SIMUTools 2008, to be held in Marseilles, France in March 2008, is the first international conference on simulation tools and techniques for communications, networks and systems.
The SimulationWorks track has issued a call for papers, and we invite you to submit your papers on simulations with CSIM 19 and CSIM for Java. Possible topics include, but are not limited to
- Applications of simulation
- Simulation-based optimization
- Cost/performance trade-offs
- Simulation-based systems design
We hope to see you in Marseilles!
As well, we're delighted to announce that CSIM for Java is now available for purchase online! In addition to CSIM for Java details, this Mesquite newsletter issue offers includes a Tech Tip on optimizing CSIM run-time performance and a special deal for users renewing their extended support.
Finally, we wish you and your family the very best of holidays!
We've Extended the Support "Synchronization" Special
Many companies that use CSIM have Extended Support contracts, purchased over time, that have differing expiration dates.
Several of our large customers have asked to combine all of their Extended Support contracts into a single contract with one expiration date. This structure minimizes paperwork for all, so we wanted to offer it to all of our customers who have more than one Extended Support contract.
From now until January 31st, if you renew all of your Extended Support contracts at once, we'll give you a 20% discount on all of them *and* pro-rate the time you have on any non-expired contracts. Next year, you'll only need to renew once!
Please contact Mesquite directly to take advantage of this special offer.
Tech Tip - Optimizing CSIM Run-time
by Dr. Herb Schwetman
Occasionally we receive questions from users on topics of interest to the CSIM community. CSIM's founder, Dr. Herb Schwetman, will answer select questions in this newsletter and by email. If you would like to submit a question for Herb, please email him at .
A question that I get from time to time is, "My model takes too much time; what can I do to make it run faster?" My answer to this can take several forms, as follows.
- Some models are complex, or operate at a very fine level of detailed events, or are inherently large, and just require a lot of time; there is not much that can be done to decrease the running time for these kinds of models.
- Sometimes, you can take steps to improve execution time, as follows:
- Make stack segments as short as possible - CSIM implements user-level threads and copies segments of the runtime stack as processes become active and then suspend. Making these stack segments as small as possible can reduce the running time of the model (see Note 1 below).
- Eliminate unnecessary context switches - As you can guess from the above point, process context switches are relatively expensive. Reduce the number of context switches to improve performance (see Note 2 below).
- Use the best possible algorithm - Many models use various algorithms to implement features of the model. As with all programs, using the best possible version of each of these algorithms (the version that minimizes run time) can radically improve performance. In most cases, using memory to reduce running time is the correct choice (the so-called space-time trade-off). Using an indexed array as opposed to searching is preferred (when this is possible), and using doubly linked lists can speed up inserting and removing elements from these lists.
-
Run for the minimum time to achieve the needed results - The length of simulated time
or the number of completed simulated tasks often determines the amount of time required to
execute the model. In some cases, models run longer than they need to run. In these
situations, careful analysis and/or using some of the features of CSIM (see steady-state
behavior below) can shorten the running time of the model while maintaining acceptable levels
of statistical accuracy. There are often two different criteria for determining the amount
of simulated time for the model:
- The model simulates a fixed amount of time (30 days of operation). In this case, it is fair to ask if this is necessary; would it be appropriate to simulate one week of operation and then extrapolate the results to one month?
- The model is being used to estimate steady-state behavior. In this case, the confidence interval feature coupled with the run_length feature in CSIM can often automatically determine the amount of simulated time (the number of simulated events) required to achieve a specified level of statistical accuracy. The User's Guides have information on these features.
- Use an optimized version of the CSIM library and/or the model - For Windows/MS Visual C/C++, there are two versions of the CSIM library: one is the Debug version and one is the Release version. You can select the Release version to optimize performance. There is warning for this: some of the optimizations that can be applied to your program can cause your CSIM program to not execute correctly or abort. In particular, it is important that stack frames be used (not omitted). You can select Custom optimization and then select a combination of optimizations that work for your program. For Linux/Unix systems, there is only one version of the CSIM library (the next version of CSIM will probably include an optimized version for these). You can compile the model with optimization, but again, there is the possibility that your model will not execute correctly with some optimizations.
So, these are some steps that can be taken to "make your model run faster".
Note 1 - Make stack segments as short as possible.
As an example of this point, consider a process as follows:
void proc()
{
double arr[5000];
create("proc");
…
}
In this example, the stack segment has 8x5000 = 40,000 bytes. This can be remedied in C++ as follows:
void proc()
{
double *arr;
create("proc");
arr = new double[5000];
…
delete arr;
}
In the modified form, the stack has a one word pointer to the array which is actually located on the heap. The delete is critical. The C version uses malloc and free. The routine name mdlstat() (see Note 2 below) can give additional information on the size of the stack segments.
Note 2 - Eliminate unnecessary context switches.
This one is more difficult to detect and correct. The CSIM routine named mldstat() gives a summary of the several factors involved in the execution of the model, as follows:
CSIM MODEL STATISTICS
CPU time used (sec): 3.703
Events processed: 3500071
Memory allocated: 13280 bytes
Calls to malloc: 60
Processes
Started: 1000002
Saved: 1833005
Terminated: 1000001
High water mark: 21
Stacks
Allocated: 1000002
High water mark: 606 words
Average: 28 words
Maximum: 29 words
Current: 28 words
In this report, the key numbers are the number of processes started and the number of processes saved. If the number saved is large compared to the number started, this could be a symptom of an excessive number of context switches.
CSIM for Java Now Available for Online Purchase
Now you can purchase CSIM for Java on the Mesquite website. CSIM for Java delivers the same features that have established the original CSIM package as the premier programmer's tool for C/C++-based discrete event simulations… with the addition of the cross-platform convenience and power of Java.
Learn more about CSIM for Java.
Complete set of CSIM for Java documentation.
Request a free Electronic Evaluation Version of CSIM for Java!
Have you been waiting to try out CSIM for Java? Now you can download a free evaluation version and don't have to wait for a CD! You can request a free evaluation copy online of both CSIM for Java and CSIM 19. Of course, if you prefer a CD, you always have that option.
Mesquite Software welcomes your questions, thoughts, and comments. Please drop us a note or give us a call!
Warm wishes for a happy and peaceful holiday season,

Nan Schwetman, President
Mesquite Software, Inc.
8500 North MOPAC, Suite 825
Austin, TX 78759, USA
Tel: (800) 538-9153 (US) or +1 (512) 338-9153
Fax: +1 (512) 338-4966
E-mail: nhs@mesquite.com
www: www.mesquite.com
This newsletter is sent to our user community and interested parties by Mesquite Software. You may subscribe by visiting: www.mesquite.com/newsletter/signup.html

