public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Daniel Tschlatscher <d.tschlatscher@proxmox.com>,
	PVE development discussion <pve-devel@pve.proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-qemu] fix: 3865: backup restore human readable output
Date: Fri, 25 Mar 2022 12:05:28 +0100	[thread overview]
Message-ID: <fd056cb7-0e4b-a25a-cd45-c1089185b7b7@proxmox.com> (raw)
In-Reply-To: <8af5712b-d33d-ffb7-ccd5-5dda8973822a@proxmox.com>

(re-sending, seems you forgot to hit Reply-All and only sent it to me directly).

On 25.03.22 10:41, Daniel Tschlatscher wrote:
> On 3/25/22 09:29, Thomas Lamprecht wrote:
>> Thanks for the patch, some comments inline.
>> On 24.03.22 16:44, Daniel Tschlatscher wrote:

>> please format the commit message according our submission rules:
>> https://pve.proxmox.com/wiki/Developer_Documentation#Commits_and_Commit_Messages
>>
>> an output example (maybe even an before/after) excerpt would be nice to have here.
>
> Just leave out the ":" after "fix", right? Or is there something else I should change?

I actually meant the per-line character length, quoting:
> Make sure the line length of the commit's message is not longer than 70 characters.
> Note, HTTPS links are an exception and should not be split.

but yeah, now that you say it, it really should be `fix #3865: ...`


>>>   +typedef struct VmaRestoreState {
>>>   +    BlockBackend *target;
>>>   +    bool write_zeroes;
>>> @@ -649,13 +653,31 @@ index 0000000000..2b1d1cdab3
>>>   +
>>>   +        if (verbose) {
>>>   +            time_t duration = time(NULL) - vmar->start_time;
>> The resulting accuracy for time in seconds could be not that good, did you make any
>> thoughts or comparison regarding that.
> I "built" upon what was here. This is the way that seconds passed were measured in the original code and works well enough in this case. time_t has some functionality for tracking milliseconds though but I don't think that much fine control over the time elapsed has any real benefits here.

sorry but what? Example we have a byte delta of 100 MiB since last report, and nothing
guarantees that we're currently very close to a second boundary, so lets see
how the error compares comparing second resolution to some millisecond ones.

Using second granularity anything between 1 <= t < 2 gets you 100 MiB/s
On the other hand:

                    "actual"     "1s cut off"   "error"
100 MiB / 1.000s = 100.0 MiB/s   100.0 MiB/s      0.0
100 MiB / 1.050s =  95.2 MiB/s   100.0 MiB/s      4.8
100 MiB / 1.123s =  89.0 MiB/s   100.0 MiB/s     11.0
100 MiB / 1.130s =  88.5 MiB/s   100.0 MiB/s     11.5
100 MiB / 1.500s =  66.7 MiB/s   100.0 MiB/s     33.3
100 MiB / 1.750s =  57.1 MiB/s   100.0 MiB/s     42.9
100 MiB / 1.999s =  50.0 MiB/s   100.0 MiB/s     50.0

So even just 7 ms (1.123s vs 1.13s) make a 0.5 MiB/s difference, IMO already relevant.

Wouldn't dare to call that "working well enough", or are we talking about
different things?

>>> ++
>>> ++                if (delta != 0)
>>> ++                    bps /= delta;
>> currently, if delta would be null you'd print a size unit as throughput unit?
>>
> This is due to the underlying code. The function that is wrapping this part of the code is called multiple times every second (something like ~20 times / sec) and in the original code a print statement would only occur after the percentage of bytes transferred increased by at least 1%.> 
> The time elapsed between an increase in percent could be less than a second. In this case the output simply prints how much bytes were transferred since this second began. This means the value for throughput would at the time of the print be always lower than the real world B/s and only the last print in that second would represent the actual B/s.

This just doesn't makes sense to me, the if clauses enforces that its called at
max every 2s (or 100% edge case) already, and using wrong units is using wrong
units, you cannot really argue basic math/physics away..

>
> Nonetheless, I later adapted this code to behave like the backup create function does, which updates every 3 seconds, eliminating this problem entirely. This is therefore dead code anyway.
>

later where?

Actual improvement, track duration in milliseconds or less and still catch the edge
case for when delta is zero and just set throughput to zero then (as no data can
transfer in zero time).


>> would IMO be worth it to factor above lines out in a static local helper to avoid
>> crowding this function to much, e.g. (types may be adapted if reasonable):
>>
>> print_restore_progress(uint64_t total_byte, uint64_t restored_byte, uint64_t duration_ms);
>>
>> I would handle the last_X statics in there and also re-calculate the percentage as float
>> in there, so that we can print a similar amount of digits after the decimal place like
>> we do in backup.
>
> A function sounds good, though I am not quite sure what you mean by "print a similar amount of digits after the decimal place like we do in backup"

Hmm, I thought percentage isn't a integer there, so meant something like 5.1%,
but apparently it is a plain integer (may just have been in an experiment done
once I rewrote that whole thing a bit ago), so for now you can ignore that.





  parent reply	other threads:[~2022-03-25 11:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24 15:44 Daniel Tschlatscher
2022-03-25  8:29 ` Thomas Lamprecht
     [not found]   ` <8af5712b-d33d-ffb7-ccd5-5dda8973822a@proxmox.com>
2022-03-25 11:05     ` Thomas Lamprecht [this message]
2022-03-25 12:39       ` Daniel Tschlatscher
2022-03-25 17:59         ` Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fd056cb7-0e4b-a25a-cd45-c1089185b7b7@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=d.tschlatscher@proxmox.com \
    --cc=pve-devel@pve.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal