Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #1037

Re: CAS operations and scalability...

Date 2012-08-26 10:36 -0700
From Patricia Shanahan <pats@acm.org>
Newsgroups comp.programming, comp.programming.threads
Subject Re: CAS operations and scalability...
References <k1dira$jt9$1@dont-email.me>
Message-ID <FsqdncaQ9pkkw6fNnZ2dnUVZ_sGdnZ2d@earthlink.com> (permalink)

Cross-posted to 2 groups.

Show all headers | View raw


On 8/26/2012 10:28 AM, aminer wrote:
...
> When the CAS operation "goes on the bus", use of CAS can impair scalability.
> but CAS can be accomplished locally -- that is, with no bus transactions --
> and then it can scale.
...

The problem the hardware faces doing CAS in-cache is that it must make
sure that no other processor can write to the cache line containing the
CAS target during the critical period of the cache.

If multiple processors are attempting CAS operations on the same target
at about the same time there are two costs:

1. The bus traffic to ensure that only one processor is writing to the
cache line at any time, and that processor has the latest value of the
cache line.

2. Repeated CAS operations, due to changes to the CAS target between
doing whatever reads select the value and doing the CAS itself.

You can do a couple of things to limit these costs. One is to make sure
each CAS target is by itself in a cache line. That will reduce the risk
of unnecessary bus traffic due to access to other fields in the same
line. The other is to structure your code to minimize contention for any
one CAS target, so that a CAS has a very high probability of the compare
matching. You can instrument your CAS-using code to see how many CAS
attempts you are making per successful CAS.

Patricia

Back to comp.programming.threads | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

CAS operations and scalability... "aminer" <aminer@videotron.ca> - 2012-08-26 12:28 -0500
  Re: CAS operations and scalability... "aminer" <aminer@videotron.ca> - 2012-08-26 12:56 -0500
  Re: CAS operations and scalability... Patricia Shanahan <pats@acm.org> - 2012-08-26 10:36 -0700
    Re: CAS operations and scalability... "aminer" <aminer@videotron.ca> - 2012-08-26 14:08 -0500
  Re: CAS operations and scalability... "aminer" <aminer@videotron.ca> - 2012-09-13 19:13 -0500

csiph-web