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

Add byte level details to list progress command #503

Merged
merged 4 commits into from
Nov 22, 2023

Conversation

hanefi
Copy link
Contributor

@hanefi hanefi commented Oct 18, 2023

This patch allows reporting the total number of bytes transferred during
a copy operation. However, it has a limitation that the reported value
is only updated after each table is copied. This is because we do not
update table summary files while the copy is in progress.

Changes include:

  • 3 new fields in table summary structures:
    • network.bytes: total number of bytes transmitted
    • network.bytes-pretty: pretty printed form of network.bytes
    • network.transmit-rate: pretty printed bytes transmitted per second
  • Some new fields on the pgcopydb list progress --json --summary
    command:
    • steps[].network is a new field that exists for COPY step and has
      the following fields:
      • bytes: total number of bytes transmitted for all tables
      • bytes-pretty: pretty printed form of bytes
    • tables[].network is a new json value with the following fields:
      • bytes: total number of bytes transmitted for table
      • bytes-pretty: pretty printed form of bytes
      • transmit-rate: pretty printed bytes transmitted per second
  • A new column on top level summary that shows total number of bytes
    copied.

@dimitri dimitri added this to the v0.14 milestone Oct 26, 2023
This patch allows reporting the total number of bytes transferred during
a copy operation. However, it has a limitation that the reported value
is only updated after each table is copied. This is because we do not
update table summary files while the copy is in progress.

Changes include:
- 3 new fields in table summary structures:
  - network.bytes: total number of bytes transmitted
  - network.bytes-pretty: pretty printed form of network.bytes
  - network.transmit-rate: pretty printed bytes transmitted per second
- Some new fields on the `pgcopydb list progress --json --summary`
  command:
  - steps[].network is a new field that exists for COPY step and has
    the following fields:
	- bytes: total number of bytes transmitted for all tables
	- bytes-pretty: pretty printed form of bytes
  - tables[].network is a new json value with the following fields:
	- bytes: total number of bytes transmitted for table
	- bytes-pretty: pretty printed form of bytes
	- transmit-rate: pretty printed bytes transmitted per second
- A new column on top level summary that shows total number of bytes
  copied.
Comment on lines +37 to +43
char bytesPretty[BUFSIZE] = { 0 };
pretty_print_bytes(bytesPretty, BUFSIZE, summary->bytesTransmitted);

char transmitRate[BUFSIZE] = { 0 };
pretty_print_bytes_per_second(transmitRate, BUFSIZE, summary->bytesTransmitted,
summary->durationMs);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not want to store bytesPretty and transmitRate in CopyTableSummary structs.

  1. It is inexpensive to have an integer addition in our copy loop, unlike pretty printing said value. I did not want to store bytes and bytesPretty when I can only update the primitive type and not keep the other in sync.
  2. Calculating the transmitRate in real time is also an expensive operation similar to bytesPretty that was discussed in earlier item. Also, I needed to have the duration information that is not always there when the command is running.
  3. If resuming an earlier operation, reading an integer value for bytes from disk makes sense. All the other values can be generated from bytes and duration information.

src/bin/pgcopydb/summary.c Show resolved Hide resolved
Comment on lines 894 to 906
Step Connection Duration Transfer Concurrency
-------------------------------------------------- ---------- ---------- ---------- ------------
Dump Schema source 225ms 1
Catalog Queries (table ordering, filtering, etc) source 842ms 1
Prepare Schema target 694ms 1
COPY, INDEX, CONSTRAINTS, VACUUM (wall clock) both 1s538 8 + 12
COPY (cumulative) both 2s771 2955 kB 8
Large Objects (cumulative) both 242ms 1
CREATE INDEX, CONSTRAINTS (cumulative) target 3s489 12
Finalize Schema target 654ms 1
-------------------------------------------------- ---------- ---------- ---------- ------------
Total Wall Clock Duration both 3s984 8 + 12
-------------------------------------------------- ---------- ---------- ---------- ------------
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: In this patch, most of the data in the top-level duration tables are made up.

Copy link
Owner

Choose a reason for hiding this comment

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

All the numbers in the docs to this point where obtained by actual runs and copy/pasted. When that make sense, runs from the test suite, ensuring they're easy to replicate, and that we're in the right ballpark. Please consider the same approach here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created a local prototype that can produce reproducible documentation examples. I used a copy of pagila tests as a starting point and I copied commands from our current documentation. Finally I copy pasted command outputs to the docs.

Hopefully, I will open a separate PR with my changes for reproducible documentation example generation after polishing it some more.

@hanefi hanefi marked this pull request as ready for review November 14, 2023 21:53
@hanefi hanefi requested a review from dimitri November 14, 2023 21:53
Copy link
Owner

@dimitri dimitri left a comment

Choose a reason for hiding this comment

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

Almost ready for merge, thanks! Still some areas to review and change, see below for details.

Comment on lines 894 to 906
Step Connection Duration Transfer Concurrency
-------------------------------------------------- ---------- ---------- ---------- ------------
Dump Schema source 225ms 1
Catalog Queries (table ordering, filtering, etc) source 842ms 1
Prepare Schema target 694ms 1
COPY, INDEX, CONSTRAINTS, VACUUM (wall clock) both 1s538 8 + 12
COPY (cumulative) both 2s771 2955 kB 8
Large Objects (cumulative) both 242ms 1
CREATE INDEX, CONSTRAINTS (cumulative) target 3s489 12
Finalize Schema target 654ms 1
-------------------------------------------------- ---------- ---------- ---------- ------------
Total Wall Clock Duration both 3s984 8 + 12
-------------------------------------------------- ---------- ---------- ---------- ------------
Copy link
Owner

Choose a reason for hiding this comment

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

All the numbers in the docs to this point where obtained by actual runs and copy/pasted. When that make sense, runs from the test suite, ensuring they're easy to replicate, and that we're in the right ballpark. Please consider the same approach here.

src/bin/pgcopydb/string_utils.c Outdated Show resolved Hide resolved
@dimitri dimitri modified the milestones: v0.14, v0.15 Nov 20, 2023
This commit addresses 2 issues raised in the review:
1. Using a SI standards when reporting data-rate units
2. Updating the relevant documentation with reproducible examples

The documentation update is done in a way that allowed me to run the
commands in a docker environment. Once I polish my changes in this
docker environment, I will update all the documentation with it and
share it in a separate PR.
@dimitri dimitri merged commit 8ce63dd into dimitri:main Nov 22, 2023
16 checks passed
@hanefi hanefi deleted the byte-level-progress branch November 23, 2023 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants