Note that there are some explanatory texts on larger screens.

plurals
  1. POScalability issue with HashMap in Multithreaded Multicore system
    primarykey
    data
    text
    <p>I am facing scalability issue while reading data from hashmap. My machine has 32 core with 2 hyper thread per core (so total 64 cpus) and 64 GB RAM. When reading data from HashMap and doing arithmetic calculation I am seeing a performance dip from 16 thread onwards, but while doing only arithmetic operation it's scaling as per expectation.</p> <p>Please find the test result below:</p> <p>Reading from HashMap and performing arithematic operation:</p> <p>no of threads | Time Taken (seconds) => 1 | 85, 2 | 93, 4 | 124, 8 | 147, 16 | 644</p> <p>Performing only arithematic operations :</p> <p>no of threads | Time Taken (seconds) => 1 | 25, 2 | 32, 4 | 35, 8 | 41, 16 | 65, 32 | 108, 40 | 112, 64 | 117, 100 | 158</p> <p>Also adding the code block for reference :</p> <pre><code>import java.util.*; import java.util.concurrent.*; import java.lang.*; public class StringCallable2 { // private static final long size = 500000L; private static final long size = 1000000L; // private final static HashMap &lt;Long,Long&gt;map = new HashMap&lt;Long, Long&gt;(); // private static long[] array = new long[(int) size]; public static class StringGenCallable implements Callable { int count; public StringGenCallable(int count) { this.count = count; } public Long call() { //Random rand = new Random(); // System.out.println("Thread " + count + " started test"); long sum = 20; // do a CPU intensive arithmetic operation; no Input Output // operations, object creations or floating point arithmetic for (long i = 0; i &lt; size; i++) { //int numNoRange = rand.nextInt((int)(size-1)); //long numNoRange = i; // Long long1 = map.get((long)i); //Long long1 = array[(int)i]; sum = i + 19 * sum; } // System.out.println("Finished " + count); return sum; } } public static void main(String args[]) { try { System.out.println("Starting"); // for (long i = 0; i &lt; size; i++) // { //array[(int)i] = System.currentTimeMillis(); // map.put(i, System.currentTimeMillis()); // } int sizt = Integer.valueOf(args[0]); long curtime = System.currentTimeMillis(); ExecutorService pool = Executors.newFixedThreadPool(sizt); Set&lt;Future&lt;Integer&gt;&gt; set = new HashSet&lt;Future&lt;Integer&gt;&gt;(); for (int i = 0; i &lt; sizt; i++) { Callable&lt;Integer&gt; callable = new StringGenCallable(i); Future&lt;Integer&gt; future = pool.submit(callable); set.add(future); } long sum = 0; for (Future&lt;Integer&gt; future : set) { future.get(); } System.out.println("Number of threads : "+sizt); long finsihtime = System.currentTimeMillis(); System.out.println("Total Time Taken : " + (finsihtime - curtime)+" ms"); pool.shutdown(); // System.exit(sum); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } catch (Error e) { // TODO: handle exception e.printStackTrace(); } catch (Throwable e) { // TODO: handle exception e.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload