Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - ftpwebrequest: Upload is slow...

Reply
 
Old 01-04-2009   #1 (permalink)
deostroll


 
 

ftpwebrequest: Upload is slow...

Hi,

I just tried uploading files with the ftpwebrequest class. I find that
they are really slow. However I am not sure if this is because of
me... I am writing everything to the input stream byte by byte so that
I can calculate the progress. However I only calculate only after 1024
bytes have been uploaded. Is there a better way to do this?

Moreover are there any general property settings for the object so
that ftp uploading is at least faster relatively speaking...

--deostroll

My System SpecsSystem Spec
Old 01-04-2009   #2 (permalink)
Family Tree Mike


 
 

Re: ftpwebrequest: Upload is slow...

"deostroll" <deostroll@xxxxxx> wrote in message
news:c6ffd1d7-5ba1-4435-bc66-560dbf14dd62@xxxxxx
Quote:

> Hi,
>
> I just tried uploading files with the ftpwebrequest class. I find that
> they are really slow. However I am not sure if this is because of
> me... I am writing everything to the input stream byte by byte so that
> I can calculate the progress. However I only calculate only after 1024
> bytes have been uploaded. Is there a better way to do this?
>
> Moreover are there any general property settings for the object so
> that ftp uploading is at least faster relatively speaking...
>
> --deostroll
You can still calculate progress percentage if you use large byte blocks,
such as 1024 bytes. Percentage is still bytes sent divided by total bytes.
You just incriment the bytes sent by the block size, rather than by one.
This may not be your problem as to speed, but it may help.

--
Mike

My System SpecsSystem Spec
Old 01-04-2009   #3 (permalink)
deostroll


 
 

Re: ftpwebrequest: Upload is slow...

On Jan 4, 5:20*pm, "Family Tree Mike" <F...@xxxxxx> wrote:
Quote:

> "deostroll" <deostr...@xxxxxx> wrote in message
>
> news:c6ffd1d7-5ba1-4435-bc66-560dbf14dd62@xxxxxx
>
Quote:

> > Hi,
>
Quote:

> > I just tried uploading files with the ftpwebrequest class. I find that
> > they are really slow. However I am not sure if this is because of
> > me... I am writing everything to the input stream byte by byte so that
> > I can calculate the progress. However I only calculate only after 1024
> > bytes have been uploaded. Is there a better way to do this?
>
Quote:

> > Moreover are there any general property settings for the object so
> > that ftp uploading is at least faster relatively speaking...
>
Quote:

> > --deostroll
>
> You can still calculate progress percentage if you use large byte blocks,
> such as 1024 bytes. *Percentage is still bytes sent divided by total bytes.
> You just incriment the bytes sent by the block size, rather than by one.
> This may not be your problem as to speed, but it may help.
>
> --
> Mike
I notice that the cpu usage goes to 100% while I do uploads! Is this
normal?
--deostroll
My System SpecsSystem Spec
Old 01-04-2009   #4 (permalink)
Family Tree Mike


 
 

Re: ftpwebrequest: Upload is slow...

"deostroll" <deostroll@xxxxxx> wrote in message
news:b6202b3d-5f15-4fd0-b8db-89e3f8bcac8f@xxxxxx
Quote:

>
> I notice that the cpu usage goes to 100% while I do uploads! Is this
> normal?
> --deostroll

That doesn't sound right, but it's hard to tell without seeing your code why
that might occur.

--
Mike

My System SpecsSystem Spec
Old 01-05-2009   #5 (permalink)
deostroll


 
 

Re: ftpwebrequest: Upload is slow...

On Jan 4, 9:58*pm, "Family Tree Mike" <F...@xxxxxx> wrote:
Quote:

> "deostroll" <deostr...@xxxxxx> wrote in message
>
> news:b6202b3d-5f15-4fd0-b8db-89e3f8bcac8f@xxxxxx
>
>
>
Quote:

> > I notice that the cpu usage goes to 100% while I do uploads! Is this
> > normal?
> > --deostroll
>
> That doesn't sound right, but it's hard to tell without seeing your code why
> that might occur.
>
> --
> Mike
The high CPU usage is probably high because of creating/destroying a
progressbar control. I've written a custom class for a datagridview
progressbar column. Here while "painting" it so happens that I create
a new progressbar control and draw its image in the cell meant to show
the progress updates. Probably this is why it happens...

Is it normally supposed to be slower than using ftp.exe? Why is this
so?

--deostroll
My System SpecsSystem Spec
Old 01-05-2009   #6 (permalink)
Family Tree Mike


 
 

Re: ftpwebrequest: Upload is slow...

"deostroll" wrote:
Quote:

> The high CPU usage is probably high because of creating/destroying a
> progressbar control. I've written a custom class for a datagridview
> progressbar column. Here while "painting" it so happens that I create
> a new progressbar control and draw its image in the cell meant to show
> the progress updates. Probably this is why it happens...
This "sounds" like you are creating a new progress bar in each repaint. I
hope that is not what you meant...
Quote:

>
> Is it normally supposed to be slower than using ftp.exe? Why is this
> so?
>
> --deostroll
>
I ran a few comparisons of ftp.exe versus the async upload code example at
http://msdn.microsoft.com/en-us/libr...ebrequest.aspx

It's true that the timings are somewhat slower (~40%) using the async
upload. If you are seeing times increase significantly in your code, I would
look at running your upload code in a console app to eliminate any issues
with your UI update logic.

Mike
My System SpecsSystem Spec
Old 01-06-2009   #7 (permalink)
deostroll


 
 

Re: ftpwebrequest: Upload is slow...

On Jan 5, 11:01*pm, Family Tree Mike
<FamilyTreeM...@xxxxxx> wrote:
Quote:

> "deostroll" wrote:
Quote:

> > The high CPU usage is probably high because of creating/destroying a
> > progressbar control. I've written a custom class for a datagridview
> > progressbar column. Here while "painting" it so happens that I create
> > a new progressbar control and draw its image in the cell meant to show
> > the progress updates. Probably this is why it happens...
>
> This "sounds" like you are creating a new progress bar in each repaint. *I
> hope that is not what you meant...
>
>
>
Quote:

> > Is it normally supposed to be slower than using ftp.exe? Why is this
> > so?
>
Quote:

> > --deostroll
>
> I ran a few comparisons of ftp.exe versus the async upload code example athttp://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
>
> It's true that the timings are somewhat slower (~40%) using the async
> upload. *If you are seeing times increase significantly in your code, Iwould
> look at running your upload code in a console app to eliminate any issues
> with your UI update logic.
>
> Mike
As such the ftp-ing (and other stuff) happen on a separate thread in a
synchronous manner. The UI update is asynchronous. But its not a
direct UI update. I am updating a datatable. My datagridview is bound
to the datatable. However I synchronize the updates to this table.

If I adopted the async solution how will I get the progress updates?

--deostroll
My System SpecsSystem Spec
Old 01-06-2009   #8 (permalink)
Family Tree Mike


 
 

Re: ftpwebrequest: Upload is slow...



"deostroll" wrote:
Quote:

> On Jan 5, 11:01 pm, Family Tree Mike
> <FamilyTreeM...@xxxxxx> wrote:
Quote:

> > "deostroll" wrote:
Quote:

> > > The high CPU usage is probably high because of creating/destroying a
> > > progressbar control. I've written a custom class for a datagridview
> > > progressbar column. Here while "painting" it so happens that I create
> > > a new progressbar control and draw its image in the cell meant to show
> > > the progress updates. Probably this is why it happens...
> >
> > This "sounds" like you are creating a new progress bar in each repaint. I
> > hope that is not what you meant...
> >
> >
> >
Quote:

> > > Is it normally supposed to be slower than using ftp.exe? Why is this
> > > so?
> >
Quote:

> > > --deostroll
> >
> > I ran a few comparisons of ftp.exe versus the async upload code example athttp://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
> >
> > It's true that the timings are somewhat slower (~40%) using the async
> > upload. If you are seeing times increase significantly in your code, I would
> > look at running your upload code in a console app to eliminate any issues
> > with your UI update logic.
> >
> > Mike
>
> As such the ftp-ing (and other stuff) happen on a separate thread in a
> synchronous manner. The UI update is asynchronous. But its not a
> direct UI update. I am updating a datatable. My datagridview is bound
> to the datatable. However I synchronize the updates to this table.
>
> If I adopted the async solution how will I get the progress updates?
>
> --deostroll
>
Sorry, I did not mean to imply trying the async method. I was just trying
to point out an existing example and the speed of that example relative to
ftp.exe.

If your upload times are significantly more than the ftp.exe (like a factor
of two or more), then it is likely beneficial to time your upload code
outside of any UI. If the upload code runs resonably well away from any UI,
then you've narrowed the areas you need to review in your code.

Mike

My System SpecsSystem Spec
Old 01-06-2009   #9 (permalink)
Family Tree Mike


 
 

Re: ftpwebrequest: Upload is slow...



"Family Tree Mike" wrote:
Quote:

>
>
> "deostroll" wrote:
>
Quote:

> > On Jan 5, 11:01 pm, Family Tree Mike
> > <FamilyTreeM...@xxxxxx> wrote:
Quote:

> > > "deostroll" wrote:
> > > > The high CPU usage is probably high because of creating/destroying a
> > > > progressbar control. I've written a custom class for a datagridview
> > > > progressbar column. Here while "painting" it so happens that I create
> > > > a new progressbar control and draw its image in the cell meant to show
> > > > the progress updates. Probably this is why it happens...
> > >
> > > This "sounds" like you are creating a new progress bar in each repaint. I
> > > hope that is not what you meant...
> > >
> > >
> > >
> > > > Is it normally supposed to be slower than using ftp.exe? Why is this
> > > > so?
> > >
> > > > --deostroll
> > >
> > > I ran a few comparisons of ftp.exe versus the async upload code example athttp://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
> > >
> > > It's true that the timings are somewhat slower (~40%) using the async
> > > upload. If you are seeing times increase significantly in your code, I would
> > > look at running your upload code in a console app to eliminate any issues
> > > with your UI update logic.
> > >
> > > Mike
> >
> > As such the ftp-ing (and other stuff) happen on a separate thread in a
> > synchronous manner. The UI update is asynchronous. But its not a
> > direct UI update. I am updating a datatable. My datagridview is bound
> > to the datatable. However I synchronize the updates to this table.
> >
> > If I adopted the async solution how will I get the progress updates?
> >
> > --deostroll
> >
>
> Sorry, I did not mean to imply trying the async method. I was just trying
> to point out an existing example and the speed of that example relative to
> ftp.exe.
>
> If your upload times are significantly more than the ftp.exe (like a factor
> of two or more), then it is likely beneficial to time your upload code
> outside of any UI. If the upload code runs resonably well away from any UI,
> then you've narrowed the areas you need to review in your code.
>
> Mike
>
I should have added, that if you wanted to use the code I referred to above,
you could just add a PercentComplete property to the FtpState class and
monitor that value from some other part of the code which updates the UI.

Mike


My System SpecsSystem Spec
Old 01-07-2009   #10 (permalink)
deostroll


 
 

Re: ftpwebrequest: Upload is slow...

On Jan 6, 6:26*pm, Family Tree Mike
<FamilyTreeM...@xxxxxx> wrote:
Quote:

> "Family Tree Mike" wrote:
>
Quote:

> > "deostroll" wrote:
>
Quote:
Quote:

> > > On Jan 5, 11:01 pm, Family Tree Mike
> > > <FamilyTreeM...@xxxxxx> wrote:
> > > > "deostroll" wrote:
> > > > > The high CPU usage is probably high because of creating/destroying a
> > > > > progressbar control. I've written a custom class for a datagridview
> > > > > progressbar column. Here while "painting" it so happens that I create
> > > > > a new progressbar control and draw its image in the cell meant toshow
> > > > > the progress updates. Probably this is why it happens...
>
Quote:
Quote:

> > > > This "sounds" like you are creating a new progress bar in each repaint. *I
> > > > hope that is not what you meant...
>
Quote:
Quote:

> > > > > Is it normally supposed to be slower than using ftp.exe? Why is this
> > > > > so?
>
Quote:
Quote:

> > > > > --deostroll
>
Quote:
Quote:

> > > > I ran a few comparisons of ftp.exe versus the async upload code example athttp://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
>
Quote:
Quote:

> > > > It's true that the timings are somewhat slower (~40%) using the async
> > > > upload. *If you are seeing times increase significantly in your code, I would
> > > > look at running your upload code in a console app to eliminate any issues
> > > > with your UI update logic.
>
Quote:
Quote:

> > > > Mike
>
Quote:
Quote:

> > > As such the ftp-ing (and other stuff) happen on a separate thread in a
> > > synchronous manner. The UI update is asynchronous. But its not a
> > > direct UI update. I am updating a datatable. My datagridview is bound
> > > to the datatable. However I synchronize the updates to this table.
>
Quote:
Quote:

> > > If I adopted the async solution how will I get the progress updates?
>
Quote:
Quote:

> > > --deostroll
>
Quote:

> > Sorry, I did not mean to imply trying the async method. *I was just trying
> > to point out an existing example and the speed of that example relativeto
> > ftp.exe. *
>
Quote:

> > If your upload times are significantly more than the ftp.exe (like a factor
> > of two or more), then it is likely beneficial to time your upload code
> > outside of any UI. *If the upload code runs resonably well away from any UI,
> > then you've narrowed the areas you need to review in your code.
>
Quote:

> > Mike
>
> I should have added, that if you wanted to use the code I referred to above,
> you could just add a PercentComplete property to the FtpState class and
> monitor that value from some other part of the code which updates the UI.
>
> Mike
Hi,

Is this the correct way to upload via batch?

for (i = 0; i <= TotalChunks; i += 1024)
{
//Console.WriteLine(i);
ftpStream.Write(fileContents, i, 1024);
ftpStream.Flush();
}
ftpStream.Write(fileContents, 0, fileContents.Length);
ftpStream.Flush();

----------------
Is Flush() known to cause an overhead?

--deostroll
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Slow Download & Upload Network & Sharing
Extremely Slow Upload Speed to Server 2k3 Vista networking & sharing
Slow Upload Speed Network & Sharing
SLOW UPLOAD SPEED IN VISTA? Vista General
slow upload of music to ipod Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46