Skip to content

Idea: Specialized bufferless Unpacker for strings #255

Description

@casperisfine

Context

As you may have seen in my recent performance PRs, I'm trying to improve msgpack performance for our use case.

We use it a lot for caches etc, so our main use case looks like:

factory.dump(object) # => String
factory.load(string) # => Object

And the payload are of very varying size, some are fairly small. Parsing wise msgpack is very fast, but there's a fairly high flat cost for instantiating a new Packer / Unpacker which I'm trying to reduce.

Idea

Based on profiling, a good part of the Unpacker instantiation cost is for the Buffer, and then we spend time copying the string inside the buffer, while in theory we could directly read from the Ruby String.

So I'm think we could have the existing Packer use for IO objects, and a new one specialized for strings that would skip the buffering.

However this may lead to quite a lot more code and probably some duplication, hence why I'm gauging interest first.

@tagomoris is this some contribution you'd be interested in?

Alternatively (or additionally) if this seems too much, I'd be interested in exploring how the Packer / Unpacker instances could be safely re-used, with maybe some kind of pooling.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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