I have a server which creates a thread for each client's task. Every thread has the necessity of accessing the memory (DB). So, as the number of threads are increasing, the system performance is degrading and I suppose this is because of thrashing. In this situation, can I assume that rather than trying to run all the threads(whose requirement is the memory i/o) at a time (and thus lead to thrashing), I want to schedule them do run serially. So that I will not at least waste time on thrashing. I may have as many as some 1000 threads (requested by thousand clients) at a time. So pls do put your analysis and thoughts regarding how I can improve the system's throughput and what can be the feasible way of using threads in my situation. Thank you all in anticipation.
Asked
Active
Viewed 31 times
1 Answers
1
If they have to write the same memory, then no; you would have to serialize access, and there is nothing better to be done. But if they only need to read the same memory, then there is no reason that these cannot be parallelized. Furthermore, if you need to write objects that are nearby in memory but are distinct, you may end up getting poor performance because the cache line is being invalidated, but you can work around this by storing objects in a way that puts them in separate cache lines. Likewise, clever techniques to organizing and storing the data (or intentionally allowing reads to see stale data so that writes do not need to block other reads) can allow for concurrency benefits.

Michael Aaron Safyan
- 93,612
- 16
- 138
- 200
-
@Michel, what do you mean by the clever techniques. Suggest a few names. – Shashank Jul 10 '15 at 05:12
-
Pretty much any database that is "eventually consistent" ... look up BIgTable, Cassandra, NoSql, etc. Also, databases that are lock-free but strongly consistent are another example; read up on Spanner. – Michael Aaron Safyan Jul 10 '15 at 05:14
-
Will there be any little advantage if I use different databases to read from and write to(I think no - because all the different DB reside on the same memory)? What do you think? – Shashank Jul 10 '15 at 05:18
-
What do you mean by "the same memory"? The same memory chip can handle parallel reads and writes. It's only when talking about the same exact memory address or the same cache line that you have an issue. – Michael Aaron Safyan Jul 10 '15 at 05:31