Performance FAQ

This is the place to read announcements, talk about Paint3D, ask for help and help others.

Performance FAQ

Postby Atomic on Mon Jan 11, 2010 11:48 am

Questions about Paint3D's performance pop up often so I decided to create this FAQ. If anything isn't clear or you have any question that hasn't been answered here please reply and I'll add it.

I tried to provide a short and direct answer to every question and for technically inclined users I've followed with a more detailed explanation for each group of questions.


Paint3D runs very slowly, what can I do about it?

If you're running in full screen or a big window try running in a smaller window or enabling subsampling (View/Options/View Mode and Edit Mode/Subsampling) - increase the value until you find a good balance between speed and image quality.

You can also enable Optimize (the option just below Subsampling) - this will disable some features but might improve speed, specially on older hardware.

Why does it get slower when I zoom in?

Because a larger portion of the screen actually "sees" the image. This is normal and it may cease to get slower when every single pixel of the screen "sees" the image.

Isn't the new renderer supposed to be faster than the old one? It seems slower here!

It scales better with volume size and smoothing (a big smoothed image will probably run faster) and memory use will be smaller but it scales worse with resolution (a small image running in full screen with a big resolution will probably run slower). This seemed like a future-proof choice because the new renderer can take advantage of multicore and 64-bit and screen resolutions seem to increase slower than overall computing power.

The new renderer is also more portable, can run on older hardware and has options to increase performance at the cost of image quality.

Why's Paint3D using almost 100% of my CPU while running?

The renderer tries to use as much CPU power as it can to render faster. I might include a way to limit FPS on a future version to address this.

Technical notes about performance on the new renderer

The new renderer is a raycaster that runs 100% in software. It casts a ray for each pixel on the screen and those rays travel until they find a voxel - this is why higher resolutions suffer a performance loss. Subsampling tells the raycaster to render a smaller image and stretch it to fill the window - with 2x2 each rendered pixel is stretched to fill an area of 2x2 screen pixels and so on.

Only rays that intersect the image have to traverse the image, when zoomed out more pixels are unused and perfomance gets better.

In addition, rays that collide faster have to travel less and render faster than rays that have to travel more. That's why an empty image is generally slower to render than a full one. Using the first person camera is also faster because the camera is nearer to the voxels and the rays travel less.

A positive side-effect of raycasting is that only voxels that are visible are actually rendered and that makes it scale better with volume size than using a traditional polygon approach. Smoothing is only computed for visible solid voxels and is considerably faster than on the old renderer.


Why does Paint3D hang when running some scripts?

Scripts are slow due to the interpreted nature of Python and Paint3D may stop responding while running them, specially on big images - this does not mean the program has crashed (altough it can crash due to poorly written scripts), it may just take some time to resume normal execution. You can make scripts execute faster by compiling your code to a .NET dll and using the script to call a function on the dll.

A "Paint3D ran out of memory and must close." message popped up, why?

You're probably working with a bigger volume than .NET or your OS can handle, try working with smaller volumes. 64-bit OS's can handle bigger volumes than 32-bit ones so you might want to consider upgrading your OS. Even on 64-bit OS's the .NET Framework imposes a limit of 1024x1024x512 (or any other size that has the same product).

Lowering your undo limit or even disabling undo completely might help (View/Options/General/Undo Limit). If you're just viewing (as opposed to editing) a very large image you may want to set your default tool (View/Options/General/Default Tool) to None and restart the program.

When this crash happens Paint3D can try to save your work but it may fail due to lack of memory. There's no way to "fix" this.

A "System.OutOfMemoryException" popped up, why?

That happens because sometimes there`s no memory left to pop up the message above and try to save your work. Unfortunately there is nothing that can be done about this. See the question above to learn what you can do to avoid this problem.

Sometimes Paint3D slows down and I can hear my hard drive hard at work, why?

This happens when your OS starts paging intensively to allow programs to use more memory than your physical RAM. It can happen to any program, specially on 64-bit OS's because programs are allowed to use more memory. It might be more noticeable in Paint3D because it deals with volumes - opening a 256x1024x1024 volume is similar to loading 256 pictures of 1 megapixel in memory at the same time.

You can try to reduce memory usage (see above) or get more RAM (consult the maximum supported by your OS before upgrading).

Technical notes about memory usage

32-bit OS's generally have a limit of 4GB of physical RAM and a 2GB limit per process and won't allow a process to use more than that even if physical memory is available. More detailed explanations about limits in Windows can be found here (this link also has a workaround to increase the per process limit to 3GB).

In practice there are further complications because the 2GB limit is "seen" as a contiguous block of memory and even when it has the total free space to allocate an image it may not be able to do so because it's fragmented in small portions - that kind of stuff is controlled by the .NET Framework and there is little I can do to change it. This problem is mitigated by 64-bit OS's because each process has a much larger address space available.

Even on 64-bit OS's the .NET Framework limits arrays to 2GB. Each voxel uses up 4 bytes (32-bit color) so a 1024x1024x512 or equivalent volume hits that limit - that's currently the hard limit for image size in Paint3D. I could split the array to work around this limit but it's so slow at those sizes that I don't think it's worth the trouble, at least for now.

I have a couple of ideas to reduce memory reallocations (specially when showing tool previews - that's why setting the default tool to none is indicated when viewing a large image) but those need further testing.


Wouldn't Paint3D be faster if it used my top-notch graphics card?

Graphics cards are made to render triangles very fast, which gives an advantage to traditional 3D meshes. That said, I still think the new renderer offers more advantages than the old one.

On the other hand I could use GPGPU to speed Paint3D up but that's a massive amount of work and I'm not willing to do it unless GPGPU support is more widespread and less buggy - using CUDA would considerably limit the amount of compatible computers and enormously increase the complexity of the renderer. I might reconsider this one if a better technology comes up.

What else are you planning to do to improve the performance of Paint3D?

The short answer is that performance is currently the main issue of Paint3D and I'm constantly making small improvements to increase it slightly. A huge improvement may eventually happen but not in the near future.

A way to considerably improve performance and memory usage is to stop using a 3D matrix and use a structure that is compressed in memory using RLE or an octree. The RLE approach is *very* fast but too complicated and limiting. The octree approach is what I'd go with if I started coding Paint3D today but it's a lot of work to change it (it would require a complete rewrite of the renderer and lots of small changes to the rest of the code) and it would also make future features harder to implement - it's something I'd like to do eventually but don't hold your breath.
User avatar
Atomic
Paint3D Developer
 
Posts: 119
Joined: Tue Aug 25, 2009 12:47 pm

Re: Performance FAQ

Postby jounihat on Sat Apr 24, 2010 8:40 pm

I'm happy to see there are quite many people interested in voxel rendering methods! However, it seems that making a voxel renderer for big model resolutions always requires some sort of cheating. I think Ken's RLE-based VoxLap is the most impressive I've seen so far, but as you said, it has some limitations. I've been trying to do something that would be called a quick marching cubes algorithm, but after some developing I felt like I'm not really in the voxel business anymore. Voxel graphics have this unique "hand-drawn" look, and using polygons to display voxels is just wrong. Oh well, maybe we have to wait until Sony releases PS4 with new Cell processor and 16GB of RAM :-P

I still think that voxels are the only real way of displaying 3D graphics.

EDIT: I also think that ray-tracing is the way to go for the future.
jounihat
 
Posts: 1
Joined: Sat Apr 24, 2010 8:25 pm

Re: Performance FAQ

Postby Atomic on Sun Apr 25, 2010 4:20 pm

Voxlap and 3D Coat are the fastest voxel renderers out there AFAIK. Voxlap is a great feat of engineering indeed! I think 3D Coat uses the marching cubes algorithm but I'm not sure (it also uses density voxels instead of binary ones to achieve more smooth results).

I certainly hope hi-res real time voxel ray tracers will become viable soon!
User avatar
Atomic
Paint3D Developer
 
Posts: 119
Joined: Tue Aug 25, 2009 12:47 pm

Re: Performance FAQ

Postby Atomic on Wed May 05, 2010 3:11 pm

Good news - I'm working on optimizing the renderer! I can't give any numbers for now but it's looking good so far.
User avatar
Atomic
Paint3D Developer
 
Posts: 119
Joined: Tue Aug 25, 2009 12:47 pm

Re: Performance FAQ

Postby Shadaez on Mon May 10, 2010 10:20 pm

That's great! I still use P3D and check on the forums every few days. Stay motivated!
Shadaez
 
Posts: 22
Joined: Mon Apr 05, 2010 6:56 am

Re: Performance FAQ

Postby NeatNit on Sun Aug 22, 2010 9:24 pm

A quick search in the app store brought this up: http://www.flatblackfilms.com/iphone/Voxel/Voxel.html

Obviously this was designed for touch controls, and for much smaller images. However, I have tried and could not get it to even slow down on my iPod 2nd gen.

The reason I say this is because my tiny handheld device seems more stable than Paint3D, which is prone to slowdowns.

I understand that the main reason is the raytracing rendering, but since obviously this app manages a high, constant framerate, I'm starting to think there's a better way to render.
Of course, it could be that I didn't add that many voxels in the app - only put them far apart in order to make the total size of the image bigger. That could be why.
User avatar
NeatNit
 
Posts: 69
Joined: Thu Dec 24, 2009 11:26 am

Re: Performance FAQ

Postby Atomic on Mon Aug 23, 2010 12:34 pm

The first version of Paint3D used a traditional renderer and could render small images like those in real time without any slowdown.

The problem is that their rendering speed scales with the cube of the size, so if you double all your dimensions you get 8x slower. That puts a usability limit at around 128^3 that would be *very* hard to break with a traditional renderer. In fact I doubt you could even get to 64^3 on the iPhone without a serious slowdown (note that they might be rendering by matrix or by voxel - by matrix slows down with empty voxels but has lower overhead on a reasonably filled image).

I suppose the best alternative would be to switch algorithms awhen the image starts to get big but that means doubling all the rendering code, which isn't something I'm willing to do (not with the amount of sales I get, anyways).
User avatar
Atomic
Paint3D Developer
 
Posts: 119
Joined: Tue Aug 25, 2009 12:47 pm

Re: Performance FAQ

Postby NeatNit on Wed Aug 25, 2010 6:37 pm

Looks like I was mistaken...

I made this:
Image

And apparently:
Image

Felt better than that.

Nevermind then!
User avatar
NeatNit
 
Posts: 69
Joined: Thu Dec 24, 2009 11:26 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron