Fast collections and Java collections
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
-
- Posts: 29
- Joined: Sun Nov 30, 2008 2:01 am
Fast collections and Java collections
Hello!
I've seen discussions about Javolution being overused in the project and I'd like to have some more info about this.
In which situations javolution collections are more suitable and which not?
Also, what's the difference between using it in shared mode and using Concurrent java colletions?
Thank you
I've seen discussions about Javolution being overused in the project and I'd like to have some more info about this.
In which situations javolution collections are more suitable and which not?
Also, what's the difference between using it in shared mode and using Concurrent java colletions?
Thank you
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
Re: Fast collections and Java collections
One of differences is that FastMap keeps its elements sorted by the way you've stored them, but ConcurrentHashMap doesn't it keeps them randomly sorted.
Also we are replacing javolution at the places that we can use native java concurrent collections.
Also we are replacing javolution at the places that we can use native java concurrent collections.
-
- Posts: 29
- Joined: Sun Nov 30, 2008 2:01 am
Re: Fast collections and Java collections
Thanks for the reply.UnAfraid wrote: Also we are replacing javolution at the places that we can use native java concurrent collections.
But what's the criteria for this replacement?
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
Re: Fast collections and Java collections
Most of FastMaps can be safely replaced with ConcurrentHashMap (Of course where sorting doesn't matters) but some FastLists cannot be replaced with CopyOnWriteArrayList for example due to some issues for example i've replaced the lists in Olympiad that holds participants and i end up into a problem having players 'unregistered' but they wasn't or player registered into few fights at the same time and stuff like that.KaL wrote:Thanks for the reply.UnAfraid wrote: Also we are replacing javolution at the places that we can use native java concurrent collections.
But what's the criteria for this replacement?
- jurchiks
- Posts: 6769
- Joined: Sat Sep 19, 2009 4:16 pm
- Location: Eastern Europe
Re: Fast collections and Java collections
That's not really a proper answer to his question...
I'm pretty sure he meant why do you choose to replace x with y, based on what criteria? Is it actually better in that specific scenario or you just like it that way?
I'm pretty sure he meant why do you choose to replace x with y, based on what criteria? Is it actually better in that specific scenario or you just like it that way?
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
-
- Posts: 29
- Joined: Sun Nov 30, 2008 2:01 am
Re: Fast collections and Java collections
I see, thank youUnAfraid wrote:Most of FastMaps can be safely replaced with ConcurrentHashMap (Of course where sorting doesn't matters) but some FastLists cannot be replaced with CopyOnWriteArrayList for example due to some issues for example i've replaced the lists in Olympiad that holds participants and i end up into a problem having players 'unregistered' but they wasn't or player registered into few fights at the same time and stuff like that.KaL wrote:Thanks for the reply.UnAfraid wrote: Also we are replacing javolution at the places that we can use native java concurrent collections.
But what's the criteria for this replacement?
Actually yes, I'd like to know better the cases I should choose between javolution and java librariesjurchiks wrote:I'm pretty sure he meant why do you choose to replace x with y, based on what criteria? Is it actually better in that specific scenario or you just like it that way?
-
- Posts: 257
- Joined: Thu Dec 16, 2010 5:16 am
Re: Fast collections and Java collections
I'd also like to know why one should use java-native maps and lists. Javolution suggests on their page, that their maps and lists are better and faster (at least in those cases they offer). So I'd also like to know why and when one should prefer one over the other.
Thanks in advance.
Thanks in advance.
I don't mind helping - however: I only do so if I want to.
No support for other server packs than L2J.
- Zoey76
- L2j Inner Circle
- Posts: 7005
- Joined: Tue Aug 11, 2009 3:36 am
Re: Fast collections and Java collections
If I made a collection API, I'd like to believe it's better than what I'm leaving behindHyrelius wrote:I'd also like to know why one should use java-native maps and lists. Javolution suggests on their page, that their maps and lists are better and faster (at least in those cases they offer). So I'd also like to know why and when one should prefer one over the other.
Thanks in advance.
Powered by Eclipse 4.30 | Eclipse Temurin 21 | MariaDB 11.3.2 | L2J Server 2.6.3.0 - High Five
Join our Discord!
Join our Discord!
-
- L2j Veteran
- Posts: 1228
- Joined: Thu Jan 17, 2013 9:46 am
Re: Fast collections and Java collections
Fast collections can be both concurrent and thread safe. While Java collections only have concurrent safety.
- Zoey76
- L2j Inner Circle
- Posts: 7005
- Joined: Tue Aug 11, 2009 3:36 am
Re: Fast collections and Java collections
Please read the javadocs at oraclexban1x wrote:Fast collections can be both concurrent and thread safe. While Java collections only have concurrent safety.
Powered by Eclipse 4.30 | Eclipse Temurin 21 | MariaDB 11.3.2 | L2J Server 2.6.3.0 - High Five
Join our Discord!
Join our Discord!
- jurchiks
- Posts: 6769
- Joined: Sat Sep 19, 2009 4:16 pm
- Location: Eastern Europe
Re: Fast collections and Java collections
You don't think they have made tests to prove their code is faster?Zoey76 wrote:If I made a collection API, I'd like to believe it's better than what I'm leaving behind
Everyone knows that the Java collections are for general use, they're all-rounders, not particularly good at anything, but not all that bad either, while libraries like Javolution and Trove specialize and excel at something in particular (storing time or retrieval time, among other things).
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
- Zoey76
- L2j Inner Circle
- Posts: 7005
- Joined: Tue Aug 11, 2009 3:36 am
Re: Fast collections and Java collections
To properly answer the OP question, one must sit and review the source code from Javolution (included in our source) and the source code of Java itself (included in any JDK).
ConcurrentHashMap, one of many concurrent and thread-safe implementations, has been completely rewritten in Java 8 to increase performance.
Added some reference documetnation.
I'll elaborate this post later, I have to go now.
ConcurrentHashMap, one of many concurrent and thread-safe implementations, has been completely rewritten in Java 8 to increase performance.
Added some reference documetnation.
I'll elaborate this post later, I have to go now.
Powered by Eclipse 4.30 | Eclipse Temurin 21 | MariaDB 11.3.2 | L2J Server 2.6.3.0 - High Five
Join our Discord!
Join our Discord!
- jurchiks
- Posts: 6769
- Joined: Sat Sep 19, 2009 4:16 pm
- Location: Eastern Europe
Re: Fast collections and Java collections
Still, there is bound to be some custom collection that is faster than the built-in one.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
-
- Posts: 257
- Joined: Thu Dec 16, 2010 5:16 am
Re: Fast collections and Java collections
This brings me back to the question: how do I decide what to use ?
I don't mind helping - however: I only do so if I want to.
No support for other server packs than L2J.