# Application Design

The following table summarizes application design characteristics that may produce faster runtime performance. Application design choices that improve performance typically have minimal impact on the behavior of the system.

Design pattern | Why it's faster | Best value option | Watch out for...
--- | --- | --- | ---
Use a small number of tools per stream. | The processing time for a single ViDi tool does not vary significantly based on the amount of information that the tool returns. For example, a single Blue tool that is trained to find 100 different features runs at the same speed as a tool that is trained to find only a single feature. Further, the number of features returned makes only a minimal speed difference. Similarly, a Red tool runs at the same speed regardless of how many defects it finds, and a Green tool can classify into 2 classes or 2000 classes at the same speed. | Start building your application with a single tool. |
Avoid image conversions. | During tool operation, the image must be sampled for processing by the neural network. This sampling requires a raster (uncompressed) format image such as a bitmap. Performing this conversion takes time. Similarly, if the tool is configured to use a single-channel (grey-scale) image as input, but the supplied images are multi-channel color images, the luminance value must be computed for each image at run time. | Attempt to solve your application using a single-channel grayscale image. | Some applications require color information.
Reduce the amount of processed data. | Reduce the quantity of processed data by doing the following: Use a smaller ROI Use a mask Use as few image channels as possible These help to improve processing speed by reducing the total amount of data that is processed. | Restrict the ROI. | ViDi tools need contextual information to work well, so try not to constrain the ROI too much. Downsampling (set through the Sample Density parameter) is usually not needed. By selecting a larger Feature Size, you can improve speed and remove the need for runtime downsampling.
Use multithreading | On systems with multiple GPUs, processing multiple streams concurrently allows tools to execute in parallel, increasing throughput. On single GPU systems, you can configure the system to allow multiple processes to make use of the same GPU. This allows a higher GPU occupancy and can improve throughput, although tool execution time will increase. | Use the --max-process-count command line argument to enable multiple threads to access a single GPU. To enable multi-process GPU access for a runtime application using the local control's GlobalConfig() method:
    control.GlobalConfig("max_process_count=2");
| The processing time for an individual tool will increase.
C++ (unmanaged) | Use of an unmanaged language environment reduces the impact of system activity on tool execution. | For low-latency, high-performance applications, do not use Cognex Designer. | Windows is not a real-time operating system (RTOS).