This project estimates the sizes of parameters passed to Java methods using method signature information from:
- A
{project}.xml
file generated by Dependency Finder, and - A
fully-qualified-methods.txt
file generated by the java-method-scanner, which extracts all project-defined methods using ClassGraph, ensuring better coverage.
The size estimation is performed using the Java Instrumentation API, and the results can be used to compute network overhead, particularly for tools like toMicroservice
.
.
├── agent/
│ ├── Agent.java
│ ├── SizeTester.java
│ ├── MANIFEST.MF
│ ├── agent.jar # Compiled Java agent
├── projects/
│ └── roller/
│ ├── roller.xml # Dependency Finder output
│ ├── fully-qualified-methods.txt # List of project-defined method signatures
│ ├── type_list.txt # Generated list of parameter types
│ ├── type_size_output.csv # Output from Java agent with sizes
│ ├── method_parameters_sizeOf.csv # Final mapping of method to param sizes
│ ├── pom.xml # Required to include runtime maven dependencies
│ └── target/
│ ├── classes/ # Required for loading project-specific classes
│ ├── dependency/ # Required for saving mvn runtime dependency
│ ├── roller.war # Required for extracting dependencies
│ └── roller-war-extracted/ # Extracted classes and dependencies from roller.war
├── estimate_param_sizes.py # Python script to run the estimation process
└── README.md # This file
cd agent
javac Agent.java SizeTester.java
jar cmf MANIFEST.MF agent.jar Agent.class SizeTester.class
Make sure your MANIFEST.MF
contains:
Manifest-Version: 1.0
Main-Class: Agent
Either one or both of the following inputs are needed:
<project_name>.xml
: generated by Dependency Finder (may skip some classes for missing run-time dependencies)fully-qualified-methods.txt
: generated byjava-method-scanner
, which ensures complete coverage of all project-defined methods (those written in the codebase) and their parameters.
If estimating the size of project-specific methods is the main goal, then fully-qualified-methods.txt
t alone is sufficient, and the Dependency Finder input can be safely omitted.
- Place
fully-qualified-methods.txt
(required) inprojects/<project_name>/
. - Place the Dependency Finder output XML as:
projects/<project_name>/<project_name>.xml
- Update the
project_name
variable inestimate_param_sizes.py
accordingly. - Extract the
<project_name>.war
file intoprojects/<project_name>/target/<project_name>-war-extracted/
. This is necessary to access third-party dependency classes used by your application. - Add the compiled
classes
toprojects/<project_name>/target/classes
. This is essential because it contains the compiled application-specific classes required to instantiate and estimate parameter sizes correctly. - Add the
pom.xml
toprojects/<project_name>
This will help include all run time dependency (dependencies that are not compiled or packaged with the project) in theprojects/<project_name>/target/dependency
folder.
⚠️ Without the extracted WAR, or the<project_name>/target/classes
or thepom.xml
, the size estimator cannot resolve all classes used in method signatures, leading to fallbacks and reduced accuracy.
python estimate_param_sizes.py
The script will:
- Parse methods from
fully-qualified-methods.txt
and<project_name>.xml
- Extract parameter types
- Write unique types to
type_list.txt
- Invoke the Java agent to compute size estimates
- Write final size results to
method_parameters_sizeOf.csv
method_parameters_sizeOf.csv
Method Signature | Parameter Types | Param Sizes | Total Param Size |
---|---|---|---|
com.foo.Bar(x,y) | int, String | 4, 64 | 68 |
- Estimating data transfer size for inter-method or inter-service communication
- Enhancing microservice decomposition tools by factoring in network overhead
- Static profiling of parameter-heavy methods
- Unknown types are assigned a fallback size of -1 bytes.
- Arrays are instantiated with length 1 during size estimation.
- The method works statically — no application execution is required.