Skip to content

Lazy memory allocation in channel pushers. #394

@ryzhyk

Description

@ryzhyk

We have an application that builds a very large dataflow graph (thousands of operators) and creates hundreds of concurrently running instances of this graph. Heap profiling showed that the application wastes a lot of memory in channel pushers, which maintain Message::default_length entries even when the system is idle with no outstanding messages.

I understand that this is a performance optimization that reduces the number of malloc calls, but the memory overhead was not acceptable for our use case, so I created a patch that changes the allocation policy to only allocate channel memory (in chunks of Message::default_length entries) when there are messages to send and to deallocate it when there are no messages, reducing the memory footprint to 0 in idle state: ddlog-dev@a94e176

@frankmcsherry , any chance you'd accept a cleaned up version of this patch as a PR? I realize that it caters for a somewhat idiosyncratic use case, but it doesn't seem to cause a measurable slow down in my experiments and it does save memory.

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