Go Back   Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Java - Tuning the performance of ObjectInputStream.readObject()

 
Thread Tools Search this Thread
Old 01-06-2005, 10:03 PM   #1
Default Tuning the performance of ObjectInputStream.readObject()


I'm using JWorks, which roughly corresponds to jdk1.1.8, on my client
(VxWorks) and jdk1.4.2 on the server side (Windows, Tomcat).

I'm serializing a big vector and compressing it using GZipOutputStream
on the server side and doing the reverse on the client side to recreate
the objects.

Server side:

Vector v = new Vector(50000);//also filled with 50k different MyObject
instances
ObjectOutputStream oos = new ObjectOutputStream(new
GZipOutputStream(socket.getOutputStream()));
oos.writeObject(v);


Client side:

ObjectInputStream ois = new ObjectInputStream(new
GZipInputStream(socket.getInputStream()));
Vector v = (Vector)ois.readObject();


ObjectInputStream.readObject() at the client takes a long time (50secs)
to complete, which is understandable as the client is a PIII-700MHz and
the uncompressed vector is around 10MB. Now the problem is that because
my Java thread runs with real time priority (which is the default on
Vxworks) and deprive other threads, including non-Java ones, for this
whole 50 sec period. This causes a watchdog thread to reset the system.
I guess most of this delay is in GZipInputStream, as part of the
un-gzipping process.

My question is, is there a way to make ObjectInputStream.readObject()
or any of the other connected streams (gzip and socket) yield the CPU
to other threads once in a while? Or is there any other way to deal
with the situation?

Is the following a good solution?

class MyGZipInputStream extends GZipInputStream {
public int count = 0;

public int read(byte b[], int off, int len) throws IOException {
if(++count %10 == 0) // to avoid too many yields
Thread.yield();
return super.read(b, off,len);
}
}


Thanks
--kannan



kannan123@gmail.com
  Reply With Quote
Old 01-07-2005, 07:01 PM   #2
Harish
 
Posts: n/a
Default Re: Tuning the performance of ObjectInputStream.readObject()
the yield looks fine....
on the other hand u can decrease the priority of the thread before starting
the de-compress, and then at the end of the de-compress put back the
priority...does JWorks support changing the priority?

final int oldPriority = Thread.currentThread().getPriority();
Thread.currentThread().setPriority(Thread.MIN_PRIO RITY);
try
{
ObjectInputStream ois = new ObjectInputStream(new
GZipInputStream(socket.getInputStream()));
Vector v = (Vector)ois.readObject();
}
finally
{
Thread.currentThread().setPriority(oldPriority);
}
<> wrote in message
news: oups.com...
> I'm using JWorks, which roughly corresponds to jdk1.1.8, on my client
> (VxWorks) and jdk1.4.2 on the server side (Windows, Tomcat).
>
> I'm serializing a big vector and compressing it using GZipOutputStream
> on the server side and doing the reverse on the client side to recreate
> the objects.
>
> Server side:
>
> Vector v = new Vector(50000);//also filled with 50k different MyObject
> instances
> ObjectOutputStream oos = new ObjectOutputStream(new
> GZipOutputStream(socket.getOutputStream()));
> oos.writeObject(v);
>
>
> Client side:
>
> ObjectInputStream ois = new ObjectInputStream(new
> GZipInputStream(socket.getInputStream()));
> Vector v = (Vector)ois.readObject();
>
>
> ObjectInputStream.readObject() at the client takes a long time (50secs)
> to complete, which is understandable as the client is a PIII-700MHz and
> the uncompressed vector is around 10MB. Now the problem is that because
> my Java thread runs with real time priority (which is the default on
> Vxworks) and deprive other threads, including non-Java ones, for this
> whole 50 sec period. This causes a watchdog thread to reset the system.
> I guess most of this delay is in GZipInputStream, as part of the
> un-gzipping process.
>
> My question is, is there a way to make ObjectInputStream.readObject()
> or any of the other connected streams (gzip and socket) yield the CPU
> to other threads once in a while? Or is there any other way to deal
> with the situation?
>
> Is the following a good solution?
>
> class MyGZipInputStream extends GZipInputStream {
> public int count = 0;
>
> public int read(byte b[], int off, int len) throws IOException {
> if(++count %10 == 0) // to avoid too many yields
> Thread.yield();
> return super.read(b, off,len);
> }
> }
>
>
> Thanks
> --kannan
>





Harish
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best CPU Cooler Performance LGA1366 Q2-2009 Admin Front Page News 0 08-05-2009 04:56 PM
Performance Issue chitra_banu Software 0 06-02-2009 12:08 PM
Windows 7 Beta Performance Admin Front Page News 0 01-16-2009 02:53 PM
Does RAID0 Really Increase Disk Performance? Silverstrand Front Page News 0 11-02-2006 02:09 AM
Re: Hard drive performance question MF A+ Certification 0 12-10-2005 01:55 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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