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

Large buffers allocated on each request #86

Open
mfp opened this issue Aug 16, 2015 · 1 comment
Open

Large buffers allocated on each request #86

mfp opened this issue Aug 16, 2015 · 1 comment

Comments

@mfp
Copy link
Contributor

mfp commented Aug 16, 2015

There are a few places where ocsigenserver allocates 1KB-, 4KB- and 8KB buffers. You can get them (along with some context) with

git grep -P -10 "(Lwt_io.make|Lwt_io.of_|Lwt_bytes.create|Bytes.create)"

There's at least two 4KB buffers per connection (Ocsigen_http_com.create_receiver), plus a 8KB buffer for serving files (4KB one for chunked responses), plus a 8KB one for deflatemod. So serving e.g. a static HTML/CSS asset (undergoing compression) allocates 24KB which go right to the major heap and become garbage as soon as we close the connection. This increases GC load, trashes the cache, etc. (see #49 for a dramatic example). Also, Lwt_bytes.t buffers lie outside OCaml's heaps and are collected at the GC's whim (probably quite late), so that memory usage grows quickly and the heap becomes fragmented.

This can be easily prevented by pooling such buffers.

@mfp
Copy link
Contributor Author

mfp commented Aug 16, 2015

Addressed in #87.

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

1 participant