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

Introduce connection force write #126

Merged
merged 1 commit into from
Sep 29, 2017

Conversation

ybubnov
Copy link
Member

@ybubnov ybubnov commented Sep 28, 2017

This patch defines a new function for conn type that allows to write
and flush the data to the connection using a single mutex acquire.

Such approach should minimize context switches between go-routines,
which in general improves performance of multi-threaded applications.

This patch defines a new function for conn type that allows to write
and flush the data to the connection using a single mutex acquire.

Such approach should minimize context switches between go-rounite,
which in general improve performance of multi-threaded applications.
@ybubnov
Copy link
Member Author

ybubnov commented Sep 28, 2017

cc @samribeiro

@samribeiro
Copy link
Contributor

LGTM

nit: server.go:response.Write() uses buf which is locked between multiple writers. The method is naturally memory efficient because it uses the same buffer for concurrent writes. On the other side it is less performant because multiple writers need exclusive access to the buffer to calculate the length of the payload. I don't feel strongly about this but I usually opt for performance instead of memory. Go has achieved pretty good garbage collection nowadays that I care less about it.

@ybubnov
Copy link
Member Author

ybubnov commented Sep 29, 2017

Memory allocation could also take time, nevertheless I agree that we should see how to improve the performance.

@ybubnov ybubnov merged commit ec6cf65 into netrack:master Sep 29, 2017
@ybubnov ybubnov deleted the introduce-connection-force-write branch September 29, 2017 09:22
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