question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

poor performance on pipeline with buffers

See original GitHub issue

Hi everyone. I’m trying to insert into redis about 15k buffers but getting poor performance. But if I try to insert same amount of data using JSON.stringify it works fast.

const pipe = redis.pipeline();
users.map(user => {
   pipe.set(`{users}:${user.id}`, UserModel.encode(user));
});
pipe.exec();
console.log("done");

on pipe.exec(); code gets freeze about for 10 seconds.

Update: UserModel is protobuf. But this does not matters: Buffer.from(JSON.stringify(user)) is also same.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
luincommented, Oct 6, 2019

Hi @GGeorgi, Could you provide a reproducible example so I can test on my machine? I used the following code and the performance is good (v4.14.1):

const Redis = require('ioredis')
const faker = require('faker')

const redis = new Redis()

// Create a buffer from an object
function encode(obj) {
  return Buffer.from(JSON.stringify(obj))
}

// Generate some fake users
const users = new Array(150000).fill(0).map(() => (
  {
    id: Math.random() * 100000 | 0,
    name: faker.name.findName(),
    email: faker.internet.email(),
    avatar: faker.internet.avatar(),
    ip: faker.internet.ip(),
    phone: faker.phone.phoneNumber(),
    company: faker.company.companyName(),
    createdAt: faker.date.past()
  }
))

const pipe = redis.pipeline();
users.map(user => {
  pipe.set(`{users}:${user.id}`, encode(user));
});

console.log('Start #exec()')
console.time('exec')
pipe.exec();
console.timeEnd('exec')

Prints:

Start #exec()
exec: 38.897ms
0reactions
stale[bot]commented, Nov 22, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pipeline Buffering - Wiley Online Library
Buffer cycles make variable throughput cycles farther apart without introducing more slow cycle delays. The effect of this is to increase shadow coverage...
Read more >
Pipelines and performance - virtualdub.org
If you don't have enough buffering between two stages then the pipeline will flood when the first stage writes to it, causing the...
Read more >
Low performance when recording command buffers with ...
The writebuffer is a pointer to the secondary command buffer that will be recorded. The pipeline is a pointer to the graphics pipeline...
Read more >
Performance Improvement from the GStreamer Perspective
The real-time performance is always measured relative to the pipeline clock and typically happens in the sinks when they synchronize buffers against the...
Read more >
Chapter 28. Graphics Pipeline Performance - NVIDIA Developer
This is the cost of running the "pixel shader" or "fragment shader." Note that fragment shading and frame-buffer bandwidth are often lumped together...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found