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.
Context
As you may have seen in my recent performance PRs, I'm trying to improve
msgpackperformance for our use case.We use it a lot for caches etc, so our main use case looks like:
And the payload are of very varying size, some are fairly small. Parsing wise
msgpackis very fast, but there's a fairly high flat cost for instantiating a newPacker / Unpackerwhich I'm trying to reduce.Idea
Based on profiling, a good part of the
Unpackerinstantiation cost is for theBuffer, 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
Packeruse forIOobjects, 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 / Unpackerinstances could be safely re-used, with maybe some kind of pooling.