Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Adjust cache line size #1

Open
wants to merge 1 commit into from

3 participants

Pinku Surana Cliff Moon Dietrich Featherston
Pinku Surana

A cache line size is 64 byes on modern CPUs. But the code appears to assume a size of 32 bytes. I adjusted two constants to increase the padding between counters.

Pinku Surana A cache line is 64 bytes, or 8 longs. Therefore, I think the pad shou…
…ld be 3 bits and the initial CAT size should be 8 longs.
75770ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 23, 2011
Pinku Surana A cache line is 64 bytes, or 8 longs. Therefore, I think the pad shou…
…ld be 3 bits and the initial CAT size should be 8 longs.
75770ec
This page is out of date. Refresh to see the latest.
4  src/main/java/org/cliffc/high_scale_lib/ConcurrentAutoTable.java
@@ -94,7 +94,7 @@ public void set( long x ) {
94 94
   private long add_if_mask( long x, long mask ) { return _cat.add_if_mask(x,mask,hash(),this); }
95 95
 
96 96
   // The underlying array of concurrently updated long counters
97  
-  private volatile CAT _cat = new CAT(null,4/*Start Small, Think Big!*/,0L);
  97
+  private volatile CAT _cat = new CAT(null,8/*Start Small, Think Big!*/,0L);
98 98
   private static final AtomicReferenceFieldUpdater<ConcurrentAutoTable,CAT> _catUpdater =
99 99
     AtomicReferenceFieldUpdater.newUpdater(ConcurrentAutoTable.class,CAT.class, "_cat");
100 100
   private boolean CAS_cat( CAT oldcat, CAT newcat ) { return _catUpdater.compareAndSet(this,oldcat,newcat); }
@@ -107,7 +107,7 @@ private static final int hash() {
107 107
     // in the low bits.
108 108
     h ^= (h>>>20) ^ (h>>>12);   // Bit spreader, borrowed from Doug Lea
109 109
     h ^= (h>>> 7) ^ (h>>> 4);
110  
-    return h<<2;                // Pad out cache lines.  The goal is to avoid cache-line contention
  110
+    return h<<3;                // Pad out cache lines.  The goal is to avoid cache-line contention
111 111
   }
112 112
 
113 113
   // --- CAT -----------------------------------------------------------------
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.