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

Optimize built-in source/sink startup Part 2 #9500

Merged

Conversation

jerrypeng
Copy link
Contributor

Motivation

As a follow up to #9413. Allow the ThreadRuntime to leverage the already loaded and cached built-in connector registry so that it does not need to unpack NARs and calculate MD5 checksums as well.

Modifications

  • Moved the jar loading logic from JavaInstanceRunnable to ThreadRuntime.
  • Add logic in ThreadRuntime to extract a classloader from a function package, e.g. JAR, or if it is a built-in connector just get it from the ConnectorManager.
  • Refactored JavaInstanceRunnable to take in classloader for the user function instead of jar paths.
  • Change the RuntimeFactory interface to allow ConnectorsManager to be passed in so that the ThreadRuntimeFactory can use it.

Jerry Peng added 2 commits February 5, 2021 11:37
…packing and checksum calculation Part 2. Allow ThreadRuntime to used cached built-in connectors instead of unpacking and loading again.
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

fnCache.unregisterFunctionInstance(
instanceConfig.getFunctionId(),
instanceConfig.getInstanceName());
log.info("Unloading JAR files for function {}", instanceConfig);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to move this line one line above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@sijie
Copy link
Member

sijie commented Feb 8, 2021

@nlu90 @freeznet Can you review this?

@david-streamlio
Copy link
Contributor

LGTM +1

Copy link
Member

@nlu90 nlu90 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +148 to +151
fnClassLoader = fnCache.getClassLoader(instanceConfig.getFunctionId());
if (null == fnClassLoader) {
throw new Exception("No function class loader available.");
}
Copy link
Member

Choose a reason for hiding this comment

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

should this null check goes before the log.info on line 145 to avoid confusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is the existing logic. I rather not change it in this PR. It is kind of out of scope.

@jerrypeng jerrypeng merged commit c27f7a3 into apache:master Feb 8, 2021
@eolivelli
Copy link
Contributor

Great!
I believe that this work will speed up a lot the integration tests

Thanks

merlimat pushed a commit to merlimat/pulsar that referenced this pull request Apr 6, 2021
* Optimize built-in source/sink startup by eliminating redundant NAR unpacking and checksum calculation Part 2. Allow ThreadRuntime to used cached built-in connectors instead of unpacking and loading again.

Co-authored-by: Jerry Peng <jerryp@splunk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants