Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

[dynamodb] Performance optimizations #5826

Merged
merged 4 commits into from
Apr 2, 2019

Conversation

ssalonen
Copy link
Contributor

@ssalonen ssalonen commented Mar 3, 2019

This PR introduces several performance optimizations to DynamoDB Persistence Service:

  • buffering data in the PersistenceService, and writing it in batches on background.
    We get performance gains by writing data in batches but also reduce
    items QueueingThreadPoolExecutor.taskQueue pressure in GenericItem.notifyListeners.
  • previously several checks were done on each store, causing
    significant overhead on store and query operations: 1) connection check
    (listing tables), 2) checking table existence. These are now removed,
    table is created on error (ResourceNotFoundException).

In addition, I have implemented exponential back-off retry for writes.

I've been verified the changes in my local setup. Before I could see that QueueingThreadPoolExecutor.taskQueue size growed (temporarily, but still) up to 500-1500 when many items were persisted at the same time. Dealing with the queue took some noticeable time. With the improvements, the size remains close to zero all the time.

Signed-off-by: Sami Salonen [email protected]

ssalonen added 2 commits March 2, 2019 14:47
- buffering data in the PersistenceService, and writing it in batches.
  We get performance gains by writing data in batches but also reduce
  items queue pressure in GenericItem.notifyListeners.
- previously several checks were done on each store, causing
  significant overhead: 1) connection check
  (listing tables), 2) checking table existence. These are now removed,
  table is created on error (ResourceNotFoundException).

Signed-off-by: Sami Salonen <[email protected]>
@ssalonen
Copy link
Contributor Author

ssalonen commented Mar 3, 2019

With the old version, I could see that sometimes QueueingThreadPoolExecutor.taskQueue growed to enormous sizes (even 1M), leading to OoM.

It's hard to diagnose what is the root cause for these occasional issues but I think writing in batches should be able to deal with even larger backlogs of data.

@ssalonen
Copy link
Contributor Author

Anything I can do to progress this?

@9037568
Copy link
Contributor

9037568 commented Mar 28, 2019

Sorry, @ssalonen . My free time has been very low lately.
I'll try to look at this this weekend. I fear we're in danger of crossing over with Kai's work on removing the persistence layer in #5844.

@ssalonen
Copy link
Contributor Author

I understand completely, you have enormous work load in this repo alone.

Oh I was not aware of #5844, I think it #5827 can be dropped for now since the bnd build system will make it easier to handle SDK as maven dependency.

@kaikreuzer
Copy link
Member

@ssalonen Would be cool if you could help on getting dynamodb (incl. your improvements) ready in https://github.com/openhab/openhab2-addons/pull/5275 - this is one of the addons, which I didn't yet spend the work to make it compile with bnd as it has a huge list of included libs.

Feel free to create a PR against my branch of that PR - merging your improvements should be very easy as I didn't do any real changes to the source code.

Copy link
Contributor

@9037568 9037568 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few little tweaks.

@ssalonen
Copy link
Contributor Author

ssalonen commented Apr 1, 2019

@9037568 thank you for the review. Addressed the comments in 6900a08 & 0f3cf54.

@9037568
Copy link
Contributor

9037568 commented Apr 2, 2019

Thanks, @ssalonen !

@9037568 9037568 merged commit 4ae4da5 into openhab:master Apr 2, 2019
@kaikreuzer
Copy link
Member

@ssalonen Could you please have a look at https://ci.openhab.org/job/openHAB1-Addons/lastCompletedBuild/org.openhab.persistence$org.openhab.persistence.dynamodb.test/testReport/? It seems that this PR made one test fail now.

@wborn wborn added this to the 1.14.0 milestone Dec 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants