We already looked at how algorithm and data structure choice can significantly impact performance and scalability. Besides this, other programming source of bottlenecks are as follows:
- Locks: There is no fun in having multiple threads doing something in parallel, only to take a lock and serialize themselves. Consistency is must in a thread-safe application, but you need to consider the granularity of the lock made. A common source of error is making the critical section (the part of code under the lock) too fat; not everything needs to be done with the lock taken.
- Deadlocks: In a multithreaded application, if threads need more than one resource to do the work, getting into deadlocks is a real possibility. Deadlocks can also happen ...