Skip to content

Conversation

@nandorsoma
Copy link
Contributor

No description provided.


public FunctionExecutor(FunctionContext context, String functionName) {
this.metricTracker = new FunctionMetricTracker(context, functionName);
this.executorService = Executors.newFixedThreadPool(10);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, I couldn’t find a way to share the executor. The most optimal approach would be to borrow one from the context, but as far as I know, such a feature doesn’t exist. Would it make sense to make the pool size configurable via an environment variable, specific to the function? For instance, something like FUNCTION_NAME.toUpperCase() + "_POOL_SIZE".

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine, we can have one threadpool per function and use a single environment variable ASYNC_FUNCTION_THREAD_POOL_SIZE to control it across all functions. We can later decide if we need to make it function specific.

Copy link
Contributor

@mbroecheler mbroecheler left a comment

Choose a reason for hiding this comment

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

Nice! Two smallish changes, please


public FunctionExecutor(FunctionContext context, String functionName) {
this.metricTracker = new FunctionMetricTracker(context, functionName);
this.executorService = Executors.newFixedThreadPool(10);
Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine, we can have one threadpool per function and use a single environment variable ASYNC_FUNCTION_THREAD_POOL_SIZE to control it across all functions. We can later decide if we need to make it function specific.

metricTracker.increaseCallCount();
final long start = System.nanoTime();

T result = executeWithRetry(
Copy link
Contributor

Choose a reason for hiding this comment

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

Flink async functions have retry build-in now:
https://nightlies.apache.org/flink/flink-docs-release-1.19/docs/dev/table/config/#table-exec-async-scalar-retry-strategy

Please remove the retry logic and just keep the metrics piece.

… Adding ASYNC_FUNCTION_THREAD_POOL_SIZE environment variable to control function threadpool size.
@nandorsoma nandorsoma merged commit 1c5d212 into main Dec 18, 2024
1 check failed
@nandorsoma nandorsoma deleted the 23-refactor-openai-functions-to-use-async-functions-interface-for-improved-performance branch December 18, 2024 10:44
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.

Refactor OpenAI Functions to Use Async Functions Interface for Improved Performance

3 participants