Fast collections and Java collections

If something doesn't fit in any other forum then post it here.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
KaL
Posts: 29
Joined: Sun Nov 30, 2008 2:01 am

Fast collections and Java collections

Post by KaL »

Hello!

I've seen discussions about Javolution being overused in the project and I'd like to have some more info about this. :roll:

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 :)
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: Fast collections and Java collections

Post by UnAfraid »

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.
Image
KaL
Posts: 29
Joined: Sun Nov 30, 2008 2:01 am

Re: Fast collections and Java collections

Post by KaL »

UnAfraid wrote: Also we are replacing javolution at the places that we can use native java concurrent collections.
Thanks for the reply. :wink:
But what's the criteria for this replacement?
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: Fast collections and Java collections

Post by UnAfraid »

KaL wrote:
UnAfraid wrote: Also we are replacing javolution at the places that we can use native java concurrent collections.
Thanks for the reply. :wink:
But what's the criteria for this replacement?
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.
Image
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Fast collections and Java collections

Post by jurchiks »

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?
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.
KaL
Posts: 29
Joined: Sun Nov 30, 2008 2:01 am

Re: Fast collections and Java collections

Post by KaL »

UnAfraid wrote:
KaL wrote:
UnAfraid wrote: Also we are replacing javolution at the places that we can use native java concurrent collections.
Thanks for the reply. :wink:
But what's the criteria for this replacement?
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.
I see, thank you :)
jurchiks 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?
Actually yes, I'd like to know better the cases I should choose between javolution and java libraries :roll:
Hyrelius
Posts: 257
Joined: Thu Dec 16, 2010 5:16 am

Re: Fast collections and Java collections

Post by Hyrelius »

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.
Image
I don't mind helping - however: I only do so if I want to.
No support for other server packs than L2J.
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7005
Joined: Tue Aug 11, 2009 3:36 am

Re: Fast collections and Java collections

Post by Zoey76 »

Hyrelius 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.
If I made a collection API, I'd like to believe it's better than what I'm leaving behind :D
Powered by Eclipse 4.30 ๐ŸŒŒ | Eclipse Temurin 21 โ˜• | MariaDB 11.3.2 ๐Ÿ—ƒ๏ธ | L2J Server 2.6.3.0 - High Five ๐Ÿš€

๐Ÿ”— Join our Discord! ๐ŸŽฎ๐Ÿ’ฌ
xban1x
L2j Veteran
L2j Veteran
Posts: 1228
Joined: Thu Jan 17, 2013 9:46 am

Re: Fast collections and Java collections

Post by xban1x »

Fast collections can be both concurrent and thread safe. While Java collections only have concurrent safety.
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7005
Joined: Tue Aug 11, 2009 3:36 am

Re: Fast collections and Java collections

Post by Zoey76 »

xban1x wrote:Fast collections can be both concurrent and thread safe. While Java collections only have concurrent safety.
Please read the javadocs at oracle :P
Powered by Eclipse 4.30 ๐ŸŒŒ | Eclipse Temurin 21 โ˜• | MariaDB 11.3.2 ๐Ÿ—ƒ๏ธ | L2J Server 2.6.3.0 - High Five ๐Ÿš€

๐Ÿ”— Join our Discord! ๐ŸŽฎ๐Ÿ’ฌ
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Fast collections and Java collections

Post by jurchiks »

Zoey76 wrote:If I made a collection API, I'd like to believe it's better than what I'm leaving behind :D
You don't think they have made tests to prove their code is faster?
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.
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7005
Joined: Tue Aug 11, 2009 3:36 am

Re: Fast collections and Java collections

Post by Zoey76 »

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.
Powered by Eclipse 4.30 ๐ŸŒŒ | Eclipse Temurin 21 โ˜• | MariaDB 11.3.2 ๐Ÿ—ƒ๏ธ | L2J Server 2.6.3.0 - High Five ๐Ÿš€

๐Ÿ”— Join our Discord! ๐ŸŽฎ๐Ÿ’ฌ
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Fast collections and Java collections

Post by jurchiks »

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.
Hyrelius
Posts: 257
Joined: Thu Dec 16, 2010 5:16 am

Re: Fast collections and Java collections

Post by Hyrelius »

This brings me back to the question: how do I decide what to use :x?
Image
I don't mind helping - however: I only do so if I want to.
No support for other server packs than L2J.
Post Reply