Comments (5)
The problem you have is you are always remobing entries from the early
segments. This means the later segments are full while the early segments
are relatively empty. Do this long enough and you keep all the keys which
happen fall in to the last segments.
You would get a similar problem with ConcurrentHashMap though it would not
be as obvious.
You can remove this issue by having only one segment so there is no
partitioning but you lose any concurrency.
On 12/06/2014 7:43 PM, "mspychalla" [email protected] wrote:
The following code reproduces an issue of the map being full despite
having 25% of its capacity still available.import java.io.File;
import java.io.IOException;
import java.util.Iterator;import net.openhft.collections.SharedHashMap;
import net.openhft.collections.SharedHashMapBuilder;public class SharedHashMapBug {
public static void main(String[] args)
{
SharedHashMap<String, byte[]> sharedHashMap = null;
Iterator it = null;int numEntries = 2048; int entrySize = 32768; int removeThreshold = (int)(numEntries * 0.75); SharedHashMapBuilder builder = new SharedHashMapBuilder(); builder.entries(numEntries); builder.entrySize(entrySize); String shmPath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "SharedHashMap"; File file = new File(shmPath); file.delete(); try { sharedHashMap = builder.create(new File(shmPath), String.class, byte[].class); } catch (IOException e) { e.printStackTrace(); } if(sharedHashMap != null) { byte[] value = new byte[30000]; int index = 0; while(index < (numEntries * 1024)) { String key = String.valueOf(index); if(sharedHashMap.longSize() > removeThreshold) { if((it == null) || (!it.hasNext())) { it = sharedHashMap.keySet().iterator(); } if(it.hasNext()) { String removalKey = it.next(); byte[] removalValue = sharedHashMap.remove(removalKey); if(removalValue == null) { System.out.println("no entry to remove for " + removalKey); } } } //System.out.println("put(" + key + ", " + value + " );"); sharedHashMap.put(key, value); ++index; } }
}
}
Here is the output when run:
Exception in thread "main" java.lang.IllegalStateException:
VanillaShortShortMultiMap is full
at
net.openhft.collections.VanillaShortShortMultiMap.nextPos(VanillaShortShortMultiMap.java:199)
at
net.openhft.collections.AbstractVanillaSharedHashMap$Segment.put(VanillaSharedHashMap.java:823)
at
net.openhft.collections.AbstractVanillaSharedHashMap.put0(VanillaSharedHashMap.java:348)
at
net.openhft.collections.AbstractVanillaSharedHashMap.put(VanillaSharedHashMap.java:330)
at SharedHashMapBug.main(SharedHashMapBug.java:62)—
Reply to this email directly or view it on GitHub
#32.
from hugecollections-old.
I would add that you can make SHM to have only one segment by this call: builder.actualSegments(1);
. I've tried to run this test with one segment, but it took really long time (I haven't waited the end).
from hugecollections-old.
Problem with one segment is, that iteration performance gets to a point where it is unusable as the iteration involves locking a full segment and captures all segment entries in an ArrayDeque.
I run into the error message by pure adding ..
from hugecollections-old.
Perhaps you could describe what you are trying to do as you shouldn't be
iterating over large collections. No matter what you do this isn't going to
be fast.
On 22/06/2014 11:28 AM, "RuedigerMoeller" [email protected] wrote:
Problem with one segment is, that iteration performance gets to a point
where it is unusable as the iteration involves locking a full segment and
captures all segment entries in an ArrayDeque.
I run into the error message by pure adding ..—
Reply to this email directly or view it on GitHub
#32 (comment)
.
from hugecollections-old.
I am evaluating the use for a distributed realtime data grid. In case data is not indexed, I need a "full table scan" initially when a new subscriber comes in (afterwards it keeps up to date by listening to change broadcasts).
With sharding to 11 nodes we currently can iterate/test 75 million records per second. We can't index everything so fallback to full scan for non-critical cases.
I got better performance now when using many segments. If one follows advice above, iteration performance becomes unusable for large tables, as creating the values() set takes several seconds if the map has 5 million entries. Configuration of SharedHashmap imo needs more documentation. As the underlying algorithms are not that easy to read from the code, it is not clear what the implications are when increasing/decreasing number of segments and changing segment size, entry size.
I initially ran into the exception above, later on I got "VanillaMultiMap is full". Now I am running with:
map = new SharedHashMapBuilder()
.entrySize(128)
.minSegments(10000)
.actualEntriesPerSegment(10*1000)
.create(new File(finam), String.class, byte[].class);
which allows me to go up to 5 million records and reasonable iteration performance (well could be better, but first I want to get things to run).
You probably burn many potential users due to lack of doc, from my experience most people give up pretty quick when they run into exceptions with some initial simple testcases (even though its just a matter of misconfiguration).
-ruediger
from hugecollections-old.
Related Issues (20)
- setSegments(int) is not public in HugeConfig; cannot be accessed from outside package HOT 3
- Comparing behaviour of HugeHashMap with HashMap HOT 2
- custom marshalling/serialization HOT 16
- remark on replication/distribution HOT 9
- how to get exactly 1 OpenHFT test to run HOT 10
- Using Shared/HugeHashMap HOT 3
- PingPong latency test across /dev/shm/SharedHashMap IPC ... HOT 19
- support for "read through" and "write behind" gettr/settrs (in addition to JBI) HOT 25
- Cache size exceed bug HOT 1
- TCPSocketReplication4WayMapTest testBufferOverflow failed (Windows 8.1) HOT 10
- Difference between setSmallEntrySize and setCapacity
- SharedHashMap: iterating using keyset, valueset is very slow for larger tables HOT 8
- problem using SharedHashMapBuilder ... HOT 6
- OpenHFT scope of capability re: SHMEntry fields (user JBI supplied) and "barrier" operations HOT 9
- HugeHashMap with JPA elements HOT 4
- SharedHashMap causing crash on Windows OS HOT 28
- Chronicle Map not thread-safe in certain circumstances HOT 14
- ChronicleMap / ChronicleMapBuilder - actualEntriesPerSegment restricted to minimum of 8 HOT 13
- too many Segment.getKey() invocations HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hugecollections-old.