Skip to content

ReadStringBytes allocates #145

@Dieterbe

Description

@Dieterbe

Hello,
thank you very much for your work. it works very nicely.
one thing i noticed though,
in my app, github.com/tinylib/msgp/msgp.ReadStringBytes is the largest allocator of objects (note: by far not the largest cause of memory usage, so it's just that it allocates a lot, but often not much each time)

is there anything that can be done? I'm using the UnMarshal method

(pprof) list ReadStringBytes
Total: 5227186039
ROUTINE ======================== github.com/tinylib/msgp/msgp.ReadStringBytes in /home/ubuntu/.go_workspace/src/github.com/tinylib/msgp/msgp/read_bytes.go
 851134023  851134023 (flat, cum) 16.28% of Total
         .          .    779:// - ErrShortBytes (b not long enough)
         .          .    780:// - TypeError{} (not 'str' type)
         .          .    781:// - InvalidPrefixError
         .          .    782:func ReadStringBytes(b []byte) (string, []byte, error) {
         .          .    783:   v, o, err := ReadStringZC(b)
 851134023  851134023    784:   return string(v), o, err
         .          .    785:}
         .          .    786:
         .          .    787:// ReadStringAsBytes reads a 'str' object
         .          .    788:// into a slice of bytes. 'v' is the value of
         .          .    789:// the 'str' object, which may reside in memory
(pprof) %

thanks.

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