Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 286013 Details for
Bug 570670
Optimisations for GarbageCleaner
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
4_introduce_threadlocal_cache_for_indexwriter_getpage
4_introduce_threadlocal_cache_for_indexwriter_getpage.patch (text/plain), 2.71 KB, created by
Jason Koch
on 2021-04-01 00:23:14 EDT
(
hide
)
Description:
4_introduce_threadlocal_cache_for_indexwriter_getpage
Filename:
MIME Type:
Creator:
Jason Koch
Created:
2021-04-01 00:23:14 EDT
Size:
2.71 KB
patch
obsolete
>diff --git a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java >index 21b3fb9b..8a8e6e36 100644 >--- a/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java >+++ b/plugins/org.eclipse.mat.parser/src/org/eclipse/mat/parser/index/IndexWriter.java >@@ -533,10 +533,28 @@ public abstract class IndexWriter > > public static class IntIndexCollector extends IntIndex<ArrayIntCompressed> implements IOne2OneIndex > { >+ static class IndexedThreadLocalCache<T> >+ { >+ final ThreadLocal<Integer> pageNumber = ThreadLocal.withInitial(() -> -1); >+ final ThreadLocal<SoftReference<T>> page = ThreadLocal.withInitial(() -> null); >+ >+ void set(int pageNumber, T page) >+ { >+ this.pageNumber.set(pageNumber); >+ this.page.set(new SoftReference(page)); >+ } >+ >+ T get(int pageNumber) >+ { >+ return (this.pageNumber.get() == pageNumber) ? this.page.get().get() : null; >+ } >+ } >+ > final int mostSignificantBit; > final int size; > final int pageSize = IndexWriter.PAGE_SIZE_INT; > final ConcurrentHashMap<Integer, ArrayIntCompressed> pages = new ConcurrentHashMap<Integer, ArrayIntCompressed>(); >+ final IndexedThreadLocalCache<ArrayIntCompressed> localPageCache = new IndexedThreadLocalCache<>(); > > public IntIndexCollector(int size, int mostSignificantBit) > { >@@ -546,13 +564,23 @@ public abstract class IndexWriter > > protected ArrayIntCompressed getPage(int page) > { >- ArrayIntCompressed existing = pages.get(page); >- if (existing != null) return existing; >+ ArrayIntCompressed existing = localPageCache.get(page); >+ if (existing != null) >+ return existing; >+ >+ existing = pages.get(page); >+ if (existing != null) >+ { >+ localPageCache.set(page, existing); >+ return existing; >+ } > > int ps = page < (size / pageSize) ? pageSize : size % pageSize; > ArrayIntCompressed newArray = new ArrayIntCompressed(ps, 31 - mostSignificantBit, 0); > existing = pages.putIfAbsent(page, newArray); >- return (existing != null) ? existing : newArray; >+ final ArrayIntCompressed result = (existing != null) ? existing : newArray; >+ localPageCache.set(page, result); >+ return result; > } > > public IIndexReader.IOne2OneIndex writeTo(File indexFile) throws IOException
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 570670
:
285390
|
285391
|
285392
|
285393
|
285394
|
285395
|
286012
| 286013 |
286014
|
286359
|
286512