473,408 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Fastest possible serialization

_DD
I had one experimented with binary serialization of an ArrayList of
structs (each struct mostly contains strings). Strangely enough, it
did not run as fast as custom XML storage (latter was nothing fancy,
but did not use normal serialization). I was not pressed to get
runtime optimized at the time, so I just went with XML.

The situation has shifted, and I have to figure out the *fastest
possible* way to save and reload that ArrayList. I remember seeing
something on optimizing serialization but could not locate it. Are
there recommended approaches? (again with speed as the major concern)
May 10 '06 #1
3 8171
_DD,

The fastest possible serialization will be from creating a custom
routine which will write binary representations of the field values to a
stream. You will have to code the routines for each type, as you will face
an overhead if you use reflection. This is what serialization "suffers"
from now.

Not that I have a problem with optimizations, but you have weigh the
benefits of these optimizations. You will have to add code to every type
every time you add a field.

What are your performance goals? Going for "as fast as possible" isn't
really a good performance goal. Rather, you should have a benchmark and try
and hit that. You might find other areas of the application where you can
make optimizations which would not be do broad (you are talking about a
custom solution which requires implementation of every type that
participates in it, which can be a maintinence nightmare, to say the least)
and help you hit your performance goals.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"_DD" <_D*@nospam.com> wrote in message
news:vb********************************@4ax.com...
I had one experimented with binary serialization of an ArrayList of
structs (each struct mostly contains strings). Strangely enough, it
did not run as fast as custom XML storage (latter was nothing fancy,
but did not use normal serialization). I was not pressed to get
runtime optimized at the time, so I just went with XML.

The situation has shifted, and I have to figure out the *fastest
possible* way to save and reload that ArrayList. I remember seeing
something on optimizing serialization but could not locate it. Are
there recommended approaches? (again with speed as the major concern)

May 10 '06 #2
_DD
On Mon, 8 May 2006 23:29:41 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
The fastest possible serialization will be from creating a custom
routine which will write binary representations of the field values to a
stream. You will have to code the routines for each type, as you will face
an overhead if you use reflection. This is what serialization "suffers"
from now.
The first method was pretty much by the book, but I may have missed
something. It took about twice as long as parsing the equivalent XML
file.

Do you have a feel for how much of a performance hit is imposed by
reflection? I thought that serialization could be fairly fast,
especially compared to verbose XML. That was a shock.
Not that I have a problem with optimizations, but you have weigh the
benefits of these optimizations. You will have to add code to every type
every time you add a field. What are your performance goals? Going for "as fast as possible" isn't
really a good performance goal. Rather, you should have a benchmark and try
and hit that.
If there was a spec for this particular function, it would be: "Fast
as hell" <g> Seriously, it is one of those things that will end up
'inline' with user interaction, and the most entertaining progress bar
in the world will not help. I'm clocking 2 minutes + loading the XML
file. Serialization took over 4 minutes.

Given the user 'eye-glaze' factor, I'd love to load the file in 15
seconds. I didn't think that would be out of the question. The
largest file is 60 megabytes, which can be drag-drop copied in about 5
seconds.
Hope this helps.


Always, Nicholas!
May 10 '06 #3
_DD
On Mon, 8 May 2006 23:29:41 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
The fastest possible serialization will be from creating a custom
routine which will write binary representations of the field values to a
stream. You will have to code the routines for each type, as you will face
an overhead if you use reflection. This is what serialization "suffers"
from now.


PS: Aren't there some tricks in regard to getting normal
serialization to run faster?
May 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Simon | last post by:
Hi, If I have a string, (variable len), and I am looking for the first position of one char in array starting from position 'x' For example, // the 'haystack' $string = "PHP is great,...
9
by: Rune Strand | last post by:
Hi, If I have a lot of integers and want do something with each digit as integer, what is the fastest way to get there? Eg. Make 12345 into an iterable object, like or "12345" (Btw: What is...
7
by: SIgnOff | last post by:
What the fastest way to copy strings from file to a vector in STL?
9
by: Jiho Han | last post by:
Suppose I have an xml fragment like: <mother> <child name="Bob" sex="M"/> <child name="Jane" sex="F"/> ... </mother> If I wanted to replace the <mother> element to <father> element, what is...
2
by: Nicholas | last post by:
I have this class that provides a disk-based queue for storing various items. As items are queued the event delegate is called and the consumer dequeues the object and processes it. This seems to...
5
by: Tales Normando | last post by:
The title says it all. Anyone?
2
by: Ninan | last post by:
I have different 256 character length records stored in a file. The first character is the record identifier. I want to instantiate different record objects. I cannot change the records stored in...
15
by: Buddy Home | last post by:
Hello, I'm trying to speed up a piece of code that is causing performance issues with our product. The problem is we are using serialization to convert the object to a string, this is costing us...
1
by: =?Utf-8?B?R292ZXJubWVudE1hbg==?= | last post by:
Hi, I am using Reflection to build a GUI based on a class create with XSD, in VB ..NET 2.0. For most elements, I can easily determine the Type and then provide the user some controls to select...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.