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

Don't build unnecessary jars. #5515

Merged
merged 7 commits into from
Jul 23, 2024

Conversation

nkoroste
Copy link
Contributor

@nkoroste nkoroste commented Oct 20, 2023

Checklist

  • I have filed an issue about this change and discussed potential changes with the maintainers.
  • I have received the approval from the maintainers to make this change.
  • This is not a stylistic, refactoring, or cleanup change.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.

Discussion thread for this change

Issue number: #1785

Description of this change

reopened #1786 - Don't build the class jar if source jars are available, as we can use that in conjunction with the interface jar to index the code instead.

For our app it reduces ~30% of the Jars the IDE will index (from 14484 to 10072)

As per PR review request I put this feature behind optimize_building_jars experiment which is enabled by default. In case an issue is found with this feature this experiment can be disabled by disabled it in the IntelliJ experiments file as follows:

echo optimize_building_jars=0 >> ~/.intellij-experiments

@github-actions github-actions bot added the awaiting-review Awaiting review from Bazel team on PRs label Oct 20, 2023
@sgowroji sgowroji added the product: IntelliJ IntelliJ plugin label Oct 25, 2023
@mai93 mai93 assigned tpasternak and blorente and unassigned mai93 Oct 25, 2023
@agluszak
Copy link
Collaborator

agluszak commented Nov 6, 2023

Hi!

For our app it reduces ~30% of the Jars the IDE will index (from 14484 to 10072)

Would you be willing to run some benchmarks on open source projects and provide the results here?

Copy link
Collaborator

@blorente blorente left a comment

Choose a reason for hiding this comment

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

The implementation looks good to me, and I think it's unlikely to interfere with indexing. However, as @agluszak said, given that this changes a lot of the core resolution, it would be interesting to run the same benchmark in other projects (such as this repository, for instance) before merging, to make sure it's not a regression.

aspect/intellij_info_impl.bzl Outdated Show resolved Hide resolved
@nkoroste
Copy link
Contributor Author

nkoroste commented Nov 7, 2023

Hi!

For our app it reduces ~30% of the Jars the IDE will index (from 14484 to 10072)

Would you be willing to run some benchmarks on open source projects and provide the results here?

and

The implementation looks good to me, and I think it's unlikely to interfere with indexing. However, as @agluszak said, given that this changes a lot of the core resolution, it would be interesting to run the same benchmark in other projects (such as this repository, for instance) before merging, to make sure it's not a regression.

I can provide a rough count of how many Jars would be ignored however I don't know how interesting that number is, instead what would be more interesting is to measure the impact this may have on indexing and code-completion time but unfortunately Intellij IDE itself nor this plugin provide an easy way to get those numbers

@tpasternak
Copy link
Collaborator

If the change is risky it would be good to at least provide some way to recover from it, ex. via a feature flag. Otherwise users will be blocked until we push a hotfix release

@mai93
Copy link
Collaborator

mai93 commented Nov 7, 2023

Can we try to incrementally roll it out?, I feel like we have been adding a lot of feature flags and not all of them are documented so not a lot of users get to try the features they protect.

@tpasternak
Copy link
Collaborator

Can we try to incrementally roll it out?

Sure, how to do it?

I feel like we have been adding a lot of feature flags and not all of them are documented so not a lot of users get to try the features they protect.

Sorry, I know I was supposed to document the flags 😅 putting it on my priority list.

@mai93
Copy link
Collaborator

mai93 commented Nov 7, 2023

We can use FeatureRolloutExperiment to define the experiment flag and set the roll out percentage in experiment.properties

@mai93
Copy link
Collaborator

mai93 commented Dec 28, 2023

Follow up on how we can select between the old and new behaviour in the aspect, we can use --aspects_parameters to pass a boolean value to the aspect based on the experiment value (i.e. enabled or not) and select the one of the 2 approaches in the aspect based on this boolean. We need to add a boolean attribute in the aspect definition, can be called optimize_building_jars and pass its value from the command line as --aspects_parameters=optimize_building_jars=true.

@nkoroste
Copy link
Contributor Author

PTAL @mai93 @tpasternak

@@ -58,10 +58,8 @@ public void testJavaBinary() throws Exception {
testRelative(intellijInfoFileName("foo")));
assertThat(getOutputGroupFiles(testFixture, "intellij-resolve-java"))
.containsAtLeast(
testRelative("libfoolib.jar"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

why these jars are no longer expected, is optimization enabled for this test? same for DependenciesTest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted these changes, they were traces to when optimization was enabled by default.

@mai93
Copy link
Collaborator

mai93 commented Jul 19, 2024

it looks good to me, I can merge it if none else wants to review cc @tpasternak @agluszak

@mai93 mai93 merged commit 2036193 into bazelbuild:master Jul 23, 2024
6 checks passed
@github-actions github-actions bot removed the awaiting-review Awaiting review from Bazel team on PRs label Jul 23, 2024
@aschott-looker
Copy link

This option isn't supported on the version of Bazel we use. How do you disable it for a project?

@mai93
Copy link
Collaborator

mai93 commented Aug 19, 2024

what feature is not supported in the Bazel version you use?

@nkoroste mentioned that this experiment can be disabled by disabled it in the IntelliJ experiments file as follows:

echo optimize_building_jars=0 >> ~/.intellij-experiments

@aschott-looker
Copy link

Any Bazel version older than when this commit landed will fail:

ERROR: --aspects_parameters=optimize_building_jars=enabled :: Unrecognized option: --aspects_parameters=optimize_building_jars=enabled

@tpasternak
Copy link
Collaborator

@mai93 , @ujohnny do we still support Bazel 5?

@tpasternak
Copy link
Collaborator

Bazel 5 will be EOL in September. https://blog.bazel.build/2020/11/10/long-term-support-release.html

@aschott-looker are there any chances you could upgrade to bazel 6?

@hisener
Copy link

hisener commented Aug 20, 2024

https://bazel.build/release says it's EOL in Jan 2025.

@aschott-looker
Copy link

@tpasternak We definitely want to upgrade to a more recent version of Bazel but it's not feasible in the short term. So I was hoping for a quick workaround.

Thanks for creating the issues above!

@tpasternak
Copy link
Collaborator

the hotfix is on its way #6653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: IntelliJ IntelliJ plugin
Projects
Development

Successfully merging this pull request may close these issues.

9 participants