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

Write dump information and dump progress bar to stderr when verbose m… #113

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

guvra
Copy link
Collaborator

@guvra guvra commented Feb 26, 2024

When -v option is provided, display information about the dump, as well as a progress bar.

Screenshot from 2024-02-26 17-06-53

@guvra
Copy link
Collaborator Author

guvra commented Feb 26, 2024

Fixes #111

@guvra
Copy link
Collaborator Author

guvra commented Feb 26, 2024

@staabm is the current implementation ok for your use case?

@guvra guvra force-pushed the feat-dump-info-stderr branch 2 times, most recently from afc6752 to dcaa8c8 Compare February 26, 2024 15:07
@staabm
Copy link
Contributor

staabm commented Feb 26, 2024

thanks for working on my feature request. I will have some time in the following days to look into the change and test it .

I will report back

@guvra guvra force-pushed the feat-dump-info-stderr branch 3 times, most recently from 5b83ac0 to 0be168a Compare February 27, 2024 13:22
@guvra
Copy link
Collaborator Author

guvra commented Feb 27, 2024

After testing it with a big database, I found out that the setInfoHook function provided by mysqldump-php is triggered after the table was dumped, not before.

So when a table name is displayed in the progress bar, it's not actually dumping this table, it's dumping the next table...

@staabm
Copy link
Contributor

staabm commented Feb 27, 2024

thanks again for working on it.

I tried it on a bigger schema, and have the following feedback:
I wonder whether we could use a undetermined progress bar and print progress every X thousand rows.
in my case with millions of rows in a single table it still looks like no progress is going on.

it might also make sense to look into redraw-parameters, as the symfony console per default redraws every 100ms, which is waaay too fast for our progress. I think once every second or similar would be plenty.

https://symfony.com/doc/current/components/console/helpers/progressbar.html#bar-settings

// this redraws the screen every 100 iterations, but sets additional limits:
// don't redraw slower than 200ms (0.2) or faster than 100ms (0.1)
$progressBar->setRedrawFrequency(100);
$progressBar->maxSecondsBetweenRedraws(0.2);
$progressBar->minSecondsBetweenRedraws(0.1);

@guvra
Copy link
Collaborator Author

guvra commented Feb 27, 2024

thanks again for working on it.

I tried it on a bigger schema, and have the following feedback: I wonder whether we could use a undetermined progress bar and print progress every X thousand rows. in my case with millions of rows in a single table it still looks like no progress is going on.

I don't think it's possible with the current implementation of the cli 😞
The dumper is executed in the same process as the cli, so when mysqldump-php is dumping a table, the whole process is blocked, and the progress bar cannot be updated.
It can only be updated when the hook from setInfoHook is triggered (once per table).

it might also make sense to look into redraw-parameters, as the symfony console per default redraws every 100ms, which is waaay too fast for our progress. I think once every second or similar would be plenty.

Does it redraw anything when mysqldump-php is dumping a table though?
It looks like the progress bar is redrawn only when the bar progresses (so once per table at most).

@guvra guvra force-pushed the feat-dump-info-stderr branch from 0be168a to 31b8b22 Compare February 27, 2024 16:30
@guvra guvra changed the title Write dump information and dump progress bar to stderr when verbose m… Draft: Write dump information and dump progress bar to stderr when verbose m… Feb 27, 2024
@guvra guvra changed the title Draft: Write dump information and dump progress bar to stderr when verbose m… Write dump information and dump progress bar to stderr when verbose m… Feb 27, 2024
@guvra guvra marked this pull request as draft February 27, 2024 16:34
@staabm
Copy link
Contributor

staabm commented Feb 28, 2024

I don't think it's possible with the current implementation of the cli 😞
The dumper is executed in the same process as the cli, so when mysqldump-php is dumping a table, the whole process is blocked, and the progress bar cannot be updated.
It can only be updated when the hook from setInfoHook is triggered (once per table).

I see. maybe its good enough for now 👍

Does it redraw anything when mysqldump-php is dumping a table though?
It looks like the progress bar is redrawn only when the bar progresses (so once per table at most).

I didn't check how often it re-renders. I judged from the symfony progress bar docs. but as you say.. when the process is blocked we will for sure not doing it too often :)

@staabm
Copy link
Contributor

staabm commented Feb 28, 2024

The dumper is executed in the same process as the cli, so when mysqldump-php is dumping a table, the whole process is blocked, and the progress bar cannot be updated.
It can only be updated when the hook from setInfoHook is triggered (once per table).

I left an idea in https://github.com/druidfi/mysqldump-php/pull/38/files#r1505546205 regarding printing progress while a table is dumped

@guvra guvra force-pushed the feat-dump-info-stderr branch from 31b8b22 to f141cbc Compare February 28, 2024 17:05
@guvra guvra force-pushed the feat-dump-info-stderr branch from f141cbc to 612c993 Compare March 4, 2024 13:25
@guvra guvra marked this pull request as ready for review March 4, 2024 13:27
@guvra guvra merged commit e4770ce into main Mar 4, 2024
3 checks passed
@guvra guvra deleted the feat-dump-info-stderr branch March 4, 2024 13:46
@staabm
Copy link
Contributor

staabm commented Mar 4, 2024

just tested this again locally. it feels like it updates every second now, which is awesome.

thank you

guvra added a commit that referenced this pull request Mar 4, 2024
@guvra
Copy link
Collaborator Author

guvra commented Mar 4, 2024

just tested this again locally. it feels like it updates every second now, which is awesome.

thank you

Yes, the min progress timer is set to 0.1s, but if the progress bar is stuck on a specific step, it upgrades every 1 second.

@staabm staabm mentioned this pull request Mar 4, 2024
guvra added a commit that referenced this pull request Mar 4, 2024
*/
private function formatRowCount(int $rowCount): string
{
return $rowCount > 1 ? sprintf('%d rows', $rowCount) : sprintf('%d row', $rowCount);
Copy link
Contributor

@staabm staabm Mar 4, 2024

Choose a reason for hiding this comment

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

what do you think about a thousands separator?

in my case the numbers get rather long and harder to read:

Dump progress
  57/405 [===>------------------------]  14% - my_table (101748356 rows) - 26 mins, 1 sec - 35.5 MiB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With a space character as the separator of course 😃

@guvra guvra added the feature New feature or request label Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants