You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This happens each time request is received. Server may be handling hundreds of thousands of connections, with hundreds of requests coming in every second. Synthetic test with map having 100,000 UUID keys pointing to String values and 1000 containsValue calls took 4 seconds. Test with the same map and 1000 containsKey calls took only 0.1ms. This shows that containsValue method does not utilize Map's ability to quickly find an object, instead, it iterates through all the values in regular scanning loop. If we really need to check if session is still present, we need to have Set of sessions in addition to the Map, and handle them together in atomic (synchronized) way - when adding a session, add it to both Map and Set, same when removing. Then Set will be used to quickly check if the session is still active.
The text was updated successfully, but these errors were encountered:
Thank you for reaching out. I'm happy to hear that business is good.
You are right of cause, it's a waste of resources to use containsValue. Especially if the UUID is already stored in the session via the getSessionId method.
Java-OCA-OCPP/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java
Line 174 in 5c608f8
This happens each time request is received. Server may be handling hundreds of thousands of connections, with hundreds of requests coming in every second. Synthetic test with map having 100,000
UUID
keys pointing toString
values and 1000containsValue
calls took 4 seconds. Test with the same map and 1000containsKey
calls took only 0.1ms. This shows thatcontainsValue
method does not utilizeMap
's ability to quickly find an object, instead, it iterates through all the values in regular scanning loop. If we really need to check if session is still present, we need to haveSet
of sessions in addition to theMap
, and handle them together in atomic (synchronized) way - when adding a session, add it to bothMap
andSet
, same when removing. ThenSet
will be used to quickly check if the session is still active.The text was updated successfully, but these errors were encountered: