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

use memset_patternN in Buffer.fill #14599

Merged
merged 4 commits into from
Oct 16, 2024
Merged

use memset_patternN in Buffer.fill #14599

merged 4 commits into from
Oct 16, 2024

Conversation

dylan-conway
Copy link
Collaborator

What does this PR do?

Before:

❯ bun /Users/dylan/code/bun/bench/snippets/buffer-fill.mjs
cpu: Apple M1 Max
runtime: bun 1.1.30 (arm64-darwin)

benchmark                                          time (avg)             (min … max)       p75       p99      p995
------------------------------------------------------------------------------------- -----------------------------
Buffer.fill 32 bytes with 4 byte value          25.51 ns/iter   (24.36 ns … 51.63 ns)   25.9 ns  29.52 ns  30.23 ns
Buffer.fill 32 bytes with 8 byte value          19.79 ns/iter   (18.05 ns … 29.24 ns)  19.56 ns   24.7 ns  26.19 ns
Buffer.fill 32 bytes with 16 byte value         15.44 ns/iter   (15.15 ns … 21.93 ns)  15.51 ns  17.53 ns  18.36 ns
Buffer.fill 32 bytes with 11 byte value         19.38 ns/iter   (18.62 ns … 29.44 ns)  19.56 ns  21.87 ns   22.9 ns
Buffer.fill 2048 bytes with 4 byte value        75.03 ns/iter   (66.63 ns … 86.33 ns)  75.71 ns  81.61 ns   84.2 ns
Buffer.fill 2048 bytes with 8 byte value         64.2 ns/iter  (59.37 ns … 448.25 ns)  60.92 ns 183.53 ns 257.21 ns
Buffer.fill 2048 bytes with 16 byte value       56.88 ns/iter   (55.89 ns … 65.98 ns)   57.1 ns  62.32 ns  63.14 ns
Buffer.fill 2048 bytes with 11 byte value       67.37 ns/iter   (65.98 ns … 77.59 ns)  68.06 ns  72.23 ns  73.41 ns
Buffer.fill 16384 bytes with 4 byte value       253.1 ns/iter (238.01 ns … 306.48 ns) 254.21 ns 277.29 ns 277.69 ns
Buffer.fill 16384 bytes with 8 byte value      245.86 ns/iter (232.36 ns … 269.86 ns) 248.37 ns 260.68 ns 263.39 ns
Buffer.fill 16384 bytes with 16 byte value     242.69 ns/iter (229.21 ns … 250.71 ns) 245.08 ns 249.44 ns 250.02 ns
Buffer.fill 16384 bytes with 11 byte value        250 ns/iter (243.79 ns … 264.95 ns) 251.09 ns 261.87 ns  263.7 ns
Buffer.fill 2097152 bytes with 4 byte value     36.78 µs/iter   (35.88 µs … 71.83 µs)  36.92 µs  40.33 µs  42.17 µs
Buffer.fill 2097152 bytes with 8 byte value      36.4 µs/iter      (35 µs … 93.96 µs)  36.42 µs  41.71 µs  42.83 µs
Buffer.fill 2097152 bytes with 16 byte value    35.99 µs/iter   (35.13 µs … 62.58 µs)     36 µs  38.83 µs  40.46 µs
Buffer.fill 2097152 bytes with 11 byte value    35.17 µs/iter   (34.29 µs … 68.75 µs)  35.04 µs  41.25 µs  42.92 µs
Buffer.fill 16777216 bytes with 4 byte value   459.35 µs/iter (410.13 µs … 558.08 µs) 475.38 µs 514.38 µs 526.79 µs
Buffer.fill 16777216 bytes with 8 byte value   471.42 µs/iter    (438.75 µs … 580 µs)  478.5 µs 530.96 µs 547.08 µs
Buffer.fill 16777216 bytes with 16 byte value  463.69 µs/iter (435.75 µs … 522.29 µs) 468.92 µs 497.17 µs 503.21 µs
Buffer.fill 16777216 bytes with 11 byte value  460.78 µs/iter     (414 µs … 654.5 µs)    468 µs 558.88 µs 578.25 µs

After:

❯ ./build/release/bun /Users/dylan/code/bun/bench/snippets/buffer-fill.mjs
cpu: Apple M1 Max
runtime: bun 1.1.31 (arm64-darwin)

benchmark                                          time (avg)             (min … max)       p75       p99      p995
------------------------------------------------------------------------------------- -----------------------------
Buffer.fill 32 bytes with 4 byte value          19.61 ns/iter    (18.9 ns … 24.89 ns)  19.57 ns  22.37 ns  23.15 ns
Buffer.fill 32 bytes with 8 byte value          17.81 ns/iter   (16.73 ns … 31.59 ns)   17.6 ns  21.53 ns  22.71 ns
Buffer.fill 32 bytes with 16 byte value         14.13 ns/iter   (13.88 ns … 24.08 ns)  14.07 ns  16.13 ns   16.9 ns
Buffer.fill 32 bytes with 11 byte value         19.03 ns/iter    (18.62 ns … 27.8 ns)  18.86 ns  22.32 ns  22.89 ns
Buffer.fill 2048 bytes with 4 byte value        36.91 ns/iter  (35.69 ns … 345.48 ns)  36.15 ns  42.69 ns  44.08 ns
Buffer.fill 2048 bytes with 8 byte value        35.23 ns/iter   (34.66 ns … 60.75 ns)  35.11 ns  39.97 ns     42 ns
Buffer.fill 2048 bytes with 16 byte value       34.75 ns/iter    (34.25 ns … 43.4 ns)  34.69 ns  38.99 ns  40.24 ns
Buffer.fill 2048 bytes with 11 byte value       73.45 ns/iter   (72.39 ns … 90.92 ns)  73.46 ns   78.9 ns  80.79 ns
Buffer.fill 16384 bytes with 4 byte value      181.37 ns/iter  (179.1 ns … 200.78 ns) 181.72 ns 194.29 ns 196.05 ns
Buffer.fill 16384 bytes with 8 byte value      178.02 ns/iter  (176.37 ns … 194.8 ns) 178.23 ns 190.41 ns 193.99 ns
Buffer.fill 16384 bytes with 16 byte value     177.86 ns/iter  (176.53 ns … 187.2 ns) 178.36 ns 183.72 ns 184.47 ns
Buffer.fill 16384 bytes with 11 byte value     260.66 ns/iter (235.24 ns … 812.54 ns) 254.61 ns 732.31 ns 799.64 ns
Buffer.fill 2097152 bytes with 4 byte value     34.17 µs/iter     (33 µs … 246.79 µs)  33.79 µs   41.5 µs  44.58 µs
Buffer.fill 2097152 bytes with 8 byte value     33.97 µs/iter  (33.08 µs … 117.75 µs)  33.75 µs  40.17 µs  42.08 µs
Buffer.fill 2097152 bytes with 16 byte value    33.79 µs/iter      (33 µs … 50.71 µs)  33.71 µs  36.96 µs  38.46 µs
Buffer.fill 2097152 bytes with 11 byte value     35.7 µs/iter   (34.88 µs … 55.33 µs)  35.71 µs     39 µs  41.42 µs
Buffer.fill 16777216 bytes with 4 byte value   272.61 µs/iter    (268.08 µs … 848 µs) 269.83 µs 319.63 µs 334.13 µs
Buffer.fill 16777216 bytes with 8 byte value   270.25 µs/iter (267.46 µs … 334.83 µs) 269.67 µs 292.08 µs 297.46 µs
Buffer.fill 16777216 bytes with 16 byte value  270.97 µs/iter (268.58 µs … 374.13 µs) 270.17 µs 297.96 µs 301.63 µs
Buffer.fill 16777216 bytes with 11 byte value  485.21 µs/iter   (438.13 µs … 2.95 ms) 469.88 µs   1.03 ms    1.6 ms

Byte length of 11 is also tested to show results when memset_patternN isn't used.

How did you verify your code works?

Existing tests

@robobun
Copy link

robobun commented Oct 16, 2024

@dylan-conway, your commit e5d7296 has 12 failures in #4907:

  • test/js/node/test/parallel/zlib.test.js - 1 failing on 🍎 14 aarch64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🍎 13 x64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🍎 13 aarch64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🍎 14 x64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🪟 x64-baseline
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🪟 x64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🍎 14 aarch64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🐧 22.04 x64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🐧 12 x64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🐧 20.04 x64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🐧 22.04 x64-baseline
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🐧 20.04 x64-baseline
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🐧 12 x64-baseline
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🐧 12 aarch64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🐧 20.04 aarch64
  • test/js/node/test/parallel/http2-server-rst-before-respond.test.js - 1 failing on 🐧 22.04 aarch64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🍎 13 x64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🍎 13 aarch64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🍎 14 x64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🍎 14 aarch64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🐧 12 x64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🐧 20.04 x64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🐧 22.04 x64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🐧 12 x64-baseline
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🐧 20.04 x64-baseline
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🐧 22.04 x64-baseline
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🐧 20.04 aarch64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🐧 22.04 aarch64
  • test/js/node/test/parallel/http2-large-write-close.test.js - 1 failing on 🐧 12 aarch64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🍎 13 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🍎 13 aarch64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🍎 14 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🪟 x64-baseline
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🪟 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🍎 14 aarch64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🐧 22.04 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🐧 12 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🐧 20.04 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🐧 22.04 x64-baseline
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🐧 20.04 x64-baseline
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🐧 12 x64-baseline
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🐧 12 aarch64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🐧 20.04 aarch64
  • test/js/node/test/parallel/http2-compat-write-early-hints.test.js - timeout on 🐧 22.04 aarch64
  • test/integration/next-pages/test/next-build.test.ts - 1 failing on 🪟 x64
  • test/js/bun/http/bun-serve-static.test.ts - annotation error on 🍎 13 aarch64
  • test/js/bun/http/fetch-file-upload.test.ts - 1 failing on 🪟 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🪟 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🍎 13 aarch64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🍎 14 aarch64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🍎 14 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🍎 13 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🐧 12 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🐧 20.04 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🐧 22.04 x64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🐧 12 x64-baseline
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🐧 20.04 x64-baseline
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🐧 22.04 x64-baseline
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🐧 20.04 aarch64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🐧 22.04 aarch64
  • test/js/node/test/parallel/http2-compat-write-early-hints-invalid-argument-type.test.js - 1 failing on 🐧 12 aarch64
  • test/cli/watch/watch.test.ts - 2 failing on 🪟 x64-baseline
  • test/cli/watch/watch.test.ts - 2 failing on 🪟 x64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🍎 14 aarch64
  • test/cli/hot/watch.test.ts - 1 failing on 🪟 x64
  • test/cli/hot/watch.test.ts - 1 failing on 🪟 x64-baseline
  • test/bundler/bundler_edgecase.test.ts - 1 failing on 🪟 x64
  • @dylan-conway dylan-conway merged commit 7283453 into main Oct 16, 2024
    25 checks passed
    @dylan-conway dylan-conway deleted the dylan/memset_pattern branch October 16, 2024 04:16
    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 this pull request may close these issues.

    3 participants