-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Mono] Optimize mono_dl_build_path for component and Android module loading. #54971
[Mono] Optimize mono_dl_build_path for component and Android module loading. #54971
Conversation
Tagging subscribers to this area: Issue Detailsmono_dl_build_path probes a lot of variations of paths and in some situations where modules uses platform specific naming, it could try at least two paths before getting to the correct one. This have been a problem for Android a long time since IO is slow For dynamic component loading the existing schema is particular bad since the scenario of disabling a component means that the component won't exist, and using the existing probing it could do 3 or more load attempts before realize that the component is not present and use the stub implmenentation. Commit splits current mono_dl_build_path probing logic so it can be customized. For components a new function has been added that will always use platform prefix and platform suffixes, and if not found Commit also change the default behavior of mono_dl_build_path on Android reversing current schema making it more likely to find modules using platform specific naming, like libMyLibrary.so, in first attempt. It will still fallback using no prefix and default suffix and then the verbatim name to make sure dllimports will still work as before, but favorizing modules using platform specific naming. On all other platforms mono_dl_build_path will continue to keep its current behaviour.
|
//cc @grendello |
a35c8db
to
56156d0
Compare
mono_dl_build_path probes a lot of variations of paths and in some situations where modules uses platform specific naming, it could try at least two paths before getting to the correct one. This have been a problem for Android a long time since IO is slow on devices, so always failing two probes per module load adds to the startup time on Android. For dynamic component loading the existing schema is particular bad since the scenario of disabling a component means that the component won't exist, and using the existing probing it could do 3 or more load attempts before realize that the component is not present and use the stub implmenentation. Commit splits current mono_dl_build_path probing logic so it can be customized. For components a new function has been added that will always use platform prefix and platform suffixes, and if not found it will stop looking. For most platform that means only one attempt to load a component instead of at least 3, optimize both the scenario when the component is awailable as well as when it should be disabled. Commit also change the default behavior of mono_dl_build_path on Android reversing current schema making it more likely to find modules using platform specific naming, like libMyLibrary.so, in first attempt. It will still fallback using no prefix and default suffix and then the verbatim name to make sure dllimports will still work as before, but favorizing modules using platform specific naming. On all other platforms mono_dl_build_path will continue to keep its current behaviour.
Cache try load history reduce try_load calls when library host multiple components (like diagnostics_tracing). Change mobile to not try components_dir, just loading using name directly. Above changes result in mono_dl_get_so_suffixes number of dl_open attempts per component library and on Android that will be one attempt independt of components begin enabled or disabled.
56156d0
to
032341f
Compare
@lambdageek Still ok after adjustments? |
mono_dl_build_path probes a lot of variations of paths and in some situations where modules uses platform specific naming, it could try at least two paths before getting to the correct one. This have been a problem for Android a long time since IO is slow
on devices, so always failing two probes per module load adds to the startup time on Android.
For dynamic component loading the existing schema is particular bad since the scenario of disabling a component means that the component won't exist, and using the existing probing it could do 3 or more load attempts before realize that the component is not present and use the stub implmenentation.
Commit splits current mono_dl_build_path probing logic so it can be customized.
For components a new function has been added that will always use platform prefix and platform suffixes, and if not found
it will stop looking. For most platform that means only one attempt to load a component instead of at least 3, optimize both the scenario when the component is awailable as well as when it should be disabled.
Commit also change the default behavior of mono_dl_build_path on Android reversing current schema making it more likely to find modules using platform specific naming, like lib*.so, in first attempt. It will still fallback using no prefix and default suffix and then the verbatim name to make sure dllimports will still work as before, but favorizing modules using platform specific naming.
On all other platforms mono_dl_build_path will continue to keep its current behaviour.