Deserialization of Session Variable Really Slow

  • Thread starter Thread starter Phil Johnson
  • Start date Start date
P

Phil Johnson

Hi,

We have an asp.net web application running on .net 3.5

I have an object that we put on the session. When we get it off the session
on the next page request it takes almost 100ms to get the item and pretty
much all of that time is spent deserializing the object. Thats almost a
tenth of a second to deserialize a single object using the binary formatter.

Is there anything I should look for that could be slowing down the
deserialisation? I have seen on other forum posts that setting a double to
Double.NaN can cause an issue but we don't do that. Are there any other
Gotchas to watch out for with binary formatter deserialiation?

This didn't seem to be an issue with the application when it was running on
the .net 1.1 platform but it is now that it is running on .net 3.5... not
sure if that could have anything to do with it?
 
deserialization works by creating your object via it constructor and
setting all the properties that were saved via serialization. any
objects it references must also be created, and properties set.

check you constructor call, and any costly property sets. you should
write a unit test that performs a serialization and deserialization and
use performance tools to look for bottle necks.

-- bruce (sqlwork.com)
 
Ah,

Looking into this one a bit more it does take a similar length of time to
get the session variables, in the trace of the .net 1.1 app though it shows
in a different place... (AsyncEventExecutionStep.Execute) so the
Application_AcquireRequestState only takes .11 ms but that is because the
session variables have already been pulled from the session state db into the
local session dictionary, whereas the .net 3.5 takes 292ms in the
Appilcation_AcquireRequestState event but it is doing the work to get the
session variable from the session state DB at that point.

The extra time actually seems to be in the OnReleaseState which takes 281 ms
longer in the 3.5 app than it does in the 1.1 app (exactly the same that the
whole request is longer).

I will raise another forum post for this and see if anybody knows more about
the OnReleaseState and if we can speed that up at all.

Thanks
 
Back
Top