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

PAYARA-3267 Fixing memory-wastage with JavaEETransactionImpl #3398

Merged
merged 9 commits into from Nov 15, 2018

Conversation

Projects
None yet
5 participants
@svendiedrichsen
Contributor

svendiedrichsen commented Nov 8, 2018

Replacing usage of java.util.Timer/TimerTask with PayaraExecutorService/ScheduledExecutorService which is configured to remove cancelled tasks immediately.

This should fix #3396

#3396 Replacing usage of java.util.Timer with PayaraExecutorService w…
…hich is configured to remove cancelled tasks immediately
@lprimak

lprimak approved these changes Nov 9, 2018

@arjantijms

This comment has been minimized.

Member

arjantijms commented Nov 10, 2018

Jenkins test please

TimeUnit.valueOf(payaraExecutorServiceConfiguration.getThreadPoolExecutorKeepAliveTimeUnit()),
new SynchronousQueue<>(), (Runnable r) -> new Thread(r, "payara-executor-service-task"));
}
scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
Integer.valueOf(payaraExecutorServiceConfiguration.getScheduledThreadPoolExecutorCorePoolSize()),
(Runnable r) -> new Thread(r, "payara-executor-service-scheduled-task"));
scheduledThreadPoolExecutor.setRemoveOnCancelPolicy(true);

This comment has been minimized.

@smillidge

smillidge Nov 11, 2018

Contributor

I think this should be configurable on the service

This comment has been minimized.

@smillidge

smillidge Nov 11, 2018

Contributor

Also I think the old purge on x number of tasks should be also retained in case there is a performance hit on removing the tasks for many small and rapid transactions like in high volume web applications with timeouts enabled.

This comment has been minimized.

@svendiedrichsen

svendiedrichsen Nov 11, 2018

Contributor

Removed config from PayaraExecutorService

@@ -109,11 +112,13 @@
@Inject protected InvocationManager invMgr;
@Inject private Provider<RequestTracingService> requestTracing;
@Inject private PayaraExecutorService payaraExecutorService;

This comment has been minimized.

@smillidge

smillidge Nov 11, 2018

Contributor

I don't think Payara Executor Service should be used for this. This is core application processing logic and I feel this could overload the Payara Executor Service which was planned for more internal tasks. For example if you have a web application performing 100s of requests per second with timeouts enabled we could be adding and removing 100s of timeout tasks per second on this Executor Pool. I approve of replacing timer with the more modern executor service though.

This comment has been minimized.

@svendiedrichsen

svendiedrichsen Nov 14, 2018

Contributor

Replaced PayaraExecutorService with newly created ScheduledThreadPoolExecuter

svendiedrichsen added some commits Nov 11, 2018

replacing usage of PayaraExecutorService with creation of new Schedul…
…edThreadPoolExecutorService. Using this service also for local monitoring timer.
removing automatic removal of cancelled tx scheduled tasks and implem…
…enting usage of configuration of tx service property purge-cancelled-transactions-after. using scheduled task to purge.
@svendiedrichsen

This comment has been minimized.

Contributor

svendiedrichsen commented Nov 11, 2018

@smillidge Implemented your requested changes. Maybe the production domain configuration Payara comes with should set a sensible default value for the transaction service property purge-cancelled-transactions-after to lower memory usage.

@svendiedrichsen

This comment has been minimized.

Contributor

svendiedrichsen commented Nov 11, 2018

@smillidge Nice to see you going all-in on the PayaraExecutorService. Using it everywhere now. ;)

@arjantijms

This comment has been minimized.

Member

arjantijms commented Nov 12, 2018

Jenkins test please

Limiting the number of threads to 3. Setting purge interval to 5 sec.…
… Setting purge property in production domain.xml to 500.
@lprimak

This comment has been minimized.

Contributor

lprimak commented Nov 13, 2018

jenkins test

svendiedrichsen added some commits Nov 14, 2018

Merge branch 'master' of https://github.com/payara/Payara into memory…
…-waste-using-timer

# Conflicts:
#	appserver/admin/production_domain_template/src/main/resources/config/domain.xml
@svendiedrichsen

This comment has been minimized.

Contributor

svendiedrichsen commented Nov 14, 2018

Resolved merge conflicts

@arjantijms

This comment has been minimized.

Member

arjantijms commented Nov 15, 2018

Jenkins test please

Outdated and Resolved

@Pandrex247 Pandrex247 changed the title from Fixing memory-wastage with JavaEETransactionImpl to PAYARA-3267 Fixing memory-wastage with JavaEETransactionImpl Nov 15, 2018

@Pandrex247

This comment has been minimized.

Member

Pandrex247 commented Nov 15, 2018

Fixes #3396

@arjantijms arjantijms merged commit 9698ea0 into payara:master Nov 15, 2018

1 check passed

Payara Quick Build and Test Quick build and test passed!
Details

@svendiedrichsen svendiedrichsen deleted the svendiedrichsen:memory-waste-using-timer branch Nov 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment