Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Performance / July 2005

Tip: Looking for answers? Try searching our database.

GC/Multi-threaded apps/byte stream conversion?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark - 25 Jul 2005 17:16 GMT
Hi...

I've got a console app that fetches, reads, and processes text files and
I've been trying to profile it to improve performance.  Based on its
configuration file, it supports multithreading with a ThreadPool.

I've tried profiling with Compuware's Devpartner Studio, but I find the
debugger gets in the way too much; it induces about 100x overhead and only
accounts for about 70x of it, so you find the results skewed pretty badly by
frequently executed lines.  Plus, with multiprocessors sometimes it just
flakes out.

I've been demoing ANT and it's been a great help.  I've also been using some
of the perfmon tips and tricks.

The nub of what I've found out is that the performance characteristics
between running single threaded and multi-threaded are pretty radically
different, and the major part of the difference comes in GC handling.  Single
threaded, it runs at about 4-7% of the time in GC.  Running with 5 threads,
it's between 45-90% of the time in GC.

My guess is that so much of the GC action is from the strings created by
stream reading.  I've been trying to cut down on all of the extra string
creation from String.Split() and redundant Substring calls and I've gotten a
lot of them out but it's a little trickier with the strings from I/O.

I've created a subroutine to effectively find the lines in a Byte [] (to
replace .ReadLine()), but getting from a subsection in a byte array to make
string of the parts I want seems a bit trickier.  HttpUtility.UrlDecode()
supports subsection from bytes to string, but StringBuilder doesn't.  Do I
have to write my own utility routines to cast up each Byte to Char or
StringBuilder.Append each byte individually?

Any suggestions from others would be appreciated...

Thanks
_mark
David Browne - 25 Jul 2005 18:06 GMT
> Hi...
>
[quoted text clipped - 36 lines]
>
> Any suggestions from others would be appreciated...

Due to the immutable nature of strings, this will always require some
copying.  But you can minimize it by using a single char[] and using
System.Text.Encoding.GetChars(byte[],pos,len,char[],pos) to decode a range
of bytes from the byte[] into a char[].  From the char[] a copy is required
to get the chars into a string.  You can use either the String(char[])
constructor, or StringBuilder.Append(char[]).  Both make a copy of the
char[].

David

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.