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

Fix slow V8 string operations in node 0.10 #237

Merged
merged 1 commit into from Mar 19, 2015
Merged

Fix slow V8 string operations in node 0.10 #237

merged 1 commit into from Mar 19, 2015

Conversation

ghost
Copy link

@ghost ghost commented Mar 10, 2015

I managed to reproduce the issue mentioned in #205 with the script below. Hopefully, you'll be able to see the latency spikes when you run the script (from ~10ms to ~80ms).

Please run on node 0.10.

slow-set.js:

'use strict';

var Memcached = require('./');

var currentSize = 515000;
var endSize = 525000;
var inc = 100;

function createStringOfSize(size) {
  var buffer = new Buffer(size);
  buffer.fill('x');
  return buffer.toString();
}

function loopUntilComplete() {
  if (currentSize < endSize) return setKey(loopUntilComplete);
  process.exit(0);
}

function setKey(cb) {
  console.time('memcached.set');
  var key = 'default:' + 'foobydoo'; // slow
  //var key = 'default:foobydoo'; // fast
  var value = createStringOfSize(currentSize);

  memcached.set(key, value, 300, function(err) {
    if (err) throw err;
    console.timeEnd('memcached.set');
    console.log("Set cache key foobydoo with object of length " + currentSize);
    currentSize += inc;
    cb(err);
  });
}

var memcached = new Memcached(['localhost:11211'], {
  retry: 1000,
  timeout: 100,
  reconnect: 300000,
  poolSize: 100
});

loopUntilComplete();

3rd-Eden added a commit that referenced this pull request Mar 19, 2015
Fix slow V8 string operations in node 0.10
@3rd-Eden 3rd-Eden merged commit dd3dbe9 into 3rd-Eden:master Mar 19, 2015
@3rd-Eden
Copy link
Owner

Thanks for providing a reproducible test case for this and fixing all the things affected!

@ghost ghost deleted the ck-fix-v8-string-issue branch March 23, 2015 00:51
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.

None yet

1 participant