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

avoid double check !isBuffer #7

Closed
wants to merge 2 commits into from
Closed

Conversation

hex7c0
Copy link

@hex7c0 hex7c0 commented Sep 24, 2014

Hi,
if you want to use var buf, are you free to close this PR :)

@dougwilson
Copy link
Contributor

So the main reason it was var buf was that under certain conditions, writing to the variable that is mapped to an argument can kill the function's optimizations. I'm not 100% if that's the case here, but just giving some history of why it didn't just overwrite entity before (because, well, I didn't want to have to figure out if it was a penalty case or not :) )

@hex7c0
Copy link
Author

hex7c0 commented Sep 24, 2014

gotcha 👍

tl;dr

commit, md4

> node benchmark/index.js

> node benchmark/body0-100b.js

  100B body

  4 tests completed.

  buffer - strong x   307,236 ops/sec ±1.89% (188 runs sampled)
  buffer - weak   x 1,146,018 ops/sec ±0.55% (196 runs sampled)
  string - strong x   178,177 ops/sec ±1.78% (188 runs sampled)
  string - weak   x   341,098 ops/sec ±0.61% (195 runs sampled)

> node benchmark/body1-1kb.js

  1KB body

  4 tests completed.

  buffer - strong x 222,709 ops/sec ±1.72% (191 runs sampled)
  buffer - weak   x 294,112 ops/sec ±0.77% (196 runs sampled)
  string - strong x 134,743 ops/sec ±2.50% (187 runs sampled)
  string - weak   x 159,173 ops/sec ±1.78% (188 runs sampled)

> node benchmark/body2-5kb.js

  5KB body

  4 tests completed.

  buffer - strong x 94,987 ops/sec ±1.19% (192 runs sampled)
  buffer - weak   x 96,372 ops/sec ±1.12% (195 runs sampled)
  string - strong x 48,524 ops/sec ±6.49% (172 runs sampled)
  string - weak   x 49,302 ops/sec ±6.64% (173 runs sampled)

> node benchmark/body3-10kb.js

  10KB body

  4 tests completed.

  buffer - strong x 55,977 ops/sec ±0.77% (195 runs sampled)
  buffer - weak   x 56,101 ops/sec ±0.93% (194 runs sampled)
  string - strong x 34,054 ops/sec ±5.53% (179 runs sampled)
  string - weak   x 34,195 ops/sec ±5.61% (180 runs sampled)

> node benchmark/body4-100kb.js

  100KB body

  4 tests completed.

  buffer - strong x 6,617 ops/sec ±0.60% (197 runs sampled)
  buffer - weak   x 6,630 ops/sec ±0.52% (196 runs sampled)
  string - strong x 4,862 ops/sec ±3.07% (183 runs sampled)
  string - weak   x 4,855 ops/sec ±3.11% (182 runs sampled)

orig, md5

> node benchmark/index.js

> node benchmark/body0-100b.js

  100B body

  4 tests completed.

  buffer - strong x   303,749 ops/sec ±1.88% (185 runs sampled)
  buffer - weak   x 1,133,652 ops/sec ±0.51% (196 runs sampled)
  string - strong x   174,857 ops/sec ±1.71% (190 runs sampled)
  string - weak   x   341,315 ops/sec ±1.47% (192 runs sampled)

> node benchmark/body1-1kb.js

  1KB body

  4 tests completed.

  buffer - strong x 205,874 ops/sec ±1.63% (191 runs sampled)
  buffer - weak   x 294,107 ops/sec ±0.66% (196 runs sampled)
  string - strong x 127,550 ops/sec ±2.64% (187 runs sampled)
  string - weak   x 159,006 ops/sec ±1.72% (188 runs sampled)

> node benchmark/body2-5kb.js

  5KB body

  4 tests completed.

  buffer - strong x 86,839 ops/sec ±1.14% (192 runs sampled)
  buffer - weak   x 87,445 ops/sec ±1.19% (193 runs sampled)
  string - strong x 46,031 ops/sec ±6.19% (175 runs sampled)
  string - weak   x 45,623 ops/sec ±6.65% (175 runs sampled)

> node benchmark/body3-10kb.js

  10KB body

  4 tests completed.

  buffer - strong x 50,551 ops/sec ±0.75% (195 runs sampled)
  buffer - weak   x 50,261 ops/sec ±1.08% (195 runs sampled)
  string - strong x 32,204 ops/sec ±5.24% (179 runs sampled)
  string - weak   x 32,043 ops/sec ±5.40% (180 runs sampled)

> node benchmark/body4-100kb.js

  100KB body

  4 tests completed.

  buffer - strong x 5,914 ops/sec ±0.65% (196 runs sampled)
  buffer - weak   x 5,904 ops/sec ±0.58% (196 runs sampled)
  string - strong x 4,478 ops/sec ±2.93% (186 runs sampled)
  string - weak   x 4,495 ops/sec ±3.03% (184 runs sampled)

@dougwilson
Copy link
Contributor

I have to think about changing MD5 to MD4 for strong ETags, though, but I can certainly change the large content weak ETags to use MD4 right away, since collisions don't particularly matter.

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

Successfully merging this pull request may close these issues.

2 participants