Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28476

Re: Upload using java nio

Newsgroups comp.lang.java.programmer
Date 2014-05-14 11:38 -0700
References <459ec56a-b369-4261-b819-a4f232362f74@googlegroups.com> <lkvl26$vls$1@gregory.bnet.hr>
Message-ID <59a3228e-41fe-46bb-8f68-8d120b54b7e9@googlegroups.com> (permalink)
Subject Re: Upload using java nio
From William Lopes <williamlopes.dev@gmail.com>

Show all headers | View raw


Em quarta-feira, 14 de maio de 2014 08h46min14s UTC-3, Josip Almasi  escreveu:
> On 05/13/2014 08:37 PM, William Lopes wrote:
> 
> > Hi, I'm building a network test with source code (basically) here: http://toolongdidntread.com/android/android-multipart-post-with-progress-bar/
> 
> >
> 
> > My server contains a php script that contains just a field with name = $_FILES['uploaded_file']['name']
> 
> >
> 
> > But, this java script file isn't very good, it is using the io lib, and I want change to the nio lib, because of the perfomance.
> 
> 
> 
> I gave up nio because it introduces a number of platform specific 
> 
> troubles. 'Troubles' being both OS and JVM impl dependent.
> 
> You may get OOM with bogus description.
> 
> IBM JVM gives more precise OOM explanation, like was it ENOMEM or 
> 
> ENOBUFS, which gives you more info on how to tune OS.
> 
> 
> 
> Furthermore, there's just a few nio methods that actually utilize proper 
> 
> OS functions in order to avoid unnecessary transfer between kernel mem 
> 
> and userspace mem.
> 
> IIRC, with sun jvm on linux, I've found exactly one nio method that 
> 
> actually does the job. And apache mina did not use it:> So neither did 
> 
> software using it, many many server software.
> 
> (netty does though)
> 
> 
> 
> I have no idea how android nio works.
> 
> 
> 
> But as the man said, nio is not faster than io - it all depends on other 
> 
> threads and their synchronization.
> 
> In your case, setProgress() is blocking and synchronized.
> 
> Blocking = transfer waits for bar to render.
> 
> Synchronized = slow.
> 
> 
> 
> Recommendiation:
> 
> Make a thread to update progress bar(s). Let it have non-blocking calls 
> 
> to update volatile/atomic internal counter(s). Use these calls instead 
> 
> of setProgress(). Make it sleep for 100-1000 ms, then render bar(s).
> 
> 
> 
> Regards...

My network test is for android plataform, on my test already I modified like you said. Is a few better now, but I still wait found the answer of how use nio lib.

Thank you!

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 11:37 -0700
  Re: Upload using java nio Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 20:37 -0400
    Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 18:38 -0700
    Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 18:38 -0700
      Re: Upload using java nio Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 22:00 -0400
        Re: Upload using java nio Arne Vajhøj <arne@vajhoej.dk> - 2014-05-13 22:08 -0400
          Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-13 19:35 -0700
            Re: Upload using java nio markspace <markspace@nospam.nospam> - 2014-05-13 20:22 -0700
              Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-14 11:35 -0700
  Re: Upload using java nio Josip Almasi <joe@vrspace.org> - 2014-05-14 13:46 +0200
    Re: Upload using java nio William Lopes <williamlopes.dev@gmail.com> - 2014-05-14 11:38 -0700

csiph-web