Skip to content

Conversation

@stepancheg
Copy link
Contributor

@stepancheg stepancheg commented Oct 26, 2016

Patch does CAS loop and XCHG instead of synchronized which should
be faster.

Patch also reduces per-future memory consumption.

@slandelle
Copy link
Contributor

Patch does CAS loop and XCHG instead of synchronized which should be faster.

Do you have some numbers please? This code is forked from Guava, so before introducing code that will have to be maintained here, I'd rather be sure it's worth it.

Patch does CAS loop and XCHG instead of synchronized which should
be faster.

Patch also reduces per-future memory consumption.
@stepancheg
Copy link
Contributor Author

stepancheg commented Oct 26, 2016

Well, it is easy to create a benchmark that proves anything.

I've created a simple benchmark:

https://gist.github.com/stepancheg/2f3236cb5428f215eb2d92e0fafed4f2

It prints:

19158
18589
19825
18905
19007
17067
18801
16763

on current master, and prints

8200
6686
6798
6620
7832
7202
7713
6623
6706

on patched version. Less is better. It is important for benchmark that addListener and runListeners are executed on different threads, otherwise JVM uses lock elision and original version is slightly faster.

However, the most important reason for me is better memory utilization in patched version: there is no ExecutionList object per future.

@stepancheg stepancheg force-pushed the exec-list branch 2 times, most recently from 15d084e to 3f701e5 Compare October 26, 2016 09:11
@slandelle slandelle merged commit 671378f into AsyncHttpClient:master Oct 27, 2016
@slandelle
Copy link
Contributor

Awesome work, thanks!

@slandelle slandelle added this to the 2.0.20 milestone Oct 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants