Auto-detect parallelism for pg_dump and pg_restore from RDS instance type#341
Open
Auto-detect parallelism for pg_dump and pg_restore from RDS instance type#341
Conversation
Resolve optimal -j values automatically: use EC2 DescribeInstanceTypes to determine vCPU count of the RDS clone (for pg_dump parallelism) and runtime.NumCPU for the local machine (for pg_restore parallelism). Pass both values through the existing ConfigProjection when updating DBLab config during refresh. https://claude.ai/code/session_01AhnBVCBWjk24T7BBQtmkbq
Drop the aws-sdk-go-v2/service/ec2 dependency entirely. Instead of calling DescribeInstanceTypes (which required ec2:DescribeInstanceTypes IAM permission and added ~5s IMDS timeout in tests), parse vCPU count from the RDS instance class size suffix using a static map of standard AWS size-to-vCPU mappings. Unlisted NUMxlarge sizes are handled via multiplier parsing. https://claude.ai/code/session_01AhnBVCBWjk24T7BBQtmkbq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add automatic parallelism detection for pg_dump and pg_restore operations based on vCPU counts. The dump parallelism is determined by querying the RDS clone instance type's vCPU count via EC2 API, while restore parallelism is based on the local machine's CPU count.
Key Changes
New parallelism module (
parallelism.go): Implements vCPU detection logicResolveParallelism(): Main entry point that determines optimal parallelism levelslookupInstanceVCPUs(): Queries EC2 API for RDS instance type vCPU informationrdsClassToEC2Type(): Converts RDS instance class format (e.g., "db.m5.xlarge") to EC2 type format ("m5.xlarge")resolveLocalVCPUs(): Returns the local machine's CPU countComprehensive test coverage (
parallelism_test.go): Tests all parallelism resolution functions with mocked EC2 APIIntegration with refresh workflow (
refresher.go):DBLab config updates (
dblab.go):SourceConfigUpdatestruct withDumpParallelJobsandRestoreParallelJobsfieldsUpdateSourceConfig()to conditionally include parallelism settings (only when > 0)Test coverage (
dblab_test.go):Implementation Details
https://claude.ai/code/session_01AhnBVCBWjk24T7BBQtmkbq