CS457 - System Performance Evaluation - Winter 2010
Public Service Announcements
- Assignment 1 office hours
- 15.00 to 17.00 Friday (today)
- 15.00 to 17.00 Monday
- DC3554.
- Assignment 2.
Lecture 16 - Discrete Event Simulation
Simulation
What is it?
Examples
Models
Model taxonomy
Common Model Contrasts
|
Continuous |
Discrete |
| Determinism |
Fully deterministic: possible
if input is a trace |
Details modelled probabilistically
Start with the same seed to get determinism |
State
|
Continuous
e.g. know that processing is
x% complete, which is necessary
for round robin scheduling |
Discrete: change system state
only when things start of end
(events) |
| Time |
Make time steps
as small as possible. |
Time moves forward discontinuously,
from event to event |
Model development
- You did this before
- Understand the system
- What is the goal?
- Determine the components
- e.g., server, job
- sometimes called `entities'
- have attributes, e.g.
- server: service capacity
- job: service required
- workload: interarrival time
- Cheat and steal
- There must be some reason for lying as well.
- Select the type of queueing model
- single server queue,
- single service facility with multiple servers,
- network of queues
- Specify attributes that need algorithms
- e.g., scheduling disciplines for resources
- Specify workload parameters and performance metrics
- remember (guess what?) the goal
- You should now be able to specify
- the state of the system: queues & servers
- events that change the state
- algorithms that change state when events occur
Example. Routing for automated telephone support
- single server, two classes of request (maybe two different products
being supported)
- queueing models have a scheduling algorithm, such as
- FCFS
- priority-based FCFS
- round robin, aka take turns
- each has a natural structure
- FCFS: single queue
- priority-based: multiple queues
- round-robin: multiple queues
- with multiple classes
- arrival rate adds: r = r1 + r2
- interarrival time adds reciprocals: t = 1/r = 1/(r1 + r2 ) =
1/(1/t1 + 1/t2) = t1*t2 / (t1 + t2)
or 1/t = 1/t1 + 1/t2
- Parameters
- interarrival time: per class
- length of transaction: per class
- service capacity: per class
- queueing algorithm
- Performance metrics
- waiting time: per class
This is used to determine the cycle time of the advertising you
listen to. Just joking!
- utilization
No point in hiring any more support staff than you need.
For a more CS-like example see this pdf.
Structure of Software for Discrete Event Simulation
Two possible approaches
- Follow a request (job) through the system
- Global time with OS-like scheduling
- Local time with
sleep( )
- Event-scheduling approach
Event Scheduling
- Events
- occurrences that will change the state of a system
- happen at a specific time
- Event set - queue of events, which means
- ordered
- pointer to next event after now
- simulation time kept in a clock variable
updated to event time each time a new event occurs
Two important operations
- Remove the earliest event from now.
- Insert an event.
These will be done equally often (Why?)
- Two key assumptions
- Events are defined so that the system never changes state without
an event occurring.
- Events can schedule other events, but never in the past.
This is called causality.
- Defining system state is the most important aspect of abstraction.
Event Scheduling Program
//* marks parts that do not vary from program to program
Highest Level Description
Initialize( ); //*
while ( ( event = event-set.dequeue( ) ) ) != nil ) { //*
clock.time = event.time; //*
process-event( event ); //*
}
log.terminate( ); //*
Initialization
Initialize( ){
clock.init( ); //*
state.init( ); //*
event-set.init( ); //*
log.init( ); //*
}
Event Processing
process-event( event ){
log.update( /* Whatever */ ); //*
state.update( event ); //*
// Possibly test for termination
}
Server with One Queue
Response variables
Parameters = Factors
- Interarrival times
- Service times
Assumptions
- Some things are independent of everything else
- interarrival times
- service times
- FCFS scheduling
- System starts empty
- Infinite population (open model)
State variuables
- n - number of jobs in the queue
- status - server busy or idle
Initialization
clock.init( ) { time = 0 } //*
state.init( ) { n = 0; status = IDLE }
log.init( ) { /* open standard output */ }
event-state.init( ) { event-set.insert( new-event( ARRIVAL, clock.time( ) ) ) }
State & Event-set Manipulation
state.update( event ) {
switch( event.type ) {
case ARRIVAL:
event-set.insert( new-event( ARRIVAL, event.time ) );
n++; queue.insert( event );
if( status == IDLE ) start_service( );
return;
case DEPARTURE:
status = IDLE;
if ( --n ) start_service( );
return;
}
}
Utility routines
event new-event( type, time ) {
this.type = type;
switch( type ) {
case ARRIVAL:
this.time = time + event.arrival-time( );
return this;
case DEPARTURE:
this.time = time + event.service-time( );
return this;
}
}
start-service( event ) {
log.update( /* Whatever */ );
job = queue.next( );
state.status = BUSY;
event-set.insert( new-event( DEPARTURE, event.time ) )
}
Left as exercises for the reader
- Trace through the samples and make certain that it all goes as you
expect.
- Find out the slightly different termination condition than the example
in the notes.
- Think about what should go in all the updates of the log.
Important.
- Remember that events must be conserved.
- For every new arrival event there must be a new departure event.
Return to: