[
https://issues.apache.org/jira/browse/ARTEMIS-2949?focusedWorklogId=502698&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-502698
]
ASF GitHub Bot logged work on ARTEMIS-2949:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 20/Oct/20 13:45
Start Date: 20/Oct/20 13:45
Worklog Time Spent: 10m
Work Description: franz1981 commented on a change in pull request #3303:
URL: https://github.com/apache/activemq-artemis/pull/3303#discussion_r508516812
##########
File path:
artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/OperationContextImpl.java
##########
@@ -191,41 +192,75 @@ public void executeOnCompletion(final IOCallback
completion, final boolean store
}
+ private boolean validateTasksAdd(int storeLined, int replicationLined, int
pageLined) {
+ if (tasks.isEmpty()) {
+ return true;
+ }
+ final TaskHolder holder = tasks.peekLast();
+ if (holder.storeLined > storeLined ||
+ holder.replicationLined > replicationLined ||
+ holder.pageLined > pageLined) {
+ return false;
+ }
+ return true;
+ }
+
@Override
public synchronized void done() {
stored++;
checkTasks();
}
+ private void checkStoreTasks() {
+ final LinkedList<StoreTaskHolder> storeOnlyTasks = this.storeOnlyTasks;
+ assert storeOnlyTasks != null;
+ final int size = storeOnlyTasks.size();
+ if (size == 0) {
+ return;
+ }
+ final long stored = this.stored;
+ for (int i = 0; i < size; i++) {
+ final StoreTaskHolder holder = storeOnlyTasks.peek();
+ if (holder.storeLined < stored) {
+ // fail fast: storeOnlyTasks are ordered by storeLined, there is
no need to continue
+ return;
+ }
+ // If set, we use an executor to avoid the server being single
threaded
+ execute(holder.task);
+ final StoreTaskHolder removed = storeOnlyTasks.poll();
+ assert removed == holder;
+ }
+ }
+
+ private void checkGenericTasks() {
+ final LinkedList<TaskHolder> tasks = this.tasks;
+ assert tasks != null;
+ final int size = this.tasks.size();
+ if (size == 0) {
+ return;
+ }
+ assert size >= 1;
+ // no need to use an iterator here, we can save that cost
+ for (int i = 0; i < size; i++) {
+ final TaskHolder holder = tasks.peek();
+ if (stored < holder.storeLined || replicated <
holder.replicationLined || paged < holder.pageLined) {
+ // End of list here. No other task will be completed after this
+ return;
+ }
+ execute(holder.task);
+ final TaskHolder removed = tasks.poll();
+ assert removed == holder;
+ }
+ }
+
private void checkTasks() {
if (storeOnlyTasks != null) {
- Iterator<TaskHolder> iter = storeOnlyTasks.iterator();
- while (iter.hasNext()) {
- TaskHolder holder = iter.next();
- if (stored >= holder.storeLined) {
- // If set, we use an executor to avoid the server being single
threaded
- execute(holder.task);
-
- iter.remove();
- }
- }
+ checkStoreTasks();
}
if (stored >= minimalStore && replicated >= minimalReplicated && paged
>= minimalPage) {
- Iterator<TaskHolder> iter = tasks.iterator();
- while (iter.hasNext()) {
- TaskHolder holder = iter.next();
- if (stored >= holder.storeLined && replicated >=
holder.replicationLined && paged >= holder.pageLined) {
- // If set, we use an executor to avoid the server being single
threaded
- execute(holder.task);
-
- iter.remove();
- } else {
- // End of list here. No other task will be completed after this
- break;
- }
- }
+ checkGenericTasks();
Review comment:
checkGenericTasks -> checkCompleteContext ok?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 502698)
Time Spent: 1h (was: 50m)
> Reduce GC on OperationContext::checkTasks
> -----------------------------------------
>
> Key: ARTEMIS-2949
> URL: https://issues.apache.org/jira/browse/ARTEMIS-2949
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Reporter: Francesco Nigro
> Assignee: Francesco Nigro
> Priority: Minor
> Time Spent: 1h
> Remaining Estimate: 0h
>
> OperationContext::checkTasks is allocating Iterators that seems not scalar
> replaced and that could be saved by using the Queue API of LinkedList.
> Similarly, store only tasks can use a reduced (in term of footprint) task
> holder to reduce the allocation pressure.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)