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.

[BUG] Performance issues when schema has data Buffer type

See original GitHub issue

Summary:

The DDB records have a binary data size of 200KB approximately. When I use Dynamoose the scan took 18 seconds, when, I use AWS DDB client, it takes ~100ms.

I suspect that Dynamoose has some performance issues in a Buffer type serialization. When I remove a field with Buffer type from the schema, it starts working fast as expected.

Code sample:

console.time('scan');
const result = await myModel.scan().exec();
console.timeEnd('scan');
console.log(result);

Schema

const mySchema = {
  site: {
    type: Object,
    required: true,
    schema: {
      pages: {
        type: Buffer,
        required: true
      },
      ...
    }
  }
}

Model

const DEFAULT_OPTIONS = {create: false, waitForActive: {enabled: false}};

const myModel: ModelType<MyEntity> & IMyModelMethods = dynamoose.model<MyEntity>(
  'MyTable',
  mySchema,
  DEFAULT_OPTIONS
) as ModelType<MyEntity> & IMyModelMethods;

Current output and behavior (including stack trace):

scan: 19.177s // <---- That's the issue

{
...
count: 53,
scannedCount: 53,
timesScanned: 1,
}

Expected output and behavior:

The scan should take much less than 19 seconds.

Environment:

Operating System: MacOS Operating System Version: 11.3.1 Node.js version (node -v): v14.16.0 NPM version: (npm -v): 6.14.11 Dynamoose version: 2.7.3

Other:

  • I have read through the Dynamoose documentation before posting this issue
  • I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
  • I have searched the internet and Stack Overflow to ensure this issue hasn’t been raised or answered before
  • I have tested the code provided and am confident it doesn’t work as intended
  • I have filled out all fields above
  • I am running the latest version of Dynamoose

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
fishcharliecommented, May 14, 2021

@bushev That is helpful. I’ll try to run this sometime soon. Sadly I’m going out of town and won’t be back until the 24th. I’ll see if I can carve out sometime during that trip to look into this more, but no guarantees on that front.

Sorry you are running into this, and hopefully I’ll be able to look into this more soon.

0reactions
fishcharliecommented, Aug 14, 2021

Fixed by #1225

Read more comments on GitHub >

github_iconTop Results From Across the Web

sql server - How can I Debug a Buffer Issue?
I think that is why I am able to see high performance with as little memory as I have. Also a large portion...
Read more >
Chapter 4, Optimizing Schema and Data Types - O'Reilly
The performance improvement from changing NULL columns to NOT NULL is usually small, so don't make it a priority to find and change...
Read more >
Troubleshoot slow SQL Server performance caused by I/O ...
Occurs when a task is waiting on a latch for a data or index page (buffer) in an I/O request. The latch request...
Read more >
Insight into the SQL Server buffer cache - SQLShack
Even SSDs are slow when compared to high-performance memory. The way in which software deals with this problem is to write data from...
Read more >
Best Practices for Using IndexedDB - web.dev
The reason is because when IndexedDB stores an object, it must first create a structured clone of that object, and the structured cloning ......
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