Skip to content

155 benchmarking#240

Merged
heshamMassoud merged 189 commits intomasterfrom
155-benchmark-tests
Feb 13, 2018
Merged

155 benchmarking#240
heshamMassoud merged 189 commits intomasterfrom
155-benchmark-tests

Conversation

@heshamMassoud
Copy link
Copy Markdown
Contributor

@heshamMassoud heshamMassoud commented Jan 22, 2018

This pr addresses #155 to product benchmark tests for the library on every release. The resulting charts look like this: https://commercetools.github.io/commercetools-sync-java/benchmarks/

Benchmark Setup:

  1. Add benchmark as a new source set in the project just like main, test and integration test.

  2. When benchmarks are run, first checkout the gh-pages branch of the repo in a temp directory: 'tmp_git_dir/', then run the benchmarks.

  3. Commit the results of the benchmarks (in this file: benchmarks/benchmarks.json) to this directory and push..

  4. Use Travis' new feature of stages to have 5 different stages which runs the benchmarks and pushes the results to the gh-pages branch: https://github.com/commercetools/commercetools-sync-java/pull/240/files#diff-354f30a63fb0907d4ad57269548329e3R7
    This kind of build will only be triggered on every release: if: tag IS present. This is how it looks on travis.

  5. Add benchmark tests for ProductSync, InventorySync (still not complete and skeleton for CategorySync

  6. In the gh-pages, the chart-render.js uses the output results of benchmarks/benchmarks.json to display the results in this bar chart graph.

Related to benchmarks:

  1. Suppress Javadoc Checkstyle requirement for benchmark methods.
  2. Preserve benchmarks directory on javadocs publishing.
  3. Ensure benchmark results are only committed after the benchmarks are run.

Boy-scout-changes:

  1. Remove unneeded oracle-java8-installer from travis configuration.

  2. Rename gradle task from setReleaseVersion to setLibraryVersion: task | usage | in execution order script.

  3. Rename gradle script file set-release-version to set-library-version: file itself | in build.gradle | in comment in SyncSolutionInfo

TODO:

  • Fix the product deletion in ITs.
  • Only build benchmarks on tag (remove commented out lines in travis.yml file)
  • Complete other missing benchmarks, but this could be done later other PRs. For now we need to merge the current benchmark setup to get results as soon as possible. (#246)
  • Split benchmarks.json file per version (#246)
  • Only show the results of the last X releases and backup the history. (#246)
  • Add docs/benchmarks.md to describe the benchmark setup.

final List<T> list = new ArrayList<>();
iterator.forEachRemaining(list::add);
return list;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of hateful stateful mutability inside closures i'd recommend to use more functional style (thought more verbose):

StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED),  false)
            .collect(Collectors.toCollection(ArrayList::new));

with static imports looks a bit better:

stream(spliteratorUnknownSize(iterator, ORDERED),  false)
            .collect(toCollection(ArrayList::new));

also, stream(spliteratorUnknownSize(iterator, ORDERED), false) could be carried out to util method to be reused in other methods

Copy link
Copy Markdown
Contributor Author

@heshamMassoud heshamMassoud Feb 7, 2018

Choose a reason for hiding this comment

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

8ff01cd merci for the suggestion.

}
}
return ofNullable(latestVersion);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

return ourFancyUtilSpliteratorStreamMethod(originalRoot.fieldNames())
            .reduce((first, second) -> second);

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.

8d47b76 :)

Copy link
Copy Markdown
Contributor Author

@heshamMassoud heshamMassoud Feb 7, 2018

Choose a reason for hiding this comment

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

@andrii-kovalenko-ct unneeded null check removed: a75d76c

Copy link
Copy Markdown
Contributor

@lojzatran lojzatran left a comment

Choose a reason for hiding this comment

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

One more thing: I see in travis, you have things like GRGIT_USER with encrypted value. Where do we get the value if sth happens to travis? You can consider saving them as encrypted files in the repo itself, like here: https://github.com/commercetools/commercetools-paypal-plus-integration/tree/master/travis-build

public class BenchmarkUtils {
private static final String BENCHMARK_RESULTS_FILE_NAME = "benchmarks.json";
private static final String BENCHMARK_RESULTS_FILE_DIR = ofNullable(System.getenv("TRAVIS_BUILD_DIR"))
.map(path -> path + "/tmp_git_dir/benchmarks/").orElse("");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure if it's ok to pass empty String in that case. Maybe it's better to throw exception because you expect in benchmarkCommit above this structure and if it's not there, it won't work.

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 need it for when I am running the benchmarks locally, I don't want an exception to be thrown. On the other hand, If this directory struc. is not there for some reason while running the benchmarks, benchmarkCommit would fail.

static final String CREATES_ONLY = "createsOnly";
static final String UPDATES_ONLY = "updatesOnly";
static final String CREATES_AND_UPDATES = "mix";
static double THRESHOLD = 120000; //120 seconds in milliseconds
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not also final?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and why it's double (isn't int enough)?

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.


public class BenchmarkUtils {
private static final String BENCHMARK_RESULTS_FILE_NAME = "benchmarks.json";
private static final String BENCHMARK_RESULTS_FILE_DIR = ofNullable(System.getenv("TRAVIS_BUILD_DIR"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hardcoding CI specific names (TRAVIS_BUILD_DIR) doesn't look flexible.
Better to use our own env name (for instance, BUILD_DIR, or CI_BUILD_DIR) and assign them in CI configuration

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.

@heshamMassoud
Copy link
Copy Markdown
Contributor Author

@lojzatran regarding encrypting secrets; an issue is created for improvement: #247

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #240 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #240   +/-   ##
=========================================
  Coverage     93.35%   93.35%           
  Complexity      832      832           
=========================================
  Files            69       69           
  Lines          2153     2153           
  Branches        127      127           
=========================================
  Hits           2010     2010           
  Misses          124      124           
  Partials         19       19
Impacted Files Coverage Δ Complexity Δ
...ercetools/sync/commons/utils/SyncSolutionInfo.java 100% <ø> (ø) 1 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3222700...82590a2. Read the comment docs.

@heshamMassoud heshamMassoud merged commit 5ea07c4 into master Feb 13, 2018
@heshamMassoud heshamMassoud deleted the 155-benchmark-tests branch February 13, 2018 12:27
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.

4 participants