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

feat: run inserts in batch and in parallel when processing new block #1818

Merged

Conversation

bestmike007
Copy link
Contributor

@bestmike007 bestmike007 commented Jan 10, 2024

Description

This PR improves the new block process improvements by means of running inserts in batch and in parallel.

Previously when the event server process a new block, it roughly process less than 10 transactions per second.
When tested with concurrency=100, it processes more than 30 transactions per second.

Type of Change

Performance improvements.

Does this introduce a breaking change?

No.

Are documentation updates required?

No.

Testing information

No changes required.

Checklist

  • Code is commented where needed
  • Unit test coverage for new or modified code paths
  • npm run test passes
  • Changelog is updated
  • Tag 1 of @rafaelcr or @zone117x for review

Signed-off-by: bestmike007 <i@bestmike007.com>
@bestmike007
Copy link
Contributor Author

@rafaelcr @zone117x please help me review this.

Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (c5a7a8c) 71.61% compared to head (b005dd4) 71.76%.
Report is 1 commits behind head on master.

Files Patch % Lines
src/datastore/pg-write-store.ts 96.00% 5 Missing ⚠️
...play/parquet-based/importers/new-block-importer.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1818      +/-   ##
==========================================
+ Coverage   71.61%   71.76%   +0.14%     
==========================================
  Files          91       91              
  Lines       11771    11817      +46     
  Branches     2612     2616       +4     
==========================================
+ Hits         8430     8480      +50     
+ Misses       3188     3184       -4     
  Partials      153      153              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: bestmike007 <i@bestmike007.com>
Signed-off-by: bestmike007 <i@bestmike007.com>
.env Outdated Show resolved Hide resolved
… min value

Signed-off-by: bestmike007 <i@bestmike007.com>
Signed-off-by: bestmike007 <i@bestmike007.com>
Signed-off-by: bestmike007 <i@bestmike007.com>
Copy link
Collaborator

@rafaelcr rafaelcr left a comment

Choose a reason for hiding this comment

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

This looks good to me. We'd like to cut a pre-release Docker image with this PR and run a few tests so we can measure how it performs in the kubernetes pods, especially when interacting with postgres over a network connection.

I'll create a beta branch and target your PR into it so we can merge there and we can run tests on our end @bestmike007 , sound good? cc @zone117x

@rafaelcr rafaelcr changed the base branch from master to beta January 10, 2024 20:24
Copy link
Member

@zone117x zone117x left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this contribution!

@bestmike007
Copy link
Contributor Author

It'd be better if you run with different concurrency values, and then decide the default value.

@rafaelcr rafaelcr merged commit 86dfdb5 into hirosystems:beta Jan 10, 2024
28 of 30 checks passed
blockstack-devops pushed a commit that referenced this pull request Jan 11, 2024
## [7.8.0-beta.1](v7.7.1...v7.8.0-beta.1) (2024-01-11)

### Features

* run inserts in batch and in parallel when processing new block ([#1818](#1818)) ([86dfdb5](86dfdb5))

### Bug Fixes

* log block event counts after processing ([#1820](#1820)) ([9c39743](9c39743)), closes [#1819](#1819) [#1819](#1819)
@blockstack-devops
Copy link

🎉 This PR is included in version 7.8.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

rafaelcr added a commit that referenced this pull request Jan 18, 2024
blockstack-devops pushed a commit that referenced this pull request Jan 23, 2024
## [7.8.0](v7.7.2...v7.8.0) (2024-01-23)

### Features

* add `/extended/v2/smart-contracts/status` endpoint ([#1833](#1833)) ([3535c11](3535c11))
* run inserts in batch and in parallel when processing new block ([#1818](#1818)) ([86dfdb5](86dfdb5))
* upgrade to node 20, use bookworm-slim image ([#1832](#1832)) ([0a42109](0a42109))

### Bug Fixes

* change all HASH indexes to BTREE to optimize writes ([#1825](#1825)) ([234936b](234936b))
* log block event counts after processing ([#1820](#1820)) ([9c39743](9c39743)), closes [#1819](#1819) [#1819](#1819)
* optimize re-org queries and indexes ([#1821](#1821)) ([5505d35](5505d35))
* parallelize re-org update queries ([#1835](#1835)) ([340a304](340a304))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants