-
Notifications
You must be signed in to change notification settings - Fork 33
Description
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.