Skip to content
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

Added first example for benchmark #338

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

NicolasHuertas
Copy link
Collaborator

@NicolasHuertas NicolasHuertas commented Sep 9, 2024

Cyclical Dependency Example

Overview

This project is designed to evaluate and benchmark the performance of EngFlow's remote execution and caching services. It specifically focuses on testing scenarios involving cyclical-like structures in the dependency graph, which are handled through interfaces and constructor injection.

Purpose

The primary objectives of this project are to:

  1. Generate Performance Data: Create examples with cyclical-like dependencies to test and gather performance data for EngFlow’s remote caching and execution services.
  2. Benchmark Analysis: Compare the performance of local versus remote execution and caching to evaluate the efficiency and effectiveness of the service.
  3. Support Automation Development: Contribute to the development of automation algorithms for resource assignment by providing valuable data on how cyclical dependencies impact performance.

Project Structure

The project is organized into several packages, each representing different components of the cyclical dependency example:

  • class_a: Contains ClassA which depends on ClassB through an interface.
  • class_b: Contains ClassB which implements InterfaceB and depends on ClassC.
  • class_c: Contains ClassC which implements InterfaceA and can be initialized with a reference to ClassA.
  • interface_a: Defines the interface InterfaceA implemented by ClassA and ClassC.
  • interface_b: Defines the interface InterfaceB implemented by ClassB.
  • main: Contains the Main class which processes the input file.
  • input: Contains the input text file used by the Main class.

How the Program Works

The program takes a text input file and recursively prints each word with each class (ClassA prints a word, then ClassB, and so on) until the string is empty. The input file should be specified in the data attribute of the java_binary rule in the BUILD file.

@anfelbar anfelbar self-requested a review September 13, 2024 15:19
@NicolasHuertas
Copy link
Collaborator Author

New Examples Added

Varying Input Example

The goal of this example project is to test the performance of Engflow's remote execution and caching service for different input sizes. The project involves creating using a class named Writer to create a specified number of txt files, each containing 100 random characters, and then reading and printing out their contents with the Reader class.

Project Structure

  • java/com/engflow/internship/varyinginputs/input: Directory where the generated .txt files are saved.
  • java/com/engflow/internship/varyinginputs/main: Contains the Main class which orchestrates the file creation and reading process.
  • java/com/engflow/internship/varyinginputs/reader: Contains the Reader class responsible for reading the files.
  • java/com/engflow/internship/varyinginputs/writer: Contains the Writer class responsible for writing the files.

Usage Example

To create and read 10 files, you would run:

bazel run //java/com/engflow/internship/varyinginputs/main -- 10

This command will:

  1. Use the Writer class to create 10 files, each containing 100 random characters, in the input directory.
  2. Use the Reader class to read and print the contents of these files.

Set Input Example

Since the data dependencies in the previous examples are for files created during runtime. This example uses a genrule to write a set number of txt files instead of a Writer class. This way, the main binary can be built and run after the files are already created.

Project Structure

  • java/com/engflow/internship/setinput/genfile: Directory where the .txt files generated by the genrule are stored.
  • java/com/engflow/internship/varyinginputs/main: Contains the Main class which orchestrates the reading process.
  • java/com/engflow/internship/varyinginputs/reader: Contains the Reader class responsible for reading the files.

Usage

To generate the test files, build the filegroup target:

bazel build //java/com/engflow/internship/setinput/genfile

Then, the program can be run with the following command:

bazel run //java/com/engflow/internship/varyinginputs/main 

To modify the amount of files generated, change the value of the NUM_FILES in the BUILD file inside the genfile directory.

Binary Input Example

The goal of this example project is to test the performance of Engflow's remote execution and caching service based on the number of input binary files in the dependency graph. The project contains a genrule that generates a specified number of Java binaries for the genbinary Java library, which are then listed as dependencies in the main binary. The Main.java file loops through each generated class and calls its greetNum method.

Project Structure

  • java/com/engflow/internship/binaryinput/Main.java: Main class that dynamically loads and invokes methods from generated classes.
  • java/com/engflow/internship/binaryinput/BUILD: Bazel build file for the main java binary and the genbinary library.

Usage

To generate the test files, build the genbinary library using the genrule:

bazel build //java/com/engflow/internship/binaryinput:genbinary

Then, the program can be run with the following command:

bazel run //java/com/engflow/internship/binaryinput:main

How It Works

  1. Generation of Java Binaries:

    • The genrule in the BUILD file generates a specified number of Java classes (Hello1.java, Hello2.java, ..., HelloN.java).
    • Each generated class contains a greetNum method that prints a unique message.
  2. Main Class Execution:

    • The Main.java file in binaryinput dynamically loads each generated class using reflection.
    • It then invokes the greetNum method of each class, printing the corresponding message.

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.

1 participant