Skip to content

High CPU usage processing lots of accumulated messages #565

Description

@WhyNotHugo

Background: my TLS certificate for mosquitto had expired and I didn't notice. My mobile clients have accumulated a few weeks worth of data which they're submitting all at once.

While processing a large backlog of data, owntracks_recorder uses 100% CPU and takes a long long time to process messages… to the point where mosquitto starts discarding messages because its queue is full.

One of the factors involved seem to be the call to is_newer_than_last for every single message. This calls last_users which, if I understand correctly, scans the entire directory tree of last. This involves multiple filesystem operations per message to continuously determine the same thing.

I think it should be feasible to read STORAGEDIR/last/{user}/{device}/{user}-{device}.json directly instead of walking the entire tree?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions