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

Various suggestions #1277

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Various suggestions #1277

wants to merge 6 commits into from

Conversation

gsmet
Copy link
Contributor

@gsmet gsmet commented Dec 26, 2024

@radcortez I pushed several suggestions here. Some are easy wins that we could apply without too much discussion, some are maybe more controversial.

I would very much like to discuss Provide some shortcuts for simple config properties as this commit clearly removes some work (and I checked the generated bytecode and it looks like it's actually less work) but it seems to make things a bit slower and I wasn't able to pinpoint what was going on.

Interested in your feedback :).

Given we are adding quite a lot of elements, there are a lot of chances
the maps will have to be resized several times.
The convertProfile() method is called several times and there's no need
to create the converter again and again.
It seems counter productive to throw so many NoSuchMethodExceptions for
these common uses cases.
This avoids a bunch of allocations, including the allocation of an
ObjectCreator for each property.
It was kept simple on purpose as a base for discussions.

Note that, interestingly enough, my startup actually got a bit slower
with this patch which makes little sense... I thought it might be
interesting to discuss this line of thoughts anyway.
Copy link
Member

@radcortez radcortez left a comment

Choose a reason for hiding this comment

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

Thanks!

Let me have a better look at the bytecode pieces. For the remaining changes, I think we should open separate PR's.

@@ -67,65 +67,25 @@ private Converters() {

static final Converter<ConfigValue> CONFIG_VALUE_CONVERTER = new ConfigValueConverter();

static final Converter<String> STRING_CONVERTER = BuiltInConverter.of(0, newEmptyValueConverter(value -> value));
Copy link
Member

Choose a reason for hiding this comment

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

I've made a similar proposal in #1249, but we ended up not moving forward with it.

@Priority(Priorities.LIBRARY + 200)
public class ProfileConfigSourceInterceptor implements ConfigSourceInterceptor {
private static final long serialVersionUID = -6305289277993917313L;

private static final Converter<ArrayList<String>> PROFILES_CONVERTER = newCollectionConverter(
Copy link
Member

Choose a reason for hiding this comment

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

+1

return hashCode;
}

private int buildHashCode() {
Copy link
Member

Choose a reason for hiding this comment

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

+1

@@ -28,7 +28,7 @@ public ConfigValue getValue(final ConfigSourceInterceptorContext context, final

@Override
public Iterator<String> iterateNames(final ConfigSourceInterceptorContext context) {
if (SecretKeys.isLocked()) {
if (!secrets.isEmpty() && SecretKeys.isLocked()) {
Copy link
Member

Choose a reason for hiding this comment

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

+1

@@ -1142,6 +1078,14 @@ static <T> Converter<T> getConverter(Class<? extends T> clazz) {
return new HyphenateEnumConverter(clazz);
}

// some shortcuts for common used classes
if ("java.io.File".equals(clazz.getName())) {
Copy link
Member

Choose a reason for hiding this comment

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

+1

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.

2 participants