user.getJoinedRooms() and room.getUserList() performance

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

JohnHacker
Posts: 12
Joined: 12 Jul 2018, 08:38

user.getJoinedRooms() and room.getUserList() performance

Postby JohnHacker » 18 Dec 2019, 15:23

Hello,

I have no real way to test it, but the tests I could do throw that these methods make a copy of the lists, so there's a lot of garbage created when calling them. It would be so great to have a way to access these methods without making in-memory copies, or at least an iterator that doesn't make a copy. There's a huge difference in performance and they are really needed for some operations.

Thank you so much!
User avatar
Lapo
Site Admin
Posts: 21647
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: user.getJoinedRooms() and room.getUserList() performance

Postby Lapo » 18 Dec 2019, 17:04

Are you talking about SmartFoxServer 2X? Because this was posted under the SFS 1.x section.

Exposing the server's internal state directly is never correct, even in the face of performance optimization which in this case would be close to insignificant. When you're copying a list you're copying references, so the load on the GC is negligible in the grand scheme of things (i.e. the rest of the server activity).

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
JohnHacker
Posts: 12
Joined: 12 Jul 2018, 08:38

Re: user.getJoinedRooms() and room.getUserList() performance

Postby JohnHacker » 18 Dec 2019, 17:59

Yes, this was for SFS 2X, I'm sorry for posting it on the wrong forum.

I am expert on optimization and this is not near close to insignificant. You can't know the cases this could be used for. That's why I wrote about the iterator, which would allow to iterate without the memory copy. I'll need to maintain my own class with lists or dictionaries to avoid the huge garbage collections this would lead to, so I asked for these methods to help other developers in the future.

Thank you for your reply!
User avatar
Lapo
Site Admin
Posts: 21647
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: user.getJoinedRooms() and room.getUserList() performance

Postby Lapo » 19 Dec 2019, 09:10

You can't know the cases this could be used for.

All I can say is this:
We have tested SmartFoxServer for over 15 years under all kinds of conditions and we have followed hundreds of large deployments of SFS2X and I can tell you that excessive garbage collection or memory pressure (due to SFS2X list copying) has never been an issue even with 100K+ connections on a single machine and traffic in the range of 10Gbp/s.

That's why I wrote about the iterator, which would allow to iterate without the memory copy.

Iterators are as problematic as exposing the data structure itself, as they are not thread safe and they allow direct manipulation of the data.

I'll need to maintain my own class with lists or dictionaries to avoid the huge garbage collections this would lead to

Do you actually have real data to back this up?
I ask because a modern JVM running on any decent hardware (e.g. a recent Intel server CPU with 4-8GB of RAM) can handle millions of reference copies without batting an eyelid. And the resulting garbage collection will not spike your CPU.

About User.getJoinedRooms(): how many Rooms do you expect your User to join at the same time? How is this possibly a problem?
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 7 guests