-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
里面用到的JSqlParser有严重性能问题 #764
Comments
jsqlparser4.8已经支持传入TimeoutService了: @Test
public void testParserInterruptedByTimeout() {
MemoryLeakVerifier verifier = new MemoryLeakVerifier();
int parallelThreads = Runtime.getRuntime().availableProcessors() + 1;
ExecutorService executorService = Executors.newFixedThreadPool(parallelThreads);
ExecutorService timeOutService = Executors.newSingleThreadExecutor();
for (int i = 0; i < parallelThreads; i++) {
executorService.submit(new Runnable() {
@Override
public void run() {
try {
CCJSqlParser parser =
CCJSqlParserUtil.newParser(INVALID_SQL)
.withAllowComplexParsing(true);
verifier.addObject(parser);
CCJSqlParserUtil.parseStatement(parser, timeOutService);
} catch (JSQLParserException ignore) {
// We expected that to happen.
}
}
});
}
timeOutService.shutdownNow();
executorService.shutdown();
// we should not run in any timeout here (because we expect that the Parser has timed out by
// itself)
assertDoesNotThrow(new Executable() {
@Override
public void execute() throws Throwable {
executorService.awaitTermination(20, TimeUnit.SECONDS);
}
});
// we should not have any Objects left in the weak reference map
verifier.assertGarbageCollected();
} |
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
每次调这个parse方法时候,他里面就创建一个单线程的线程池,然后同步解析,之后就销毁线程,目的就为了加一个8秒超时抛异常的逻辑。。。我并发请求分页接口,服务的线程数直接飙升了200个,简直了,而且最后这个feature.get还全都8秒超时抛异常!
而且...为毛它会存在8秒都解析不完的情况啊,这究竟是什么性能...
The text was updated successfully, but these errors were encountered: