Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  File IO blocks rendering  (Read 2170 times)
0 Members and 1 Guest are viewing this topic.
Offline Mezzerman

Junior Newbie





« Posted 2007-08-10 10:37:02 »

Hi,

I am experiencing a strange behaviour which I was wondering if anybody knows about. When I read from a BufferedReader in a separate Thread, the rendering speed goes noticeable down. Actually rendering seems to block. I was tracking it down to peaks in:

- LoaderThread: calls to .readLine
- RenderThread: calls to glVertex3f

Does anybody know about this behaviour and what would be the solution? Might using Vertex Arrays help or does the bus block on Java File IO in general?

Thanks alot!
Mezzerman.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 802
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2007-08-10 10:56:28 »

Even if it would block the bus, file-I/O is normally so slow that it should have any impact.

Maybe you're using synchronized-blocks/methods.

Are you creating a new Thread everytime you do File I/O? Thread-construction is a very heavy operation.

What are you doing with the results obtained from readLine, any processing?

Last thing I can come up with is that you're creating lots of garbage while doing I/O, and the GC starts to kick in full-sweeps very often, if the Heap is already nearly (>95%) full.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Mezzerman

Junior Newbie





« Reply #2 - Posted 2007-08-10 11:16:58 »

Thanks for the quick reply!!!

The FileIO-Thread is obtained from a ThreadPool using java.util.concurrent. I can increase the speed by omitting the readLine method call and can reproduce the blocking effect by just calling readLine w/o any processing of the data.

First of all I was thinking about a synchronization problem in my code but it seems that file io blocks calls to glVertex3f. Unfortunately, rising the thread priority of the renderthread does not help eighter.

The GarbageCollection may be a point though! Can I alter the gc strategy in some way?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 802
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2007-08-10 11:39:48 »

run java.exe with -verbose:gc as an additional argument, to see when the GC occurs, and how long each collection takes.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Mezzerman

Junior Newbie





« Reply #4 - Posted 2007-08-10 12:32:56 »

Good tip!

GC takes about 1-2ms, no particular peaks occured.

I have measured the render time also (just a for-loop sending glVertex3f in selection mode, code below), which has peaks up to 63ms when reading from a file. Usually it is < 10ms.

        // draw faces by hand
        for (int i = 0; i < faces_vertices.length; i++)
        {
            // draw polygon
            gl.glBegin(GL.GL_POLYGON);
            for (int j = 0; j < faces_vertices.length; j++)
            {
                // add vertex
                Vector3DVO vec = vertices[faces_vertices[j]];
                gl.glVertex3f(vec.x, vec.z, -vec.y);
            }
            gl.glEnd();
        }

It is rendering aprox. 600 faces w/3-4 vertices each face. Drawing in immediate mode can be optimized a lot. But I am thinking that this problem will occure then too (slightly better performance but still blocking when doing file io I think).
Offline broumbroum

Junior Member





« Reply #5 - Posted 2007-08-10 23:12:22 »

Did you try with the NIO classes? RandomAccessFile's are far smoother to get up vs File's, I mean they have their own ByteBuffer which does avoid to build extra BufferedStreams.
Plus, did you check for the priority of both Threads loader and render? I always set them to the Max_priority which does improve speed for about the double, because of the GC'ing running at a normal level that can interfer with new Threads instances.
Where RAM data reading can be fail-fast if the heap memory is overflowed, File IO must improve speed to the Bus speed which can vary from 9ms (that is common HDD r/w speeds) to even faster rates, depending on the architecture used for testing.

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline gouessej
« Reply #6 - Posted 2007-08-28 18:29:06 »

Maybe you could use FileChannel.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (28 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!