You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Kevin Burton <bu...@spinn3r.com> on 2016/07/20 18:48:02 UTC

Are counters faster than CAS or vice versa?

We ended up implementing a task/queue system which uses a global pointer.

Basically the pointer just increments ... so we have thousands of tasks
that just increment this one pointer.

The problem is that we're seeing contention on it and not being able to
write this record properly.

We're just doing a CAS operation now to read the existing value, then
increment it.

I think it might have been better to implement this as a counter.  Would
that be inherently faster or would a CAS be about the same?

I can't really test it without deploying it so I figured I would just ask
here first.

Kevin

-- 

We’re hiring if you know of any awesome Java Devops or Linux Operations
Engineers!

Founder/CEO Spinn3r.com
Location: *San Francisco, CA*
blog: http://burtonator.wordpress.com
… or check out my Google+ profile
<https://plus.google.com/102718274791889610666/posts>

Re: Are counters faster than CAS or vice versa?

Posted by Jonathan Haddad <jo...@jonhaddad.com>.
Just to make sure I understand, you've got a queue where you can stand
missing processing the items in it?

On Wed, Jul 20, 2016 at 1:13 PM Kevin Burton <bu...@spinn3r.com> wrote:

> On Wed, Jul 20, 2016 at 11:53 AM, Jeff Jirsa <je...@crowdstrike.com>
> wrote:
>
>> Can you tolerate the value being “close, but not perfectly accurate”? If
>> not, don’t use a counter.
>>
>>
>>
>
> yeah.. agreed.. this is a problem which is something I was considering.  I
> guess it depends on whether they are 10x faster..
>
> --
>
> We’re hiring if you know of any awesome Java Devops or Linux Operations
> Engineers!
>
> Founder/CEO Spinn3r.com
> Location: *San Francisco, CA*
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> <https://plus.google.com/102718274791889610666/posts>
>
>

Re: Are counters faster than CAS or vice versa?

Posted by Kevin Burton <bu...@spinn3r.com>.
On Wed, Jul 20, 2016 at 11:53 AM, Jeff Jirsa <je...@crowdstrike.com>
wrote:

> Can you tolerate the value being “close, but not perfectly accurate”? If
> not, don’t use a counter.
>
>
>

yeah.. agreed.. this is a problem which is something I was considering.  I
guess it depends on whether they are 10x faster..

-- 

We’re hiring if you know of any awesome Java Devops or Linux Operations
Engineers!

Founder/CEO Spinn3r.com
Location: *San Francisco, CA*
blog: http://burtonator.wordpress.com
… or check out my Google+ profile
<https://plus.google.com/102718274791889610666/posts>

Re: Are counters faster than CAS or vice versa?

Posted by Jeff Jirsa <je...@crowdstrike.com>.
Can you tolerate the value being “close, but not perfectly accurate”? If not, don’t use a counter.

 

 

From: <bu...@gmail.com> on behalf of Kevin Burton <bu...@spinn3r.com>
Reply-To: "user@cassandra.apache.org" <us...@cassandra.apache.org>
Date: Wednesday, July 20, 2016 at 11:48 AM
To: "user@cassandra.apache.org" <us...@cassandra.apache.org>
Subject: Are counters faster than CAS or vice versa?

 

We ended up implementing a task/queue system which uses a global pointer. 

 

Basically the pointer just increments ... so we have thousands of tasks that just increment this one pointer.

 

The problem is that we're seeing contention on it and not being able to write this record properly.

 

We're just doing a CAS operation now to read the existing value, then increment it.

 

I think it might have been better to implement this as a counter.  Would that be inherently faster or would a CAS be about the same?

 

I can't really test it without deploying it so I figured I would just ask here first.

 

Kevin

 

-- 

We’re hiring if you know of any awesome Java Devops or Linux Operations Engineers!

 

Founder/CEO Spinn3r.com

Location: San Francisco, CA

blog: http://burtonator.wordpress.com

… or check out my Google+ profile

Error! Filename not specified.