Tighten up the locking in the Cache class #15

Closed
jeremydmiller opened this Issue Oct 30, 2011 · 12 comments

Comments

Projects
None yet
5 participants
Owner

jeremydmiller commented Oct 30, 2011

Need to be more aggressive with reader/writer locks in the Cache class. Of course, the last time someone tried to make a fancier locking Cache that damn thing just didn't work. However, I'm an optimist

Owner

chadmyers commented Nov 1, 2011

First stab at code is done. All current FubuCore tests pass. I had to
turn on lock recursion in the ReaderWriterLockSim because there are areas
in the FubuCore tests (at least) that call back into the same cache in the
onMissing action (causing another read lock).

With my implementation, it's possible that someone could attempt to write
to the cache within the onMissing and get an exception. This is expected
behavior because you shouldn't be modifying the cache in the onMissing in
the first place, IMHO.

I am planning on doing some more tests in a multi-threaded way (possibly
with Microsoft's CHESS framework) before submitting a pull request.

chadmyers/fubucore@1c6acd3

-Chad

On Sun, Oct 30, 2011 at 2:46 PM, Jeremy D. Miller <
reply@reply.github.com>wrote:

Need to be more aggressive with reader/writer locks in the Cache class.
Of course, the last time someone tried to make a fancier locking Cache
that damn thing just didn't work. However, I'm an optimist

Reply to this email directly or view it on GitHub:
#15

Owner

jmarnold commented Nov 1, 2011

@chadmyers I've seen the .NET Parallel pieces used several times to do some simulate basic "load" against a server. I wonder if that would suffice for multi-threaded scenarios of reading/writing to the cache

If you are interested in testing by http request i would really suggest http://redmine.lighttpd.net/projects/weighttp/wiki.
It has been proven to really been able to stress a webserver with multi threading.

A few more valuable links regarding benchmarks.

http://gwan.ch/faq#benchmarks
And
http://gwan.ch/en_apachebench_httperf.html

Its a c script / wrapper around multiple benchmarks tools (weighttp is prefered because its speed) which can aggregate results in a csv file and then plot it.

It is sure a bit into how to test the webservers, but if you want to test the underlying logic i can't see a reason too.

Anyway If someone is willing to collaborate in this, i have a test bench which we can flood requests to a http server (which probably would call the cache in some extensive way). So I'm more then willing to help out to find any concurrency issues aswell as speed.

Owner

chadmyers commented Nov 11, 2011

Tomas,

I got busy and had to put this on hold for awhile. I was going to take a
look at it this afternoon.

The Microsoft CHESS route was promising, but flopped since it hasn't been
updated in a few years and doesn't seem to work with VS 2010.

I'm not sure how the Apache stuff will help unless we test in Mono, right?
What are your thoughts here?

-Chad

On Thu, Nov 10, 2011 at 12:37 AM, Tomas Roos <
reply@reply.github.com>wrote:

Anyway If someone is willing to collaborate in this, i have a test bench
which we can flood requests to a http server (which probably would call the
cache in some extensive way). So I'm more then willing to help out to find
any concurrency issues aswell as speed.


Reply to this email directly or view it on GitHub:
#15 (comment)

Hey!

I have the abillity to test both against Linux and windows 2008 r2 iis 7.5.

Do you need bugging abilities? You can get remote access to the server and then we collaborate and I trigger clients/requests against it.

Would that help? I can trigger from 100 concurrent clients to about 10.000.

Best regards Tomas

On 11 nov 2011, at 23:18, Chad Myersreply@reply.github.com wrote:

Tomas,

I got busy and had to put this on hold for awhile. I was going to take a
look at it this afternoon.

The Microsoft CHESS route was promising, but flopped since it hasn't been
updated in a few years and doesn't seem to work with VS 2010.

I'm not sure how the Apache stuff will help unless we test in Mono, right?
What are your thoughts here?

-Chad

On Thu, Nov 10, 2011 at 12:37 AM, Tomas Roos <
reply@reply.github.com>wrote:

Anyway If someone is willing to collaborate in this, i have a test bench
which we can flood requests to a http server (which probably would call the
cache in some extensive way). So I'm more then willing to help out to find
any concurrency issues aswell as speed.


Reply to this email directly or view it on GitHub:
#15 (comment)


Reply to this email directly or view it on GitHub:
#15 (comment)

Just to be clear.

If you have the ability to create a action / aspx which tests the cache in
your preferred way or point me in the direction how it should be tested.
I can take the time to test it or we can do it together.

Tomas

On Sat, Nov 12, 2011 at 12:08 PM, ptomasroos@gmail.com wrote:

Hey!

I have the abillity to test both against Linux and windows 2008 r2 iis 7.5.

Do you need bugging abilities? You can get remote access to the server and
then we collaborate and I trigger clients/requests against it.

Would that help? I can trigger from 100 concurrent clients to about 10.000.

Best regards Tomas

On 11 nov 2011, at 23:18, Chad Myers<
reply@reply.github.com>
wrote:

Tomas,

I got busy and had to put this on hold for awhile. I was going to take a
look at it this afternoon.

The Microsoft CHESS route was promising, but flopped since it hasn't been
updated in a few years and doesn't seem to work with VS 2010.

I'm not sure how the Apache stuff will help unless we test in Mono,
right?
What are your thoughts here?

-Chad

On Thu, Nov 10, 2011 at 12:37 AM, Tomas Roos <
reply@reply.github.com>wrote:

Anyway If someone is willing to collaborate in this, i have a test bench
which we can flood requests to a http server (which probably would call
the
cache in some extensive way). So I'm more then willing to help out to
find
any concurrency issues aswell as speed.


Reply to this email directly or view it on GitHub:
#15 (comment)


Reply to this email directly or view it on GitHub:
#15 (comment)

Owner

chadmyers commented Nov 14, 2011

Tomas,

I've been thinking through the types of tests I want to run. At first, it
sounded like involving FubuMVC in the testing was overkill to test this,
but it may end up being the easiest way to get at the Cache<,> class.

My thought was to have a bunch of readers, a few writers, and a few
read-misses (triggering writes). We can run them in various mixtures
(85%/10%/5%, or 90%/5%/5%, etc) and see if problems appear.

Do you have any recommendations like these?

-Chad

On Mon, Nov 14, 2011 at 12:48 AM, Tomas Roos <
reply@reply.github.com

wrote:

Just to be clear.

If you have the ability to create a action / aspx which tests the cache in
your preferred way or point me in the direction how it should be tested.
I can take the time to test it or we can do it together.

Tomas

On Sat, Nov 12, 2011 at 12:08 PM, ptomasroos@gmail.com wrote:

Hey!

I have the abillity to test both against Linux and windows 2008 r2 iis
7.5.

Do you need bugging abilities? You can get remote access to the server
and
then we collaborate and I trigger clients/requests against it.

Would that help? I can trigger from 100 concurrent clients to about
10.000.

Best regards Tomas

On 11 nov 2011, at 23:18, Chad Myers<
reply@reply.github.com>
wrote:

Tomas,

I got busy and had to put this on hold for awhile. I was going to take
a
look at it this afternoon.

The Microsoft CHESS route was promising, but flopped since it hasn't
been
updated in a few years and doesn't seem to work with VS 2010.

I'm not sure how the Apache stuff will help unless we test in Mono,
right?
What are your thoughts here?

-Chad

On Thu, Nov 10, 2011 at 12:37 AM, Tomas Roos <
reply@reply.github.com>wrote:

Anyway If someone is willing to collaborate in this, i have a test
bench
which we can flood requests to a http server (which probably would
call
the
cache in some extensive way). So I'm more then willing to help out to
find
any concurrency issues aswell as speed.


Reply to this email directly or view it on GitHub:

#15 (comment)


Reply to this email directly or view it on GitHub:

#15 (comment)


Reply to this email directly or view it on GitHub:
#15 (comment)

Sounds good.
And yes it sure is a bit overhead to include fubumvc. But there are
benefits with doing it.

  1. I have existing tools for running requests against webservers up to
    1 million request / s.
  2. It's a native multithreaded environment.

And if we want to we can get populate a performance graph on reads /
writes. If we felt like there is a need for performance improvements.

Tomas

Owner

drusellers commented Apr 25, 2012

System.Runtime.Caching has an object cache, that has sliding stuff, and other awesome. I would assume that this would have the locking constructs. What if we built FubuCore's Cache on top of that?

Owner

jeremydmiller commented Dec 13, 2013

We have the new ConcurrentCache as a replacement. What we found when we started monkeying around with the existing Cache<> is that it broke all kinds of things downstream that we didn't expect, so we retreated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment