Probably, I have found the cause of the slowdown.
The real case is not the badly organized scene graph, but small amount of memory on my system. Models with about 500-1000 objects, instantiated from my PROTO's rendered in timely fashion, but when the number of objects increased, aprrox. to 1500, I ran out of available physical memory (512 Mb) and intensive swapping and (probably) garbage collection began - thus slowing the startup more than 60 times(!).
When I tried rendering the scene on a better machine, with 2 Gb RAM, it rendered in 35 seconds, when on the slower one the rendering time was 35 minutes.
So it appears that the real case is the amount of RAM, not the scene graph.
The explanation of some increase of speed then the scene is separated into some Group's is that after parsing a group some garbage collecting is performed, that clears some RAM and makes it available to render more objects without swapping memory.
According to my calculations, instancing of one PROTOtyped object takes about 256 kB RAM, this includes a 128 kB texture, and other 128 kB contain scripts and associated data - the heaviest, I suppose, are 20-30 SFStrings, which might allocate memory in quite large chunks (4 kB, probably?), also each script may create lots of garbage which can stay uncollected even after the initial rendering completes.
|
|