Skip to content

[VL] Promote SharedLibraryLoader to SPI#10774

Merged
yaooqinn merged 4 commits intoapache:mainfrom
yaooqinn:spi
Sep 24, 2025
Merged

[VL] Promote SharedLibraryLoader to SPI#10774
yaooqinn merged 4 commits intoapache:mainfrom
yaooqinn:spi

Conversation

@yaooqinn
Copy link
Member

What changes are proposed in this pull request?

This PR promotes SharedLibraryLoader to SPI. Enable developers to create a custom SharedLibraryLoader tailored to their specific environments.

Besides the existing loadLib function, a new method accepts is defined for SharedLibraryLoaders to identify whether it satisfies the given options or os release information.

How was this patch tested?

new tests

@github-actions github-actions bot added the VELOX label Sep 22, 2025
Copy link
Member

@zhztheplayer zhztheplayer left a comment

Choose a reason for hiding this comment

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

Thanks. May I know the motivation of adding the SPI? Do you place a user-customized shared loader implementation?

Comment on lines +64 to +67
val loaders = ServiceLoader
.load(classOf[SharedLibraryLoader])
.asScala
.filter(loader => loader.accepts(osName, osVersion))
Copy link
Member

@zhztheplayer zhztheplayer Sep 22, 2025

Choose a reason for hiding this comment

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

What happens when more than one loaders are returned?

Copy link
Member Author

@yaooqinn yaooqinn Sep 23, 2025

Choose a reason for hiding this comment

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

First in, first load && Best effort to load one if successful.

Copy link
Member

@zhztheplayer zhztheplayer Sep 23, 2025

Choose a reason for hiding this comment

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

Do we already have this use case (multiple loaders returned)? Otherwise let's simply throw an error because the loading priority is not guaranteed?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is new. If we leave this conflict error for users, how do they suppose to fix it

Copy link
Member

Choose a reason for hiding this comment

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

For example, if user adds their own loader implementation of CentOS 9, does the code ensure their implementation is chosen over the built-in SharedLibraryLoaderCentos9?

Can we add a simple priority API to SharedLibraryLoader, so the loading process is more deterministic?

Copy link
Member Author

Choose a reason for hiding this comment

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

For example, if user adds their own loader implementation of CentOS 9, does the code ensure their implementation is chosen over the built-in SharedLibraryLoaderCentos9?

The new SharedLibraryLoaderCentos9 can define its own accepts logic with osName or osVersion to distinguish the built-in one. Then, configs loadLibOS/loadLibOSVersion can help the caller side to decide which one to pick.

Can we add a simple priority API to SharedLibraryLoader, so the loading process is more deterministic?

I tried, but the priority API didn't mitigate the issue here since the conflict loaders can also have identical priority.

Maybe we shall just throw errors when conflicting

Copy link
Member

Choose a reason for hiding this comment

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

Making sense to me then. Thanks for the explanation.

@yaooqinn
Copy link
Member Author

Do you place a user-customized shared loader implementation?

Yes, and then I don't need to modify the gluten main code base

@yaooqinn yaooqinn merged commit dc38213 into apache:main Sep 24, 2025
55 checks passed
@yaooqinn
Copy link
Member Author

Thank you, @zhztheplayer, for the detailed review and suggestions.

@yaooqinn yaooqinn deleted the spi branch September 24, 2025 08:02
@zhztheplayer
Copy link
Member

No problem. Thank you for the contribution!

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.

2 participants