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

Rewrite doins by python (bug 624526). #190

Merged
merged 2 commits into from
Dec 2, 2017
Merged

Conversation

zmedico
Copy link
Member

@zmedico zmedico commented Aug 14, 2017

doins is written in bash. However, specifically in case that
too many files are installed, it is very slow.
This CL rewrites the script in python for performance.

BUG=chromium:712659
TEST=time (./setup_board --forace &&
./build_package --withdev &&
./build_image --noenable_rootfs_verification test)
===Before===
real 21m35.445s
user 93m40.588s
sys 21m31.224s

===After===
real 17m30.106s
user 94m1.812s
sys 20m13.468s

Change-Id: Ib10f623961ba316753d58397cff5e72fbc343339
Reviewed-on: https://chromium-review.googlesource.com/559225
X-Chromium-Bug: 712659
X-Chromium-Bug-url: https://bugs.chromium.org/p/chromium/issues/detail?id=712659
X-Gentoo-Bug: 624526
X-Gentoo-Bug-url: https://bugs.gentoo.org/624526

rm -rf "$TMP"
[[ $failed -ne 0 || $success -eq 0 ]] && { __helpers_die "${helper} failed"; exit 1; } || exit 0
"${PORTAGE_PYTHON:-/usr/bin/python}" \
"${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/doins.py \
Copy link
Contributor

Choose a reason for hiding this comment

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

Is /usr/lib/portage/bin a safe fallback? Shouldn't we check for it being unset instead?

mkdir -p "$TMP"/{1,2}
# Use safe cwd, avoiding unsafe import for bug #469338.
export __PORTAGE_HELPER_CWD=${PWD}
cd "${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this path a safe fallback?

bin/doins.py Outdated
"""Installs a file at |source| into |dest_dir| in process."""
dest = os.path.join(dest_dir, os.path.basename(source))
try:
# TODO: Consider to use portage.util.file_copy.copyfile
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible to get this TODO done before merging?

bin/doins.py Outdated
def run(self, dest):
"""Installs a dir into |dest| by 'install' command."""
command = ['install', '-d'] + self._split_options + [dest]
subprocess.call(command)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could need some exception handling, if subprocess.call fails

bin/doins.py Outdated
# supported.
# In Python 3, the prefix of octal int must be '0o' rather than '0'.
# So, set base explicitly in that case.
return int(mode, 8 if re.search(r'^0[0-7]*$', mode) else 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Split up into multiple lines for readability and consider compiling the regex

@zmedico
Copy link
Member Author

zmedico commented Nov 30, 2017

Updated with the version merged in chromiumos/third_party/portage_tool, and added a commit to optimize with copyfile from portage.util.file_copy.

Hidehiko Abe and others added 2 commits December 2, 2017 13:17
doins is written in bash. However, specifically in case that
too many files are installed, it is very slow.
This CL rewrites the script in python for performance.

BUG=chromium:712659
TEST=time (./setup_board --forace && \
     ./build_package --withdev && \
     ./build_image --noenable_rootfs_verification test)
===Before===
real    21m35.445s
user    93m40.588s
sys     21m31.224s

===After===
real    17m30.106s
user    94m1.812s
sys     20m13.468s

Change-Id: Ib10f623961ba316753d58397cff5e72fbc343339
Reviewed-on: https://chromium-review.googlesource.com/559225
X-Chromium-Bug: 712659
X-Chromium-Bug-url: https://bugs.chromium.org/p/chromium/issues/detail?id=712659
Reviewed-by: Manuel Rüger <mrueg@gentoo.org>
Bug: https://bugs.gentoo.org/624526
@gentoo-bot gentoo-bot merged commit e8f9d69 into gentoo:master Dec 2, 2017
@zmedico zmedico deleted the bug_624526 branch January 3, 2018 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants