Skip to content

Conversation

@allevato
Copy link
Collaborator

@allevato allevato commented Mar 25, 2017

Whew. I got inspired yesterday, and I should have done this a long time ago; it wasn't as bad as I thought it would be.

The harness now takes -c options that let you specify git revisions that should be benchmarked and compared to the current working tree. They can be specified as anything the git tools allow—I imagine branch names (probably master) will be most useful but you can also use commit hashes and whatnot.

-c also accepts the string c++, which means compare against C++ (the old behavior, and also what happens if you don't use any -c options). You can specify -c multiple times, each one becomes a series in the plot, and the current working tree is always last; we're not limited to two anymore (we probably won't use this very much, unless we want to compare, say, master, the working tree, and C++ all at once).

This works by checking out the local repo history at the given revisions into temporary locations and building the harnesses there. This means it uses the generator and the runtime at that revision—so even if you're changing generator code, you end up generating the right thing for each revision and it just works.

It should be noted that this will only work for commits going forward from the time this is merged; because of changes I made to the harness generating scripts to separate the generation from the running (to isolate API changes), the harness makes assumptions about the scripts that will be available in the checkout.

I tested it by adding a usleep(1) in the binary decoder (I can't account for the seemingly nontrivial noise elsewhere in the two branches, though):
harness

This was generated with the command line:

$ Performance/perf_runner.sh -c c++ -c revision-perf -p false 100 "fixed32"

Additionally, you can specify "all" to run the harness multiple
times with all of the (non-repeated) field types listed above.
("all" is not compatible with revision comparisons.)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Especially for revision comparisons, should we look at adding a "mixed" or something that is a message with say two dozen fields of differing types and also uses messages within messages to get some depth?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's a TODO in there to do this :) So yes.


readonly field_count="$1"; shift
if [[ "$1" == "all" ]]; then
# if [[ "$comparison" != "c++" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

delete since it is commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


# Check to see if we have past results from that commit cached. If so, we
# don't need to run it again.
if [[ ! -f "$commit_results" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if it was testing a different field count/etc.?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The filename includes the field type and count in addition to the hash.


# Check out the commit to a temporary directory and create its _generated
# directory. (Results will still go in the working tree.)
tmp_checkout="$(mktemp -d -t swiftprotoperf)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you want an exit hook to delete this directory?

Early on, set up a hook:

  CLEANUP_WHEN_DONE=()
  function cleanup() {
    rm -rf "${CLEANUP_WHEN_DONE[@]}"
  }
  trap cleanup EXIT HUP INT QUIT TERM

The this directory creation becomes:

  tmp_checkout="$(mktemp -d -t swiftprotoperf)"
  CLEANUP_WHEN_DONE+=("$tmp_checkout")

Then no mater now the script dies/exits (unless it is an exec), it will ensure everything added to CLEANUP_WHEN_DONE gets removed at the end.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was trying to think of a clean way to do that but my bash-fu isn't that strong—I like your approach.

@allevato allevato merged commit bd1e20e into apple:master Mar 27, 2017
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.

2 participants