ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

[Phase 1][Ballerina standard libraries] Dead code elimination report for Ballerina library modules #7339

Open ayeshLK opened 6 days ago

ayeshLK commented 6 days ago

Description

$subject

In the first phase we will be looking into dead-code-elimination for Ballerina standard library modules.

Below are the steps required to complete dead code elimination for a standard library module:

1. Update Dependency Versions:

Update the timestamps or latest versions of dependencies in gradle.properties (refer to the “Next” tab for the relevant versions).

2. Build the Module:

Use gradle to build the standard library module. This step will generate an intermediate package, which will be used for testing.

3. Run Dead Code Elimination Command:

In the ballerina directory of the module, execute:

    BAL_DISABLE_HARDCODED_OPTIMIZATIONS=true <path-to-intermediate-pack>/bin/bal test --eliminate-dead-code --dead-code-elimination-report

4. Review the Report:

If errors arise, examine target/dead_code_elimination_report.json to identify any removed types. Use @ExternalDependency to mark these types as needed.

5. Verify Type and Value Creator Usage:

Review TypeCreator, ValueCreator and ErrorCreator usage in the native code. Mark any relevant Ballerina types with @ExternalDependency if they aren’t marked already.

Module list

Version

No response

TharmiganK commented 6 days ago

The url package has no usages of ValueCreator or TypeCreator APIs. But the tests with DCE are failing due to a lang issue: https://github.com/ballerina-platform/ballerina-lang/issues/43552. There is one usage for the ErrorCreator to create url:Error and since it is mentioned in the external function calls, it is added by default.

TharmiganK commented 6 days ago

The log package has no usages of TypeCreator. There are some usages of ValueCreator and ErrorCreator, but those are for tests (added via the test-utils package) and not part of the package.

ayeshLK commented 6 days ago

This effort is currently on hold due to the following lang issue [1]

[1] - https://github.com/ballerina-platform/ballerina-lang/issues/43554