Skip to content

Large buffers allocated on each request #86

@mfp

Description

@mfp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions