public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate
@ 2020-07-24  8:16 Thomas Lamprecht
  2020-07-24  8:16 ` [pbs-devel] applied: [PATCH backup 2/2] client: log archive upload duration more accurate, fix grammar Thomas Lamprecht
  2020-07-24 12:01 ` [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate Dietmar Maurer
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2020-07-24  8:16 UTC (permalink / raw)
  To: pbs-devel

using micros vs. as_secs_f64 allows to have it calculated as usize
bytes, easier to handle - this was also used when it still lived in
upload_chunk_info_stream

Co-authored-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/client/backup_writer.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
index 7e5adb3..2344045 100644
--- a/src/client/backup_writer.rs
+++ b/src/client/backup_writer.rs
@@ -264,7 +264,7 @@ impl BackupWriter {
             crate::tools::format::strip_server_file_expenstion(archive_name.clone())
         };
         if archive_name != CATALOG_NAME {
-            let speed: HumanByte = (uploaded / (duration.as_secs() as usize)).into();
+            let speed: HumanByte = ((uploaded * 1_000_000) / (duration.as_micros() as usize)).into();
             let uploaded: HumanByte = uploaded.into();
             println!("{}: had to upload {} from {} in {}s, avgerage speed {}/s).", archive, uploaded, vsize_h, duration.as_secs(), speed);
         } else {
-- 
2.27.0





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pbs-devel] applied: [PATCH backup 2/2] client: log archive upload duration more accurate, fix grammar
  2020-07-24  8:16 [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate Thomas Lamprecht
@ 2020-07-24  8:16 ` Thomas Lamprecht
  2020-07-24 12:01 ` [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate Dietmar Maurer
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2020-07-24  8:16 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/client/backup_writer.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
index 2344045..e10ff45 100644
--- a/src/client/backup_writer.rs
+++ b/src/client/backup_writer.rs
@@ -266,7 +266,7 @@ impl BackupWriter {
         if archive_name != CATALOG_NAME {
             let speed: HumanByte = ((uploaded * 1_000_000) / (duration.as_micros() as usize)).into();
             let uploaded: HumanByte = uploaded.into();
-            println!("{}: had to upload {} from {} in {}s, avgerage speed {}/s).", archive, uploaded, vsize_h, duration.as_secs(), speed);
+            println!("{}: had to upload {} of {} in {:.2}s, avgerage speed {}/s).", archive, uploaded, vsize_h, duration.as_secs_f64(), speed);
         } else {
             println!("Uploaded backup catalog ({})", vsize_h);
         }
-- 
2.27.0





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate
  2020-07-24  8:16 [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate Thomas Lamprecht
  2020-07-24  8:16 ` [pbs-devel] applied: [PATCH backup 2/2] client: log archive upload duration more accurate, fix grammar Thomas Lamprecht
@ 2020-07-24 12:01 ` Dietmar Maurer
  2020-07-24 12:37   ` Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Dietmar Maurer @ 2020-07-24 12:01 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Thomas Lamprecht

Why don't you use a single duration.as_secs_f64() and compute speed using floting point?


> On 07/24/2020 10:16 AM Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
> 
>  
> using micros vs. as_secs_f64 allows to have it calculated as usize
> bytes, easier to handle - this was also used when it still lived in
> upload_chunk_info_stream
> 
> Co-authored-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
> ---
>  src/client/backup_writer.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
> index 7e5adb3..2344045 100644
> --- a/src/client/backup_writer.rs
> +++ b/src/client/backup_writer.rs
> @@ -264,7 +264,7 @@ impl BackupWriter {
>              crate::tools::format::strip_server_file_expenstion(archive_name.clone())
>          };
>          if archive_name != CATALOG_NAME {
> -            let speed: HumanByte = (uploaded / (duration.as_secs() as usize)).into();
> +            let speed: HumanByte = ((uploaded * 1_000_000) / (duration.as_micros() as usize)).into();
>              let uploaded: HumanByte = uploaded.into();
>              println!("{}: had to upload {} from {} in {}s, avgerage speed {}/s).", archive, uploaded, vsize_h, duration.as_secs(), speed);
>          } else {
> -- 
> 2.27.0
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate
  2020-07-24 12:01 ` [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate Dietmar Maurer
@ 2020-07-24 12:37   ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2020-07-24 12:37 UTC (permalink / raw)
  To: Dietmar Maurer, Proxmox Backup Server development discussion

Am 7/24/20 um 2:01 PM schrieb Dietmar Maurer:
> Why don't you use a single duration.as_secs_f64() and compute speed using floting point?
> 

Because usize -> f64 is a loss of precision and mainly this is moving back
to exactly how you used to do:
https://git.proxmox.com/?p=proxmox-backup.git;a=commitdiff;h=82ab72304efd651d2afa771c499d4bcec2787f64
thought you had similar/some reasons...

And HumanByte has no from<f64> yet so either adding that or casting back would be
required, but sure, have no hard feelings between:

... = ((uploaded as f64 / duration.as_secs_f64()) as usize).into()

vs.:
... = ((uploaded * 1_000_000) / (duration.as_micros() as usize)).into();
 
>> On 07/24/2020 10:16 AM Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
>>
>>  
>> using micros vs. as_secs_f64 allows to have it calculated as usize
>> bytes, easier to handle - this was also used when it still lived in
>> upload_chunk_info_stream
>>
>> Co-authored-by: Stoiko Ivanov <s.ivanov@proxmox.com>
>> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
>> ---
>>  src/client/backup_writer.rs | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
>> index 7e5adb3..2344045 100644
>> --- a/src/client/backup_writer.rs
>> +++ b/src/client/backup_writer.rs
>> @@ -264,7 +264,7 @@ impl BackupWriter {
>>              crate::tools::format::strip_server_file_expenstion(archive_name.clone())
>>          };
>>          if archive_name != CATALOG_NAME {
>> -            let speed: HumanByte = (uploaded / (duration.as_secs() as usize)).into();
>> +            let speed: HumanByte = ((uploaded * 1_000_000) / (duration.as_micros() as usize)).into();
>>              let uploaded: HumanByte = uploaded.into();
>>              println!("{}: had to upload {} from {} in {}s, avgerage speed {}/s).", archive, uploaded, vsize_h, duration.as_secs(), speed);
>>          } else {
>> -- 
>> 2.27.0




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-24 12:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24  8:16 [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate Thomas Lamprecht
2020-07-24  8:16 ` [pbs-devel] applied: [PATCH backup 2/2] client: log archive upload duration more accurate, fix grammar Thomas Lamprecht
2020-07-24 12:01 ` [pbs-devel] applied: [PATCH backup 1/2] client: avoid division by zero in avg speed calculation, be more accurate Dietmar Maurer
2020-07-24 12:37   ` Thomas Lamprecht

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