Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvements #2

Closed
xaionaro opened this issue Feb 11, 2019 · 3 comments
Closed

Performance improvements #2

xaionaro opened this issue Feb 11, 2019 · 3 comments
Assignees

Comments

@xaionaro
Copy link

xaionaro commented Feb 11, 2019

Hello.

  1. I'd suggest to consider using of fasthttp to reduce HTTP-library overheads.

https://github.com/valyala/fasthttp

A related issue: julienschmidt/httprouter#117

To make this project really useful you need to be faster than this:
http://antirez.com/blogdata/216/redisvsmemcached.png

  1. Also, mutexes are slow. Especially on massively-concurrent cases (which a caching server is about). You may consider to use atomicmap instead (method GetByBytes to get a value) — it is oriented on a lot of reads (less writes and unsets [it's required to use LockUnset(), ATM :( ]).

https://github.com/xaionaro-go/atomicmap

c.Mutex.Lock()

Or, may be, it would be better to implement own mutexless thread-safe map.

  1. You're coping data (and doing a memory allocation) here:

if value, ok := c.Map[key]; ok {

I'd suggest to use pointers, instead.

@xaionaro xaionaro changed the title fasthttp Performance Feb 11, 2019
@xaionaro xaionaro changed the title Performance Performance improvements Feb 11, 2019
@Darwinnn Darwinnn self-assigned this Feb 12, 2019
@Darwinnn
Copy link
Owner

Darwinnn commented Feb 12, 2019

Hello!
Well, first of all, I'd like to thank you for the feedback! I'll consider what you suggested here and come right to it.

@Darwinnn
Copy link
Owner

  1. Also, mutexes are slow. Especially on massively-concurrent cases (which is about a caching server of)

I've done some tests and it looks like atomic sync.Map is slower (about to 5k rps) than plain map with mutexes. At least on my 4cores i5 cpu. I'll be looking to test your lib and compare the results

@Darwinnn
Copy link
Owner

Darwinnn commented Feb 12, 2019

  1. I'd suggest to consider using of fasthttp to reduce HTTP-library overheads.

Wow, that actually doubled the RPS value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants