Giter VIP home page Giter VIP logo

Comments (7)

GabrielSimonetto avatar GabrielSimonetto commented on May 22, 2024

How much increased time would be tolerable? I have no idea how much time is normal for a print to take, but it is expected for them to tax the system a little bit.

from ouch.

marcospb19 avatar marcospb19 commented on May 22, 2024

How much increased time would be tolerable?

I'm not sure, we would need to investigate it further, we might even conclude at the end that our current time is tolerable or can be improved.


Let's see, I ran the same command and redirected the output to the file output_file.

ouch decompress --yes linux-5.14.9.arch2-1-x86_64.pkg.tar.zst &> output_file                                                                                                                                                                      

Now, we can show the contents in the terminal.

time cat output_file

It showed 0.145 seconds in the first run, and 0.045s for some of the consecutive runs.

That means that the terminal can display the same text in amount 0.045 seconds, if we take the minimum (this can be misleading if I'm missing something).

Here is the time it takes to decompressing the linux package with and without displaying the output:

time ouch decompress --yes linux-5.14.9.arch2-1-x86_64.pkg.tar.zst
# 0.95s on average
time ouch decompress --yes linux-5.14.9.arch2-1-x86_64.pkg.tar.zst &> output_file
# 0.82s on average

So it's an addition of 130 milliseconds.

from ouch.

marcospb19 avatar marcospb19 commented on May 22, 2024

It's common to speed up this by using an additional buffer, here's an example from coreutils:
https://github.com/GrayJack/coreutils/blob/dev/uniq/src/main.rs#L25-L32

This saves on OS calls to write into the stdout file descriptor, but in our case, the problem is probably with how terminals implement their flushing (it depends on the terminal, one of them can try flushing by every frame if too much flush is demanded).

from ouch.

figsoda avatar figsoda commented on May 22, 2024

tested on 2c5a57c, got a slightly different result

[...]
  Time (mean ± σ):      6.137 s ±  0.745 s    [User: 3.145 s, System: 2.873 s]
  Range (min … max):    5.589 s …  7.551 s    10 runs

Benchmark #2: target/release/ouch d linux.tar.gz -yo '/tmp/tmp.nhJZkRNvMD' > '/tmp/tmp.nhJZkRNvMD/log'
  Time (mean ± σ):      5.366 s ±  0.087 s    [User: 2.813 s, System: 2.406 s]
  Range (min … max):    5.242 s …  5.490 s    10 runs

Summary
  'target/release/ouch d linux.tar.gz -yo '/tmp/tmp.nhJZkRNvMD' > '/tmp/tmp.nhJZkRNvMD/log'' ran
    1.14 ± 0.14 times faster than 'target/release/ouch d linux.tar.gz -yo '/tmp/tmp.nhJZkRNvMD''

This is the script I tested with, requires hyperfine.

#!/bin/sh

set -e

cargo build --release
[ ! -f linux.tar.gz ] && curl https://github.com/torvalds/linux/archive/v5.14.tar.gz -Lo linux.tar.gz
out=$(mktemp -d)
target/release/ouch d linux.tar.gz -o "$out"
hyperfine --show-output \
    "target/release/ouch d linux.tar.gz -yo '$out'" \
    "target/release/ouch d linux.tar.gz -yo '$out' > '$out/log'"
rm -r "$out"

from ouch.

marcospb19 avatar marcospb19 commented on May 22, 2024

Interesting, it depends on the archive structure and level of compression, a 14%-ish speed improvement is not a huge priority right now, but I'll leave this open in case we want to optimize in the future.

from ouch.

marcospb19 avatar marcospb19 commented on May 22, 2024

should be fixed once #643 is solved.

from ouch.

marcospb19 avatar marcospb19 commented on May 22, 2024

Fixed! #643 was solved by #642 🎉

from ouch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.