Performance issue due to dynamic query creation

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2012 12:15 PM
Hi,
we made some performance tests with Activiti on a hardware with 12 cores (tomcat server with Activiti + separate database server).
During these tests we observed a contention in MyBatis' dynamic query creation mechanism which is called from ExecutionEntity.remove() for every finished process instance.
The dynamic queries are created by: TaskQueryImpl(commandContext).executionId(id).list() and JobQueryImpl(commandContext).executionId(id).list(), see below:
As an example the statement for selecting the jobs belonging to a process instance (from our changed /org/activiti/db/mapping/entity/Job.xml😞
Some more details concerning our tests:
The test scenario was a multi-threaded test client that started process instances and waited for their completion, measuring the throughput: how many processes completed in a given time (e.g. per minute).
The test process had the following features:
) alternatives that we may have overlooked.
we made some performance tests with Activiti on a hardware with 12 cores (tomcat server with Activiti + separate database server).
During these tests we observed a contention in MyBatis' dynamic query creation mechanism which is called from ExecutionEntity.remove() for every finished process instance.
The dynamic queries are created by: TaskQueryImpl(commandContext).executionId(id).list() and JobQueryImpl(commandContext).executionId(id).list(), see below:
… CommandContext commandContext = Context.getCommandContext(); List<TaskEntity> tasks = (List) new TaskQueryImpl(commandContext) .executionId(id) .list(); for (TaskEntity task : tasks) { if (replacedBy!=null) { task.setExecution(replacedBy); } else { commandContext .getTaskManager() .deleteTask(task, TaskEntity.DELETE_REASON_DELETED, false); } } List<Job> jobs = new JobQueryImpl(commandContext) .executionId(id) .list(); for (Job job: jobs) { if (replacedBy!=null) { ((JobEntity)job).setExecution((ExecutionEntity) replacedBy); } else { ((JobEntity)job).delete(); } } …
For our tests we changed the creation of the two dynamic queries to static queries (since the dynamic queries always evaluate to the same SELECT statement anyway). This change led to a performance increase of up to 100% in our tests.As an example the statement for selecting the jobs belonging to a process instance (from our changed /org/activiti/db/mapping/entity/Job.xml😞
<select id="selectJobsByExecutionId" parameterType="string" resultMap="jobResultMap"> select * from ACT_RU_JOB J where J.EXECUTION_ID_ = #{executionId} </select>
Note also the following quote from http://forums.activiti.org/en/viewtopic.php?f=6&t=1523#p6386 about the queries in ExecutionEntity.remove():Profiler shows that they consume at least 50-70% of overall time.We created a Jira issue (ACT-1056) and can contribute a patch if needed.
Some more details concerning our tests:
The test scenario was a multi-threaded test client that started process instances and waited for their completion, measuring the throughput: how many processes completed in a given time (e.g. per minute).
The test process had the following features:
- main process:
- two ServiceTasks performing db updates (each with asynchronous continiuation)
- two ServiceTasks sending jms notifications back to the test client
- call of a sub process (with asynchronous continiuation)
- sub process
- two ServiceTasks that call WebServices (SoapUI simulator was used for these WebServices)
- two exclusive gateways

Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2012 09:40 AM
Interesting find.
I'm definitely interested in a patch attached to the jira.
I'm definitely interested in a patch attached to the jira.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2012 07:18 AM
ok, I will upload a patch soon
Best regards,
Christian
Best regards,
Christian

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2012 08:51 AM
Hi,
I attached two patches to the JIRA issue. One for the current trunk, one for Activiti, version 5.8.
I am looking forward to the review.
Best regards,
Christian
I attached two patches to the JIRA issue. One for the current trunk, one for Activiti, version 5.8.
I am looking forward to the review.
Best regards,
Christian
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2012 03:45 AM
Thanks, I'll review them shortly and comment on the issue. Thanks!

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2012 08:09 AM
Hi Jerome,
any news on this? Did you review the patch?
Thanks in advance,
Christian
any news on this? Did you review the patch?
Thanks in advance,
Christian
