P2 L5: Thread Performance Considerations Flashcards
How do you calculate the average time to complete a task for the worker-boss threading model?
Total processing time = num_workers * time for first badge of tasks to complete + num_workers * * time for second badge of tasks to complete (this is + the time spent waiting for first batch to complete!)
–> then divide by number of tasks
How do you calculate the average time to complete a task for the pipeline threading model?
n/2 * (a(1) + a(n)). –> then divide by number of tasks
N is the amount of tasks.
a(1) is the time it takes for the first task to run through the whole pipeline.
a(n) is the time it take for the last thread (has to wait for all previous threads).
How do you calculate the execution time for the worker-boss threading model?
time_process_task * ceil(tasks / workers).
6 thread = 5 workers ONLY + 1 boss!
How do you calculate the execution time for the pipeline threading model?
- First task takes 6 * 20 = 120 ms
- then each consecutive task is finished 20 ms later!
Calculation: 120 + 20 * 10 = 320 ms
When do threads add pure overhead
2 * context_switch > processing time needed
-> e.g serving a very small file already cached in RAM
A program that has to run sequentially! (no concurrent design possible!)
Adding more threads than CPUs/cores when there is no I/O to be done (advantage of thread would be to wait till interrupt when I/O is done)
Why overall are threads useful (not metrics)
Parallelization => speed up
Specialization => hot cache
Efficiency => lower memory requirement (smaller PCP to context switch and copy). + cheaper synchronization (no need for IPC via message passing or shared memory)
Threads hide the latency of I/O operations!!
What is a performance metric
=> measurement standard
- measurable
- quantifiable
- for the system, we are interested in