-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add Benchmark CLI for format comparison and perf tracking #329
Add Benchmark CLI for format comparison and perf tracking #329
Conversation
Build checks failed due a couple issues. One where gtest isn't linking, which doesn't reproduce on my system. Another is cmake acting like it hasn't known what C++17 is since 3.8.. continuing to dig. |
…kflow to account for changes better
The unit test crash that is occurring with the amazonlinux:1 gcc72 build isn't reliably reproducible locally. The most recent commit should address the memleak that was identified by the ubuntu clang build, but I'm not sure if it is related. Will continue digging if not. |
…itialized data sets decimal to NUMBER type
Ok. I've reproduced the crash that GHA is seeing, and it's pretty awesome. /s All of my attempts to reproduce the issue failed. I combed through the package versions, and made sure the docker digest SHA reported by GitHub matched the image I was using locally. Everything lined up but for some reason the issue would not reproduce. Until I piped the output of act, into I was also able to reproduce the issue by simply redirecting the output of the unit tests into a file, which made it possible to easily run it under gdb. I had known from the output of the GHA crash that the issue was triggering in the test_ion_decimal.cpp tests, specifically With the redirect, I'm guessing some things have shifted on the stack, and the uninitialized |
Putting this into review. There may be an issue with ion-test-drivers, I'm still looking into that, but this PR should be good to start moving forward. |
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.
Nice! Could you add some example output from the tool to the PR description?
@@ -1,7 +1,21 @@ | |||
[submodule "ion-tests"] | |||
path = ion-tests | |||
url = https://github.com/amazon-ion/ion-tests.git | |||
[submodule "googletest"] | |||
path = test/googletest | |||
[submodule "tools/ion-bench/deps/libcbor"] |
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.
Is there something we can do to make it easy for people to avoid pulling down these dependencies unless they plan to build the benchmark CLI?
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.
Yea, not sure what we can do here. I might be able to wire it into the cmake config. I'll dig into that, and see what options we have.
ion_reader_get_annotation_count(_reader, &count); | ||
ION_STRING *syms = new ION_STRING[count]; | ||
ion_reader_get_annotations(_reader, syms, count, &count); | ||
for (int i=0; i < count; i++) { | ||
annot.push_back(std::string((char *)syms[i].value, syms[i].length)); | ||
} | ||
delete[] syms; |
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.
Should we use ion_reader_get_an_annotation
in the loop and avoid copying into a temporary array?
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.
Good call. I'll follow up with a PR to change that.
default: | ||
printf("Attempt to write unknown type: %d\n", val.tpe); | ||
break; |
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.
Are we missing support for null.null
, blob, and clob?
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.
Agh, yea. I'll include those in the follow-up PR.
break; | ||
} | ||
case YYJSON_TYPE_BOOL: | ||
stats.num_bools++; |
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.
Should we retrieve the value of the boolean?
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.
Yea, I need to wire up a dependency on the bool so it doesn't get optimized out. For yyjson specifically getting a bool is a memory access, and a couple bit operations, so there aren't any side effects to keep the call around. I'll address it in the follow-up.
Thank you! I'm going to push up a new commit with the commented code, and typos, fixed, and output added. Then get I'll this merged. Then PR the regression workflow, and follow up with the code changes discussed above. Unless anyone has an argument against that. |
Issue #, if available:
Description of changes:
Changes to the Build
Google Test
This PR changes the googletest usage a little. This was primarily to support google-benchmark's googletest dependency, but resulted in further adjustments to supply users with the ability to:
gtest_main
target is available, and the ion-c build will disable its own import.IONC_BUILD_TEST
flagoff
in order to stop the ion-c build from building ion-c unit tests.Build Type: Profiling
This PR's primary purpose is to add a new CLI to allow for benchmarking for performance baselining, analysis, and improvement quantification. In order to produce builds where we have optimized builds, but still have enough debug information to generate flame graphs, and use profilers effectively a new build type was added to do just that. Rather than building with
-DCMAKE_BUILD_TYPE=Release
, a user can now use-DCMAKE_BUILD_TYPE=Profiling
and cmake will produce a build that has debug information and optimization passes.Addition of IonCBench
The primary purpose of this PR is to add the ion-c benchmark CLI. In order to build this tool the user can set the CMake variable
IONC_BENCHMARKING_ENABLED
toON
. This is done by default when using theProfiling
build type. The tool is intended to provide a similar set of features to the other benchmark CLIs found for ion-java, and ion-python.Currently, the tool allows the user to provide their own data, and perform both full deserialization and full serialization of that data using ion-c (in text mode, or binary), MsgPack (MsgPack-C), JSON (yyjson, and json-c), and CBOR (libcbor).
This PR is the first iteration of the ion-bench tool, and provides functionality for measuring CPU time, and other CPU metrics such as instruction counts (as long as it is built with libpfm). The tool currently supports a single benchmark run per invocation. Each benchmark run requires an input dataset, a specified supported implementation, and the requested benchmark to run. Currently the tool supports two benchmarks:
In both benchmarks timing does not include the IO to get the input dataset into memory.
The expectation is that more benchmarks will be added, along with more format implementations, in order to compare runtime, memory usage, and data size, between ion and other data formats.
Usage
The tool has a
--help
which has a list of all of the arguments that can be used:By default, output will be presented in a tabular format.
Since the tool leans very heavily on google-benchmark, all google-benchmark arguments are also supported:
Changes Since Original Post
image
defines the container, or VM Image (runs-on), that the job uses, andtoolchain
defines whether to use gcc, or clang (currently).By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.