EstablishEncryption () Huge Memory allocations

Options
Hi,
I noticed that the first time Photon Connects, it makes couple of calls to PhotonPeer.EstablishEnryption() and everytime that call takes a lot of time and memory allocations. Is it possible to add some kind of a cache, so it does not take around 3mb+ every time Photon connects.

http://prntscr.com/8420k2

Thanks

Comments

  • kamend
    Options
    Actually the big memory allocations comes from: DiffieHellmanCryptoProvider.CalculatePublicKey(), may be you don't have to call this more than once?
  • Tobias
    Options
    3MB? It looks more like 0.6MB...

    It needs to be called once per server-switch. On NameServer, MasterServer and GameServer.
    I can take a look if we can optimize this but it's called rarely, so we didn't put stress on it.

    Did you deep profile this?
  • kamend
    Options
    Well, I am saying around 3mb, because on establishing connection and joining a room, there are around 5 calls that use BigInteger.ModPow() .

    1) http://prntscr.com/849we9
    2) http://prntscr.com/849wn6
    3) http://prntscr.com/849wu7
    4) http://prntscr.com/849wzh
    5) http://prntscr.com/849x6x


  • Tobias
    Options
    I will see if I can do something.
    In worst case, if you don't use encryption in your code, we could skip this on some servers. The client gets a Token from the servers, so it can switch between Photon instances without additional encryption...
  • Tobias
    Options
    I couldn't find a good way to pool memory in the BigInteger implementation we use.
    As said, we could possibly skip establishing encryption on some servers if this is really a problem.