473,799 Members | 3,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8194
_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.co m

"_DD" <_D*@nospam.com > wrote in message
news:vb******** *************** *********@4ax.c om...
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.c om> 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.c om> 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
2550
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, php is ok"; // the needles
9
32662
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 the English term for this process; itemize? tokenize? digitize? sequence?) Some examples:
7
2206
by: SIgnOff | last post by:
What the fastest way to copy strings from file to a vector in STL?
9
3718
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 the fastest or most efficient way to do this?
2
1723
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 work off and on. Sometimes the queue does not pick up a queued item until another item is queued. Can anyone see a problem with this class? *** Here's the interface and EventArgs... *** /// <summary>
5
4503
by: Tales Normando | last post by:
The title says it all. Anyone?
2
1655
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 file as it comes from a third party standard. I am planning to use the factory method to create the objects. Is there a faster way to construct this class other than the obvious solution I am presenting below class Record {
15
12315
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 performance degrade. Does anyone know any better way to archive this which just not degrade performance. The code is written in C#. Thanks
1
2938
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 what data to use (they are creating an XML document essentially on the fly). But the choice element has several possible types and so it creates this itemField as object within the xs:choice-generated class: Private itemField As Object
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10030
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.