-
Notifications
You must be signed in to change notification settings - Fork 5
Add --parallel-io CLI flag for concurrent loop execution #129
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
Open
vlap
wants to merge
3
commits into
uwefladrich:master
Choose a base branch
from
vlap:perf/parallel-loops
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Benchmark: base.copy loop | ||
| - base.make_dir: | ||
| path: "{{workdir}}" | ||
| - base.chdir: | ||
| path: "{{workdir}}" | ||
| - base.copy: | ||
| src: "{{srcdir}}/{{item}}" | ||
| dst: . | ||
| loop: "{{files}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Setup for base.move benchmark: copy source files into workdir | ||
| - base.make_dir: | ||
| path: "{{workdir}}" | ||
| - base.chdir: | ||
| path: "{{workdir}}" | ||
| - base.copy: | ||
| src: "{{srcdir}}/{{item}}" | ||
| dst: . | ||
| loop: "{{files}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Benchmark: base.move loop | ||
| # Assumes files are already present in workdir (copied by bench-move-setup.yml) | ||
| - base.make_dir: | ||
| path: "{{workdir}}/dest" | ||
| - base.chdir: | ||
| path: "{{workdir}}" | ||
| - base.move: | ||
| src: "{{item}}" | ||
| dst: dest/ | ||
| loop: "{{files}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #!/usr/bin/env bash | ||
| # Benchmark: se --parallel-io vs se (sequential) | ||
| # Usage: bash run-bench.sh <dir_with_nc_files> [iterations] | ||
| # Set BENCH_WORKDIR if /tmp is too small. | ||
| set -uo pipefail | ||
|
|
||
| SRCDIR=${1:?'Usage: run-bench.sh <dir_with_nc_files> [iterations]'} | ||
| N=${2:-5} | ||
| DIR=$(cd "$(dirname "$0")" && pwd) | ||
| W=${BENCH_WORKDIR:-${TMPDIR:-/tmp}/se-bench-$$} | ||
|
|
||
| command -v se >/dev/null || { echo "ERROR: se not in PATH" >&2; exit 1; } | ||
|
|
||
| # Pick 10 largest .nc files | ||
| mapfile -t FILES < <(find "$SRCDIR" -maxdepth 1 -name '*.nc' -size +1M -printf '%s %f\n' | sort -rn | head -10 | awk '{print $2}') | ||
| (( ${#FILES[@]} >= 5 )) || { echo "ERROR: need >=5 .nc files >1MB" >&2; exit 1; } | ||
|
|
||
| YAML_LIST=$(printf ", '%s'" "${FILES[@]}"); YAML_LIST="[${YAML_LIST:2}]" | ||
|
|
||
| mkdir -p "$W/src" | ||
| for f in "${FILES[@]}"; do [ -f "$W/src/$f" ] || cp "$SRCDIR/$f" "$W/src/"; done | ||
|
|
||
| cat > "$W/ctx.yml" <<EOF | ||
| - base.context: | ||
| files: $YAML_LIST | ||
| srcdir: "$W/src" | ||
| workdir: "$W/run" | ||
| EOF | ||
|
|
||
| echo "se --parallel-io benchmark: ${#FILES[@]} files, $N iterations" | ||
| echo "" | ||
|
|
||
| TIMEFORMAT='%R' | ||
|
|
||
| time_copy() { | ||
| rm -rf "$W/run" | ||
| { time se --loglevel error $1 "$W/ctx.yml" "$DIR/bench-copy.yml" ; } 2>&1 | tail -1 | ||
| } | ||
|
|
||
| time_move() { | ||
| rm -rf "$W/run" | ||
| se --loglevel error "$W/ctx.yml" "$DIR/bench-move-setup.yml" >/dev/null 2>&1 | ||
| { time se --loglevel error $1 "$W/ctx.yml" "$DIR/bench-move.yml" ; } 2>&1 | tail -1 | ||
| } | ||
|
|
||
| median() { printf '%s\n' "$@" | sort -n | awk -v n=$# 'NR==int(n/2)+1{print}'; } | ||
|
|
||
| for op in copy move; do | ||
| par=() seq=() | ||
| fn="time_$op" | ||
|
|
||
| $fn "" >/dev/null 2>&1 || true | ||
| $fn "--parallel-io" >/dev/null 2>&1 || true | ||
|
|
||
| for ((i=1; i<=N; i++)); do | ||
| if (( i%2 )); then | ||
| par+=("$($fn "--parallel-io")") | ||
| seq+=("$($fn "")") | ||
| else | ||
| seq+=("$($fn "")") | ||
| par+=("$($fn "--parallel-io")") | ||
| fi | ||
| done | ||
|
|
||
| mp=$(median "${par[@]}"); ms=$(median "${seq[@]}") | ||
| sp=$(awk "BEGIN{printf \"%.0f\", ($ms-$mp)/$ms*100}") | ||
| printf " %-10s par=%ss seq=%ss speedup=%s%%\n" "base.$op" "$mp" "$ms" "$sp" | ||
| printf " all par: %s\n" "${par[*]}" | ||
| printf " all seq: %s\n" "${seq[*]}" | ||
| done | ||
|
|
||
| echo "" | ||
| rm -rf "$W" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this little change slipped in from #128 and does not really belong here, does it?