If you are having performance problems with PIGGE, take a look at the troubleshooting guide. This document is a set of tips and rules of thumb for improving performance of rendering code -- basically notes I jotted down at one point.


Benchmark
Above all, benchmark. Try different ideas, and check them all to see which ones perform best. Make sure you are benchmarking what you think you are; game engines often perform worse during normal play than they do during their benchmarks, because the benchmarks use hardcoded data, and turn off AIs and random number generators and the like.
Profile
Don't just trust your gut about what is slowing the program down. Don't trust these rules of thumb either; they are bound to be wrong sometimes, and the only way you'll know is to actuallly profile your code. You can use a general-purpose profiler, or simply instrument your code, but whatever your method, just do it.
Offload Work
If you are writing to an API that can do a lot of work for you, such as OpenGL, let it do its job. Try to get it to do as much work for you as possible. These APIs are generally either accelerated in hardware, or written in hand-tuned low-level code, such as C or assembly. It's unlikely you'll be able to beat this in a higher-level language unless your dataset is sufficiently special that you can do significantly less work than a general- purpose algorithm. Even then, benchmark it. I've been surprised a number of times when I knew I could do a lot fewer iterations of some function manually than the API would have to do -- and the API was faster anyway, because each iteration was so much faster.
Minimize API Calls
This may seem like the opposite of the previous rule of thumb, but I mean something different here. Calls from a high-level language down through an API, whether that be file I/O calls, graphics calls, or what have you, are slow. Usually, very slow. It's worth it to review your code to see if you could batch several single-item API calls into an array call, or cache a value instead of constantly asking the API, or rearranging your API calls to minimize the number of times you have to do set up or breakdown of objects or state.
Use Performance Features
Some APIs have special features designed to improve performance. It is usually a good idea to use them if you can, especially if the API guarantees performance "no worse" than the normal code path. Of course, using the special feature may make your code jump through so many hoops that your code goes slower, but that's why you benchmark and profile, right? OpenGL includes all of the following performance features and more:
  • Hardware or hand-tuned code acceleration of many features.
  • Caching complex sequences of API calls in the server, and activating them all with a single call later.
  • Performing repeated operations on densely packed arrays of data, rather than just a few unpacked elements at a time.
  • Ability to choose appropriate data types to minimize bandwidth utilization and spurious transformation.
  • Functions to get and set many related state variables in a single call.
  • Data stacks, allowing easy return to previous states without rebuilding them from scratch.
  • Tesselators and evaluators, which take simple descriptions of objects, and produce complex, detailed representations from them.