Skip to content

Allow to disable deleting of the native library file after it is loaded. - #6118

Closed
normanmaurer wants to merge 1 commit into
4.1from
delete_after_loading
Closed

normanmaurer wants to merge 1 commit into
4.1from
delete_after_loading

Conversation

@normanmaurer

@normanmaurer normanmaurer commented Dec 8, 2016 •

Copy link
Copy Markdown
Member

Motivation:

When profiling it is sometimes needed to still have the native library file avaible. We should allow to disable the explicit deletion and just delete it when the JVM stops.

This is related to #6110

Modifications:

Add io.netty.native.deleteLibAfterLoading system property which allows to disable the explicit delete after laoding

Result:

Possible to profile native libraries better.

Motivation:

When profiling it is sometimes needed to still have the native library file avaible. We should allow to disable the explicit deletion and just delete it when the JVM stops.

This is related to #6110

Modifications:

Add io.netty.native.deleteLibAfterLoading system property which allows to disable the explicit delete after laoding

Result:

Possible to profile native libraries better.
@normanmaurer normanmaurer added this to the 4.0.43.Final milestone Dec 8, 2016
@normanmaurer normanmaurer self-assigned this Dec 8, 2016
@normanmaurer

Copy link
Copy Markdown
Member Author

@tjake I think this is what you need, can you verify ?

@Scottmitch PTAL

@tjake

tjake commented Dec 9, 2016

Copy link
Copy Markdown
Contributor

+1

}

DELETE_NATIVE_LIB_AFTER_LOADING = SystemPropertyUtil.getBoolean(
"io.netty.native.deleteLibAfterLoading", true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this be scoped to a particular library? Just wondering if we ever load multiple libraries using this loader if we want to have a global flag or scope it per load.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it should be global

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

couldn't we build the global flag at a higher level if the low level library loader allows individual libraries to be configured?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What you mean? I am not sure I understand what you are suggesting

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

// NativeLibraryLoader.java

// Users can call this method if they want to respect the default.
// This also allows users to apply their own logic ...
// e.g. maybe EPOLL, KQUEUE, TCNATIVE have their own properties at some point.
public static boolean defaultDeleteAfterLoading() {
  return DELETE_NATIVE_LIB_AFTER_LOADING;
}

public static void loadFirstAvailable(boolean deleteAfterLoading, ClassLoader loader, String... names) {
// load(deleteAfterLoading, loader, name);
}

public static void load(boolean deleteAfterLoading, String name, ClassLoader loader) {
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Scottmitch I can do this but I think either you want it for all or for none. So I think it is overkill and makes not a lot of sense in a practical sense. So please tell me if you feel super strong about it and if so I will do, but honestly I think it makes more sense as it is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, I'm not strong on this. Feel free to pull in.

I would generally prefer to express configuration in terms of API as opposed to introduce another vector (system properties) which impacts the API. This is a more general concern in Netty though IMO there is room for improvement in configuration/setup.

@Scottmitch Scottmitch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

feel free to pull in

@normanmaurer

Copy link
Copy Markdown
Member Author

Cherry-picked into 4.1 (fe2b55c) and 4.0 (6a0f30d)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants