With the risk of stating the obvious, here is some advice:
In many cases you can gain some performance by writing Java actions. For example to cache objects in HashMaps, or to use batches so that the server keeps only a limited set of objects in memory.
Further, if you modify associations in Java, you can gain much performance on large sets, if you work with raw IMendixIdentifiers, without instantiating the corresponding IMendixObjects.