By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

Serialization problem continues

P: n/a
Joe
I've tracked the performance issue down to a single class. This class
derives from CollectionBase and stores a basic value type such as string,
int, double, etc... I also store the type itself which you can see I'm using
when calling AddValue.

I implemented ISerializable and GeteObjectData.
Here's what I tried:

for (int i = 0; i < this.Count; i++)
info.AddValue("item" + i.ToString(), this[i], typeof(type) );

Count = ~60,000

I added some logging to see how long it takes and get some interesting
results but can't find the problem.
Using basic DateTime for start and end I check the TotalMilliseconds for
each call to AddValue and most show as 0 but ~6000 show as taking 15.625
milliseconds. The first one shows around the 15,000 item although it is not
always the same. I also write the value out to a log file and they all seem
fine.
I have a try catch but nothing seems to get thrown although I do get a flash
of my application which is typical when an exception has occurred.

Is there any further way of debugging this?

I'm desperate for help.
Thanks,
Joe
Dec 4 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Joe,

What is the total time you are seeing when it comes to serializing these
objects? 60000 objects is going to take some time, no matter how you cut it
(even if they are small). Chances are that you don't need to implement
custom serialization in this case either.

You might get some speed increase by creating a byte array to store the
information, and serializing the information yourself. However, this would
require you to keep in mind the type information, and as well as the order
that you are serializing the information in. This would allow you to not
have to store the type information for each item that is being serialized.

However, this might not be enough. The SerializationInfo instance
stores the information in a hashtable, and that hashtable expands as you add
items to it, copying the elements over when more memory is needed.

Anyways, 60000 is a large amount of objects, and you are going to have
to pay a price somewhere along the line for that.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Joe" <jb*******@noemail.noemail> wrote in message
news:OS****************@TK2MSFTNGP10.phx.gbl...
I've tracked the performance issue down to a single class. This class
derives from CollectionBase and stores a basic value type such as string,
int, double, etc... I also store the type itself which you can see I'm
using when calling AddValue.

I implemented ISerializable and GeteObjectData.
Here's what I tried:

for (int i = 0; i < this.Count; i++)
info.AddValue("item" + i.ToString(), this[i], typeof(type) );

Count = ~60,000

I added some logging to see how long it takes and get some interesting
results but can't find the problem.
Using basic DateTime for start and end I check the TotalMilliseconds for
each call to AddValue and most show as 0 but ~6000 show as taking 15.625
milliseconds. The first one shows around the 15,000 item although it is
not always the same. I also write the value out to a log file and they all
seem fine.
I have a try catch but nothing seems to get thrown although I do get a
flash of my application which is typical when an exception has occurred.

Is there any further way of debugging this?

I'm desperate for help.
Thanks,
Joe

Dec 4 '05 #2

P: n/a
Joe
Hi Nicholas,

It takes any where from 65-98 seconds to write this. There are 30 of these
that need to be written. The strangest part about this is that the entire
process on a Windows 2003 server takes about 1.5 - 2.5 seconds but on XP Pro
or Win 2k pro it takes much, much longer like up to 30+ minutes.

The machine I'm testing on now has dual Xeon 3.0 GHz with 2gig ram. One of
the servers (where it take 2 seconds) if a 1.7 GHz with 1gig ram.

I've done other testing where I create another class inherit from
CollectionBase, add 100,000 values to it and serialize it and it's done in
~1.5 seconds. For the most part it's the same class just with bogus data.

-Joe

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OW***************@TK2MSFTNGP11.phx.gbl...
Joe,

What is the total time you are seeing when it comes to serializing
these objects? 60000 objects is going to take some time, no matter how
you cut it (even if they are small). Chances are that you don't need to
implement custom serialization in this case either.

You might get some speed increase by creating a byte array to store the
information, and serializing the information yourself. However, this
would require you to keep in mind the type information, and as well as the
order that you are serializing the information in. This would allow you
to not have to store the type information for each item that is being
serialized.

However, this might not be enough. The SerializationInfo instance
stores the information in a hashtable, and that hashtable expands as you
add items to it, copying the elements over when more memory is needed.

Anyways, 60000 is a large amount of objects, and you are going to have
to pay a price somewhere along the line for that.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Joe" <jb*******@noemail.noemail> wrote in message
news:OS****************@TK2MSFTNGP10.phx.gbl...
I've tracked the performance issue down to a single class. This class
derives from CollectionBase and stores a basic value type such as string,
int, double, etc... I also store the type itself which you can see I'm
using when calling AddValue.

I implemented ISerializable and GeteObjectData.
Here's what I tried:

for (int i = 0; i < this.Count; i++)
info.AddValue("item" + i.ToString(), this[i], typeof(type) );

Count = ~60,000

I added some logging to see how long it takes and get some interesting
results but can't find the problem.
Using basic DateTime for start and end I check the TotalMilliseconds for
each call to AddValue and most show as 0 but ~6000 show as taking 15.625
milliseconds. The first one shows around the 15,000 item although it is
not always the same. I also write the value out to a log file and they
all seem fine.
I have a try catch but nothing seems to get thrown although I do get a
flash of my application which is typical when an exception has occurred.

Is there any further way of debugging this?

I'm desperate for help.
Thanks,
Joe


Dec 4 '05 #3

P: n/a
Hi Joe,

I think you can try avoid so much time of string concatenate operation like:

("item" + i.ToString(),

in the serizliation code since such operation will consume much memorty and
will hit peformance also....

as for basic types, boxing, unboxing is also time consuming, are you using
.net framework 1.1 or 2.0? Maybe the generic collection in 2.0 will be more
suitable for such collection...

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "Joe" <jb*******@noemail.noemail>
| References: <OS**************@TK2MSFTNGP10.phx.gbl>
<OW*************@TK2MSFTNGP11.phx.gbl>
| Subject: Re: Serialization problem continues
| Date: Sun, 4 Dec 2005 13:13:51 -0500
| Lines: 80
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| X-RFC2646: Format=Flowed; Response
| Message-ID: <e4**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 69.37.58.70.adsl.snet.net 69.37.58.70
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.csharp:369298
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi Nicholas,
|
| It takes any where from 65-98 seconds to write this. There are 30 of
these
| that need to be written. The strangest part about this is that the entire
| process on a Windows 2003 server takes about 1.5 - 2.5 seconds but on XP
Pro
| or Win 2k pro it takes much, much longer like up to 30+ minutes.
|
| The machine I'm testing on now has dual Xeon 3.0 GHz with 2gig ram. One
of
| the servers (where it take 2 seconds) if a 1.7 GHz with 1gig ram.
|
| I've done other testing where I create another class inherit from
| CollectionBase, add 100,000 values to it and serialize it and it's done
in
| ~1.5 seconds. For the most part it's the same class just with bogus data.
|
| -Joe
|
| "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
| message news:OW***************@TK2MSFTNGP11.phx.gbl...
| > Joe,
| >
| > What is the total time you are seeing when it comes to serializing
| > these objects? 60000 objects is going to take some time, no matter how
| > you cut it (even if they are small). Chances are that you don't need
to
| > implement custom serialization in this case either.
| >
| > You might get some speed increase by creating a byte array to store
the
| > information, and serializing the information yourself. However, this
| > would require you to keep in mind the type information, and as well as
the
| > order that you are serializing the information in. This would allow
you
| > to not have to store the type information for each item that is being
| > serialized.
| >
| > However, this might not be enough. The SerializationInfo instance
| > stores the information in a hashtable, and that hashtable expands as
you
| > add items to it, copying the elements over when more memory is needed.
| >
| > Anyways, 60000 is a large amount of objects, and you are going to
have
| > to pay a price somewhere along the line for that.
| >
| >
| > --
| > - Nicholas Paldino [.NET/C# MVP]
| > - mv*@spam.guard.caspershouse.com
| >
| >
| > "Joe" <jb*******@noemail.noemail> wrote in message
| > news:OS****************@TK2MSFTNGP10.phx.gbl...
| >> I've tracked the performance issue down to a single class. This class
| >> derives from CollectionBase and stores a basic value type such as
string,
| >> int, double, etc... I also store the type itself which you can see I'm
| >> using when calling AddValue.
| >>
| >> I implemented ISerializable and GeteObjectData.
| >> Here's what I tried:
| >>
| >> for (int i = 0; i < this.Count; i++)
| >> info.AddValue("item" + i.ToString(), this[i], typeof(type) );
| >>
| >> Count = ~60,000
| >>
| >> I added some logging to see how long it takes and get some interesting
| >> results but can't find the problem.
| >> Using basic DateTime for start and end I check the TotalMilliseconds
for
| >> each call to AddValue and most show as 0 but ~6000 show as taking
15.625
| >> milliseconds. The first one shows around the 15,000 item although it
is
| >> not always the same. I also write the value out to a log file and they
| >> all seem fine.
| >> I have a try catch but nothing seems to get thrown although I do get a
| >> flash of my application which is typical when an exception has
occurred.
| >>
| >> Is there any further way of debugging this?
| >>
| >> I'm desperate for help.
| >> Thanks,
| >> Joe
| >>
| >
| >
|
|
|

Dec 5 '05 #4

P: n/a
Joe
Hi Steven,

I'm only using the GetObjectData to try and track down the performance
issue. I tried several different types of collection classes and non seem to
improve performance at all. I'm using VS 2003 .NET 1.1. w/SP1

There is some other issue here which I can't seem to pin point. I can
serialize similar data (same and more data points) in seconds.

Based on my testing it seems there is an issue with the data itself. The
data in the classes were read in from Excel which originated in Oracle. Any
null values are being replaces with a default value such as 0 for numerical
and " " for a string.

This still doesn't explain why all Windows server machines perform the
serialization in seconds and non server takes 20+ minutes for the exact
data.

-Joe

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:7Q****************@TK2MSFTNGXA02.phx.gbl...
Hi Joe,

I think you can try avoid so much time of string concatenate operation
like:

("item" + i.ToString(),

in the serizliation code since such operation will consume much memorty
and
will hit peformance also....

as for basic types, boxing, unboxing is also time consuming, are you using
net framework 1.1 or 2.0? Maybe the generic collection in 2.0 will be more
suitable for such collection...

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "Joe" <jb*******@noemail.noemail>
| References: <OS**************@TK2MSFTNGP10.phx.gbl>
<OW*************@TK2MSFTNGP11.phx.gbl>
| Subject: Re: Serialization problem continues
| Date: Sun, 4 Dec 2005 13:13:51 -0500
| Lines: 80
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| X-RFC2646: Format=Flowed; Response
| Message-ID: <e4**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 69.37.58.70.adsl.snet.net 69.37.58.70
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.csharp:369298
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi Nicholas,
|
| It takes any where from 65-98 seconds to write this. There are 30 of
these
| that need to be written. The strangest part about this is that the
entire
| process on a Windows 2003 server takes about 1.5 - 2.5 seconds but on XP
Pro
| or Win 2k pro it takes much, much longer like up to 30+ minutes.
|
| The machine I'm testing on now has dual Xeon 3.0 GHz with 2gig ram. One
of
| the servers (where it take 2 seconds) if a 1.7 GHz with 1gig ram.
|
| I've done other testing where I create another class inherit from
| CollectionBase, add 100,000 values to it and serialize it and it's done
in
| ~1.5 seconds. For the most part it's the same class just with bogus
data.
|
| -Joe
|
| "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
| message news:OW***************@TK2MSFTNGP11.phx.gbl...
| > Joe,
| >
| > What is the total time you are seeing when it comes to serializing
| > these objects? 60000 objects is going to take some time, no matter
how
| > you cut it (even if they are small). Chances are that you don't need
to
| > implement custom serialization in this case either.
| >
| > You might get some speed increase by creating a byte array to store
the
| > information, and serializing the information yourself. However, this
| > would require you to keep in mind the type information, and as well as
the
| > order that you are serializing the information in. This would allow
you
| > to not have to store the type information for each item that is being
| > serialized.
| >
| > However, this might not be enough. The SerializationInfo instance
| > stores the information in a hashtable, and that hashtable expands as
you
| > add items to it, copying the elements over when more memory is needed.
| >
| > Anyways, 60000 is a large amount of objects, and you are going to
have
| > to pay a price somewhere along the line for that.
| >
| >
| > --
| > - Nicholas Paldino [.NET/C# MVP]
| > - mv*@spam.guard.caspershouse.com
| >
| >
| > "Joe" <jb*******@noemail.noemail> wrote in message
| > news:OS****************@TK2MSFTNGP10.phx.gbl...
| >> I've tracked the performance issue down to a single class. This class
| >> derives from CollectionBase and stores a basic value type such as
string,
| >> int, double, etc... I also store the type itself which you can see
I'm
| >> using when calling AddValue.
| >>
| >> I implemented ISerializable and GeteObjectData.
| >> Here's what I tried:
| >>
| >> for (int i = 0; i < this.Count; i++)
| >> info.AddValue("item" + i.ToString(), this[i], typeof(type) );
| >>
| >> Count = ~60,000
| >>
| >> I added some logging to see how long it takes and get some
interesting
| >> results but can't find the problem.
| >> Using basic DateTime for start and end I check the TotalMilliseconds
for
| >> each call to AddValue and most show as 0 but ~6000 show as taking
15.625
| >> milliseconds. The first one shows around the 15,000 item although it
is
| >> not always the same. I also write the value out to a log file and
they
| >> all seem fine.
| >> I have a try catch but nothing seems to get thrown although I do get
a
| >> flash of my application which is typical when an exception has
occurred.
| >>
| >> Is there any further way of debugging this?
| >>
| >> I'm desperate for help.
| >> Thanks,
| >> Joe
| >>
| >
| >
|
|
|

Dec 5 '05 #5

P: n/a
Hi Joe,

Are the machines running the same build of your test app? Also, did you
count the time that data were obtained from the server?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 7 '05 #6

P: n/a
Joe
The application is identical in version on all machines.

No need to worry about the server because the data is already in the app. I
mentioned where it originated from just in case someone had a problem with a
data type.

I can deserialize the data into the application which is very fast. Now when
I try to serialize it I get the massive delay. This delay happens any time I
serilizae the data whether it's newly imported or deserialized.

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:UW****************@TK2MSFTNGXA02.phx.gbl...
Hi Joe,

Are the machines running the same build of your test app? Also, did you
count the time that data were obtained from the server?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 7 '05 #7

P: n/a
Hi Joe,

I don't have enough resource to reproduce this issue on my machine. In this
case, I suggest you try to contact Microsoft PSS. You can find their
contact information from the following link:

http://support.microsoft.com/default...;OfferProPhone

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 9 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.