Skip to content

Commit

Permalink
Merge pull request #2267 from warunalakshitha/java21_perf
Browse files Browse the repository at this point in the history
Remove unnecessary virtual thread creation
  • Loading branch information
warunalakshitha authored Jan 9, 2025
2 parents b58e52d + ea84aee commit 92e1281
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.11.0-20241218-101200-109f6cc7"
distribution-version = "2201.11.0-20250109-162500-c85851f4"

[[package]]
org = "ballerina"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.caching=true
group=io.ballerina.stdlib
version=2.13.0-SNAPSHOT
ballerinaLangVersion=2201.11.0-20241218-101200-109f6cc7
ballerinaLangVersion=2201.11.0-20250109-162500-c85851f4
ballerinaTomlParserVersion=1.2.2
commonsLang3Version=3.12.0
nettyVersion=4.1.115.Final
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,13 @@ private void returnErrorResponse(BError error) {
}

public void invokeBalMethod(Object[] paramFeed, String methodName) {
Thread.startVirtualThread(() -> {
try {
StrandMetadata metaData = new StrandMetadata(false, null);
runtime.callMethod(caller, methodName, metaData, paramFeed);
stopObserverContext();
} catch (BError error) {
sendFailureResponse(error);
}
});
try {
StrandMetadata metaData = new StrandMetadata(true, null);
runtime.callMethod(caller, methodName, metaData, paramFeed);
stopObserverContext();
} catch (BError error) {
sendFailureResponse(error);
}
}

public void stopObserverContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,13 @@ private void returnResponse(Object result) {
}

public void invokeBalMethod(Object[] paramFeed, String methodName) {
Thread.startVirtualThread(() -> {
try {
StrandMetadata metaData = new StrandMetadata(false, null);
runtime.callMethod(caller, methodName, metaData, paramFeed);
} catch (BError error) {
cleanupRequestMessage();
HttpUtil.handleFailure(requestMessage, error);
}
});
try {
StrandMetadata metaData = new StrandMetadata(true, null);
runtime.callMethod(caller, methodName, metaData, paramFeed);
} catch (BError error) {
cleanupRequestMessage();
HttpUtil.handleFailure(requestMessage, error);
}
}

private int getRequestInterceptorId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,16 @@ private void returnResponse(Object result) {

@Override
public void invokeBalMethod(Object[] paramFeed, String methodName) {
Thread.startVirtualThread(() -> {
try {
StrandMetadata metaData = new StrandMetadata(true, null);
this.getRuntime().callMethod(caller, methodName, metaData, paramFeed);
stopObserverContext();
dataContext.notifyOutboundResponseStatus(null);
} catch (BError error) {
dataContext.notifyOutboundResponseStatus(null);
sendFailureResponse(error);
}
});

try {
StrandMetadata metaData = new StrandMetadata(true, null);
this.getRuntime().callMethod(caller, methodName, metaData, paramFeed);
stopObserverContext();
dataContext.notifyOutboundResponseStatus(null);
} catch (BError error) {
dataContext.notifyOutboundResponseStatus(null);
sendFailureResponse(error);
}
}

private int getResponseInterceptorId() {
Expand Down

0 comments on commit 92e1281

Please sign in to comment.