Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to skip MessagePack for String objects #18

Closed
casperisfine opened this issue Nov 14, 2022 · 0 comments · Fixed by #20
Closed

Allow to skip MessagePack for String objects #18

casperisfine opened this issue Nov 14, 2022 · 0 comments · Fixed by #20

Comments

@casperisfine
Copy link
Contributor

Something we envisioned a while ago but never implemented yet.

When using Paquito to implement a Rails.cache coder, a good number of the payload are String objects. For these, going through MessagePack is just wasteful, we could just prepend a byte indicating that the payload is an UTF-8 or BINARY String, which would allow us to "deserialize" it with just payload.byteslice(1..-1). For large payload it would be much much faster.

We probably just need a different code for the common encodings: UTF-8, ASCII, BINARY. If the encoding is anything else, we can fallback to use the serializer.

casperisfine pushed a commit that referenced this issue Nov 24, 2022
…erialization

Fix: #18

```
 === 100B ===
Warming up --------------------------------------
             marshal   223.272k i/100ms
             msgpack   241.596k i/100ms
              bypass   525.868k i/100ms
Calculating -------------------------------------
             marshal      2.204M (± 2.4%) i/s -     11.164M in   5.068149s
             msgpack      2.430M (± 0.6%) i/s -     12.321M in   5.070954s
              bypass      5.254M (± 0.6%) i/s -     26.293M in   5.004752s

Comparison:
             marshal:  2203965.2 i/s
              bypass:  5253891.6 i/s - 2.38x  (± 0.00) faster
             msgpack:  2429893.3 i/s - 1.10x  (± 0.00) faster

 === 10000B ===
Warming up --------------------------------------
             marshal    63.218k i/100ms
             msgpack    56.587k i/100ms
              bypass   525.636k i/100ms
Calculating -------------------------------------
             marshal    669.594k (±10.4%) i/s -      3.351M in   5.059375s
             msgpack    539.556k (±14.9%) i/s -      2.660M in   5.031818s
              bypass      5.260M (± 0.5%) i/s -     26.807M in   5.097029s

Comparison:
             marshal:   669594.2 i/s
              bypass:  5259577.9 i/s - 7.85x  (± 0.00) faster
             msgpack:   539555.8 i/s - same-ish: difference falls within error

 === 1000000B ===
Warming up --------------------------------------
             marshal     1.019k i/100ms
             msgpack   817.000  i/100ms
              bypass   526.597k i/100ms
Calculating -------------------------------------
             marshal     11.233k (± 4.0%) i/s -     57.064k in   5.088251s
             msgpack      7.790k (± 7.8%) i/s -     39.216k in   5.069360s
              bypass      5.255M (± 0.5%) i/s -     26.330M in   5.010561s

Comparison:
             marshal:    11232.9 i/s
              bypass:  5255000.7 i/s - 467.82x  (± 0.00) faster
             msgpack:     7789.8 i/s - 1.44x  (± 0.00) slower

```
casperisfine pushed a commit that referenced this issue Nov 24, 2022
…erialization

Fix: #18

```
 === 100B ===
Warming up --------------------------------------
             marshal   223.272k i/100ms
             msgpack   241.596k i/100ms
              bypass   525.868k i/100ms
Calculating -------------------------------------
             marshal      2.204M (± 2.4%) i/s -     11.164M in   5.068149s
             msgpack      2.430M (± 0.6%) i/s -     12.321M in   5.070954s
              bypass      5.254M (± 0.6%) i/s -     26.293M in   5.004752s

Comparison:
             marshal:  2203965.2 i/s
              bypass:  5253891.6 i/s - 2.38x  (± 0.00) faster
             msgpack:  2429893.3 i/s - 1.10x  (± 0.00) faster

 === 10000B ===
Warming up --------------------------------------
             marshal    63.218k i/100ms
             msgpack    56.587k i/100ms
              bypass   525.636k i/100ms
Calculating -------------------------------------
             marshal    669.594k (±10.4%) i/s -      3.351M in   5.059375s
             msgpack    539.556k (±14.9%) i/s -      2.660M in   5.031818s
              bypass      5.260M (± 0.5%) i/s -     26.807M in   5.097029s

Comparison:
             marshal:   669594.2 i/s
              bypass:  5259577.9 i/s - 7.85x  (± 0.00) faster
             msgpack:   539555.8 i/s - same-ish: difference falls within error

 === 1000000B ===
Warming up --------------------------------------
             marshal     1.019k i/100ms
             msgpack   817.000  i/100ms
              bypass   526.597k i/100ms
Calculating -------------------------------------
             marshal     11.233k (± 4.0%) i/s -     57.064k in   5.088251s
             msgpack      7.790k (± 7.8%) i/s -     39.216k in   5.069360s
              bypass      5.255M (± 0.5%) i/s -     26.330M in   5.010561s

Comparison:
             marshal:    11232.9 i/s
              bypass:  5255000.7 i/s - 467.82x  (± 0.00) faster
             msgpack:     7789.8 i/s - 1.44x  (± 0.00) slower

```
casperisfine pushed a commit that referenced this issue Nov 24, 2022
…erialization

Fix: #18

```
 === 100B ===
Warming up --------------------------------------
             marshal   223.272k i/100ms
             msgpack   241.596k i/100ms
              bypass   525.868k i/100ms
Calculating -------------------------------------
             marshal      2.204M (± 2.4%) i/s -     11.164M in   5.068149s
             msgpack      2.430M (± 0.6%) i/s -     12.321M in   5.070954s
              bypass      5.254M (± 0.6%) i/s -     26.293M in   5.004752s

Comparison:
             marshal:  2203965.2 i/s
              bypass:  5253891.6 i/s - 2.38x  (± 0.00) faster
             msgpack:  2429893.3 i/s - 1.10x  (± 0.00) faster

 === 10000B ===
Warming up --------------------------------------
             marshal    63.218k i/100ms
             msgpack    56.587k i/100ms
              bypass   525.636k i/100ms
Calculating -------------------------------------
             marshal    669.594k (±10.4%) i/s -      3.351M in   5.059375s
             msgpack    539.556k (±14.9%) i/s -      2.660M in   5.031818s
              bypass      5.260M (± 0.5%) i/s -     26.807M in   5.097029s

Comparison:
             marshal:   669594.2 i/s
              bypass:  5259577.9 i/s - 7.85x  (± 0.00) faster
             msgpack:   539555.8 i/s - same-ish: difference falls within error

 === 1000000B ===
Warming up --------------------------------------
             marshal     1.019k i/100ms
             msgpack   817.000  i/100ms
              bypass   526.597k i/100ms
Calculating -------------------------------------
             marshal     11.233k (± 4.0%) i/s -     57.064k in   5.088251s
             msgpack      7.790k (± 7.8%) i/s -     39.216k in   5.069360s
              bypass      5.255M (± 0.5%) i/s -     26.330M in   5.010561s

Comparison:
             marshal:    11232.9 i/s
              bypass:  5255000.7 i/s - 467.82x  (± 0.00) faster
             msgpack:     7789.8 i/s - 1.44x  (± 0.00) slower

```
casperisfine pushed a commit that referenced this issue Nov 24, 2022
…erialization

Fix: #18

```
 === 100B ===
Warming up --------------------------------------
             marshal   223.272k i/100ms
             msgpack   241.596k i/100ms
              bypass   525.868k i/100ms
Calculating -------------------------------------
             marshal      2.204M (± 2.4%) i/s -     11.164M in   5.068149s
             msgpack      2.430M (± 0.6%) i/s -     12.321M in   5.070954s
              bypass      5.254M (± 0.6%) i/s -     26.293M in   5.004752s

Comparison:
             marshal:  2203965.2 i/s
              bypass:  5253891.6 i/s - 2.38x  (± 0.00) faster
             msgpack:  2429893.3 i/s - 1.10x  (± 0.00) faster

 === 10000B ===
Warming up --------------------------------------
             marshal    63.218k i/100ms
             msgpack    56.587k i/100ms
              bypass   525.636k i/100ms
Calculating -------------------------------------
             marshal    669.594k (±10.4%) i/s -      3.351M in   5.059375s
             msgpack    539.556k (±14.9%) i/s -      2.660M in   5.031818s
              bypass      5.260M (± 0.5%) i/s -     26.807M in   5.097029s

Comparison:
             marshal:   669594.2 i/s
              bypass:  5259577.9 i/s - 7.85x  (± 0.00) faster
             msgpack:   539555.8 i/s - same-ish: difference falls within error

 === 1000000B ===
Warming up --------------------------------------
             marshal     1.019k i/100ms
             msgpack   817.000  i/100ms
              bypass   526.597k i/100ms
Calculating -------------------------------------
             marshal     11.233k (± 4.0%) i/s -     57.064k in   5.088251s
             msgpack      7.790k (± 7.8%) i/s -     39.216k in   5.069360s
              bypass      5.255M (± 0.5%) i/s -     26.330M in   5.010561s

Comparison:
             marshal:    11232.9 i/s
              bypass:  5255000.7 i/s - 467.82x  (± 0.00) faster
             msgpack:     7789.8 i/s - 1.44x  (± 0.00) slower

```
casperisfine pushed a commit that referenced this issue Nov 24, 2022
…erialization

Fix: #18

```
 === 100B ===
Warming up --------------------------------------
             marshal   223.272k i/100ms
             msgpack   241.596k i/100ms
              bypass   525.868k i/100ms
Calculating -------------------------------------
             marshal      2.204M (± 2.4%) i/s -     11.164M in   5.068149s
             msgpack      2.430M (± 0.6%) i/s -     12.321M in   5.070954s
              bypass      5.254M (± 0.6%) i/s -     26.293M in   5.004752s

Comparison:
             marshal:  2203965.2 i/s
              bypass:  5253891.6 i/s - 2.38x  (± 0.00) faster
             msgpack:  2429893.3 i/s - 1.10x  (± 0.00) faster

 === 10000B ===
Warming up --------------------------------------
             marshal    63.218k i/100ms
             msgpack    56.587k i/100ms
              bypass   525.636k i/100ms
Calculating -------------------------------------
             marshal    669.594k (±10.4%) i/s -      3.351M in   5.059375s
             msgpack    539.556k (±14.9%) i/s -      2.660M in   5.031818s
              bypass      5.260M (± 0.5%) i/s -     26.807M in   5.097029s

Comparison:
             marshal:   669594.2 i/s
              bypass:  5259577.9 i/s - 7.85x  (± 0.00) faster
             msgpack:   539555.8 i/s - same-ish: difference falls within error

 === 1000000B ===
Warming up --------------------------------------
             marshal     1.019k i/100ms
             msgpack   817.000  i/100ms
              bypass   526.597k i/100ms
Calculating -------------------------------------
             marshal     11.233k (± 4.0%) i/s -     57.064k in   5.088251s
             msgpack      7.790k (± 7.8%) i/s -     39.216k in   5.069360s
              bypass      5.255M (± 0.5%) i/s -     26.330M in   5.010561s

Comparison:
             marshal:    11232.9 i/s
              bypass:  5255000.7 i/s - 467.82x  (± 0.00) faster
             msgpack:     7789.8 i/s - 1.44x  (± 0.00) slower

```
casperisfine pushed a commit that referenced this issue Nov 24, 2022
…erialization

Fix: #18

```
 === 100B ===
Warming up --------------------------------------
             marshal   223.272k i/100ms
             msgpack   241.596k i/100ms
              bypass   525.868k i/100ms
Calculating -------------------------------------
             marshal      2.204M (± 2.4%) i/s -     11.164M in   5.068149s
             msgpack      2.430M (± 0.6%) i/s -     12.321M in   5.070954s
              bypass      5.254M (± 0.6%) i/s -     26.293M in   5.004752s

Comparison:
             marshal:  2203965.2 i/s
              bypass:  5253891.6 i/s - 2.38x  (± 0.00) faster
             msgpack:  2429893.3 i/s - 1.10x  (± 0.00) faster

 === 10000B ===
Warming up --------------------------------------
             marshal    63.218k i/100ms
             msgpack    56.587k i/100ms
              bypass   525.636k i/100ms
Calculating -------------------------------------
             marshal    669.594k (±10.4%) i/s -      3.351M in   5.059375s
             msgpack    539.556k (±14.9%) i/s -      2.660M in   5.031818s
              bypass      5.260M (± 0.5%) i/s -     26.807M in   5.097029s

Comparison:
             marshal:   669594.2 i/s
              bypass:  5259577.9 i/s - 7.85x  (± 0.00) faster
             msgpack:   539555.8 i/s - same-ish: difference falls within error

 === 1000000B ===
Warming up --------------------------------------
             marshal     1.019k i/100ms
             msgpack   817.000  i/100ms
              bypass   526.597k i/100ms
Calculating -------------------------------------
             marshal     11.233k (± 4.0%) i/s -     57.064k in   5.088251s
             msgpack      7.790k (± 7.8%) i/s -     39.216k in   5.069360s
              bypass      5.255M (± 0.5%) i/s -     26.330M in   5.010561s

Comparison:
             marshal:    11232.9 i/s
              bypass:  5255000.7 i/s - 467.82x  (± 0.00) faster
             msgpack:     7789.8 i/s - 1.44x  (± 0.00) slower

```
casperisfine pushed a commit that referenced this issue Nov 24, 2022
…erialization

Fix: #18

```
 === 100B ===
Warming up --------------------------------------
             marshal   223.272k i/100ms
             msgpack   241.596k i/100ms
              bypass   525.868k i/100ms
Calculating -------------------------------------
             marshal      2.204M (± 2.4%) i/s -     11.164M in   5.068149s
             msgpack      2.430M (± 0.6%) i/s -     12.321M in   5.070954s
              bypass      5.254M (± 0.6%) i/s -     26.293M in   5.004752s

Comparison:
             marshal:  2203965.2 i/s
              bypass:  5253891.6 i/s - 2.38x  (± 0.00) faster
             msgpack:  2429893.3 i/s - 1.10x  (± 0.00) faster

 === 10000B ===
Warming up --------------------------------------
             marshal    63.218k i/100ms
             msgpack    56.587k i/100ms
              bypass   525.636k i/100ms
Calculating -------------------------------------
             marshal    669.594k (±10.4%) i/s -      3.351M in   5.059375s
             msgpack    539.556k (±14.9%) i/s -      2.660M in   5.031818s
              bypass      5.260M (± 0.5%) i/s -     26.807M in   5.097029s

Comparison:
             marshal:   669594.2 i/s
              bypass:  5259577.9 i/s - 7.85x  (± 0.00) faster
             msgpack:   539555.8 i/s - same-ish: difference falls within error

 === 1000000B ===
Warming up --------------------------------------
             marshal     1.019k i/100ms
             msgpack   817.000  i/100ms
              bypass   526.597k i/100ms
Calculating -------------------------------------
             marshal     11.233k (± 4.0%) i/s -     57.064k in   5.088251s
             msgpack      7.790k (± 7.8%) i/s -     39.216k in   5.069360s
              bypass      5.255M (± 0.5%) i/s -     26.330M in   5.010561s

Comparison:
             marshal:    11232.9 i/s
              bypass:  5255000.7 i/s - 467.82x  (± 0.00) faster
             msgpack:     7789.8 i/s - 1.44x  (± 0.00) slower

```
casperisfine pushed a commit that referenced this issue Nov 24, 2022
…erialization

Fix: #18

```
 === 100B ===
Warming up --------------------------------------
             marshal   223.272k i/100ms
             msgpack   241.596k i/100ms
              bypass   525.868k i/100ms
Calculating -------------------------------------
             marshal      2.204M (± 2.4%) i/s -     11.164M in   5.068149s
             msgpack      2.430M (± 0.6%) i/s -     12.321M in   5.070954s
              bypass      5.254M (± 0.6%) i/s -     26.293M in   5.004752s

Comparison:
             marshal:  2203965.2 i/s
              bypass:  5253891.6 i/s - 2.38x  (± 0.00) faster
             msgpack:  2429893.3 i/s - 1.10x  (± 0.00) faster

 === 10000B ===
Warming up --------------------------------------
             marshal    63.218k i/100ms
             msgpack    56.587k i/100ms
              bypass   525.636k i/100ms
Calculating -------------------------------------
             marshal    669.594k (±10.4%) i/s -      3.351M in   5.059375s
             msgpack    539.556k (±14.9%) i/s -      2.660M in   5.031818s
              bypass      5.260M (± 0.5%) i/s -     26.807M in   5.097029s

Comparison:
             marshal:   669594.2 i/s
              bypass:  5259577.9 i/s - 7.85x  (± 0.00) faster
             msgpack:   539555.8 i/s - same-ish: difference falls within error

 === 1000000B ===
Warming up --------------------------------------
             marshal     1.019k i/100ms
             msgpack   817.000  i/100ms
              bypass   526.597k i/100ms
Calculating -------------------------------------
             marshal     11.233k (± 4.0%) i/s -     57.064k in   5.088251s
             msgpack      7.790k (± 7.8%) i/s -     39.216k in   5.069360s
              bypass      5.255M (± 0.5%) i/s -     26.330M in   5.010561s

Comparison:
             marshal:    11232.9 i/s
              bypass:  5255000.7 i/s - 467.82x  (± 0.00) faster
             msgpack:     7789.8 i/s - 1.44x  (± 0.00) slower

```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant