Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Conversation

he32
Copy link

@he32 he32 commented May 24, 2021

Replace inner-loop use of "grep", "sed" and "cut" for pattern matching
and substitution when case/esac and appropriate parameter expansion
works just as well. A test rig shows around 4x speed-up.

Replace inner-loop use of "grep", "sed" and "cut" for pattern matching
and substitution when case/esac and appropriate parameter expansion
works just as well.  A test rig shows around 4x speed-up.
wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request May 25, 2021
When building the bootstrap kit, drop "docs" and "compiler-docs"
from the build.  This will make the install of the bootstrap kit
a lot faster, since it drops 5-6.000 files from the kit, which would
need to be processed by the install.sh script.  Note that this will
also impact the rust-bin package, since we also use the bootstrap
kits for installation there for the ports we maintain locally.  To
get these "docs" sub-sets installed, use the full "lang/rust" normal
build and/or a corresponding binary package.

Also, speed up the install.sh script (via install-template.sh) by
significantly reducing the number of forks in the inner loop.
Instead of relying on "grep", "sed" and "cut" for pattern matching,
substitution and field extraction, use case/esac and parameter
expansion modification to do the same, i.e. using in-shell mechanisms.
Submitted upstream, ref.

rust-lang/rust-installer#111

On an emulated (and loaded...) armv7 system, this reduced the time
(as shown with csh "time") for a test rig of install.sh (which
doesn't even actually do the file copying etc.) from

13000.143u 48616.601s 14:21:27.13 119.2%   57+151k 598+7367io 0pf+0w
to
3247.518u 9754.898s 3:45:48.70 95.9%   31+75k 927+4952io 14pf+0w

(This is with the "docs" and "compiler-docs" still in the bootstrap kit.)

Bump PKGREVISION.
he32 added a commit to he32/rust that referenced this pull request Aug 24, 2025
This round replaces repetitive pattern matching in the inner loop
of this script using grep (which causes a fork() for each test)
with built-in pattern matching in the bourne shell using the case
/ esac construct.

This in reference to
  rust-lang#80684
and is a separated-out request from
  rust-lang/rust-installer#111

which apparently never got any review.

The forthcoming planned "step 2" change builds on top of this
change, and replaces the inner-loops needless uses of sed (which
again causes a fork() for each instance) with the suffix removal
constructs from the bourne shell.  Since this change touches lots
of the same lines this change does, that pull request cannot be
submitted before this one is accepted.

Hopefully this first step is less controversial than the
latter change.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant