[jira] [Created] (IGNITE-2582) j.u.Collections.singletonIterator() allocations during TX cache puts.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (IGNITE-2582) j.u.Collections.singletonIterator() allocations during TX cache puts.

Anton Vinogradov (Jira)
Vladimir Ozerov created IGNITE-2582:
---------------------------------------

             Summary: j.u.Collections.singletonIterator() allocations during TX cache puts.
                 Key: IGNITE-2582
                 URL: https://issues.apache.org/jira/browse/IGNITE-2582
             Project: Ignite
          Issue Type: Sub-task
          Components: cache
    Affects Versions: 1.5.0.final
            Reporter: Vladimir Ozerov
             Fix For: 1.6


*Problem*
Allocations came from several sources:
1) IgniteTxManager.lockMultiple
2) IgniteTxManager.notifyEvictions
3) IgniteTxManager.removeObsolete
4) IgniteTxManager.unlockMultiple
5) GridDhtTxLocalAdapter.mapExplicitLocks

In all these code pieces we have the same pattern:
{code}
for (T t : collection) {
    logic(t)
}
{code}

*Solution*
Perform simple refactoring:
{code}
if (collection isntanceof List) {
    for (int i = 0; i < ((List)colllection).size()) {
        logic(collection.get(i));
    }
}
else {
    for (T t : collection) {
        logic(t)
    }
}
{code}
Though, we should be careful with LinkedList here - such refactoring will slowdown processing.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)