I have just realized, if I place my custom LyX macros into a separate LyX file with the same settings of the master file and insert that file into the master file as a child document, compilation times are significantly improved. FYI.