Skip to content

Set repetitions of benchmark to 10. - #4053

Merged
hanhanW merged 2 commits into
iree-org:mainfrom
hanhanW:multiple-bench
Dec 2, 2020
Merged

hanhanW merged 2 commits into
iree-org:mainfrom
hanhanW:multiple-bench

Conversation

@hanhanW

@hanhanW hanhanW commented Dec 2, 2020 •

Copy link
Copy Markdown
Contributor

This allows us to get more sample points in one run, and can get more
stable results.

Ignore the report of mean/median/stddev because Mako can deal with them.

This allows us to get more sample points in one run, and can get more
stable results.

TS="$(date +%s)000"
SED_EXPR='s/BM_[[:alnum:][:punct:]]+ [[:space:]]+ ([0-9]+) ms[[:print:]]+/\1/p'
SED_EXPR='s/BM_[[:alnum:][:punct:]]+\/real_time[[:space:]]+ ([.0-9]+) ms[[:print:]]+/\1/p'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is fine for now, but note that Benchmark has structured output as well, which is probably what we should be using (https://github.com/google/benchmark#output-formats)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got you, I just feel this is easy enough, instead of parsing a json file in bash. CSV format is probably good.

for ms in "$(sed -En -e "${SED_EXPR}" "${test_out}")"; do
"--driver=${driver}" \
--benchmark_repetitions=10 \
--benchmark_min_time=1 | tee "${test_out}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit relative to the description. This isn't warmup time, it's the sampling time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought benchmark_min_time is to set the running time before real benchmarks? I tried with fullyconnect test, and the total execution time is longer, but the report time is still less than 1 sec, like 0.107 ms. So I thought this is kind of warmup time.

https://github.com/google/benchmark/blob/bf585a2789e30585b4e3ce6baf11ef2750b54677/src/benchmark.cc#L62-L67

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No benchmark is already averaging over many many runs for the report time. You should see a number of iterations as part of the report. The way it works is approximately like this. For each benchmark:

  1. Run the benchmark a few times to see how long it takes. This also serves as a warmup.
  2. Based on how long the benchmark took during these runs, calculate how many times to run it such that it runs at least once, not more than 1e9 times, and for at least benchmark_min_time. (I think there is also some observation of the variance on the initial runs the informs the decision here).
  3. Run it that many times.
  4. Report the average for those iterations as well as the number of iterations.
  5. If benchmark_repetitions is set, repeat for that many repetitions (I think it may not repeat step 1 though) and report statistical aggregations across those repetitions.

See https://github.com/google/benchmark#runtime-and-reporting-considerations

Anyway, increasing benchmark_min_time is fine, but unless you have a reason you think we need to increase it, I would just leave it as the default. It does not increase the warmup time, only the sampling time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see, thanks for the detailed explanation! Let's leave it as the default. I'll update the commit message.

@hanhanW hanhanW changed the title Set repetitions of benchamrks to 10 and increase warmup time. Set repetitions of benchmark to 10. Dec 2, 2020
@hanhanW
hanhanW merged commit c6caf9e into iree-org:main Dec 2, 2020
@hanhanW
hanhanW deleted the multiple-bench branch December 2, 2020 19:06
This was referenced Dec 2, 2020
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