The following table lists the techniques to use to improve the performance of UEFI drivers. By using combinations of all of these techniques, significant performance enhancements can be realized.
Compiler flags that optimize for performance.
Some compiler provide flags (such as /Ot, /O2, and /Ox) optimize code for performance. This technique is an easy way to reduce the execution time of a UEFI driver. For the most part, the EDK II balances size and speed optimizations. The flags can be customized to specify a preference for speed or size.
Whenever possible, use UEFI boot services, UEFI runtime services, and the protocol services provided by other UEFI drivers. The UEFI boot services and UEFI runtime services are likely implemented as native calls that have been optimized for the platform, so there is a performance advantage for using these services. Some protocol services might be native, and other protocol services might be EBC images. Either way, if all UEFI drivers assume that external protocol services are native, then the combination of UEFI drivers and EFI services result in more efficient execution.
PCI I/O Protocol
If a UEFI driver is a PCI driver, then it should take advantage of all the PCI I/O Protocol services to improve the UEFI driver's performance. This approach means that all register accesses should be performed at the largest possible size. For example, perform a single 32-bit read instead of multiple 8-bit reads. Also, take advantage of the read/write multiple, FIFO, and fill modes of the