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

Make it possible to ignore existing native configuration with the native tracing agent #3283

Closed
sdeleuze opened this issue Mar 15, 2021 · 5 comments
Assignees
Labels
feature spring spring related issue
Milestone

Comments

@sdeleuze
Copy link
Collaborator

One simple but very useful feature would be to allow to ignore existing native configuration with the tracing agent. For example, the agent could be aware of the configuration in META-INF/native-image/*.json in the project and generate only what is not already present in this existing configuration.

A very interesting use case would be with Spring Native that generates all the configuration it can using an analysis of the Spring application via the Spring AOT build plugins. Currently even with all that inferred configuration, if just a few entries were missing, they are totally lost in the huge configuration files generated by the agent.

This enhancement would allow the tracing agent to just generate "the useful diff" that could then be taken and used as it is or converted to Spring @NativeHint. We think that feature would be useful outside of Spring as well.

I would be in favor of that being the default behavior. If that's not possible or if you consider that's not a good idea, providing a configuration flag on the agent would be fine.

@aclement
Copy link

aclement commented Apr 9, 2021

I'll just mention I did some experiments around this in a branch of mine:
https://github.com/aclement/graal/tree/agent-filtering

It's a bit unfinished but the principles are there:

  • it discovers META-INF/native-image entries on the classpath (in directories, don't think it goes into jars yet)
  • loads them up into a separate configurationset
  • subtracts that configurationset from the collected set before it is written out (possible to do this as you go I suppose, I just did something quick).
  • it attempts to simplify entries in the agent output as much as possible, so it is quite granular, it doesn't just remove them if they are identical, it strips them down (for example if the existing config named 3 methods and the computed config contained 5, it should remove 3 from the computed config)

For our webmvc-tomcat sample, I saw the line count for reflect-config.json go from 2800 to 1900.

@gradinac gradinac modified the milestones: 21.2, 21.3 Jun 15, 2021
@gradinac
Copy link
Contributor

Hey @aclement! Your approach for this change is good, and the principles it follows (filtering configuration when it's written out and simplifying entries) is basically the same as it's now implemented on master: a461aa0

There are two different agent flags related to this mode:

  • experimental-omit-config-from-classpath omits configuration present on the classpath, both in directories and JARs
  • config-to-omit=<path> omits configuration from a specified directory

This feature won't be in the upcoming 21.2 release, but it's on master and should soon be available in the dev builds. If anyone has a chance to test it out - please do and let me if it works for you

@gradinac
Copy link
Contributor

I'll close this issue as the feature had made it into 21.3 - let me know if you hit any issues/have any questions about the feature

Native Image automation moved this from To do to Done Sep 22, 2021
@sdeleuze
Copy link
Collaborator Author

@jtjeferreira
Copy link

Is there any work planned to improve the filtering as per @sdeleuze comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature spring spring related issue
Projects
Native Image
  
Done
Development

No branches or pull requests

5 participants