Given that the problem is caused by using thousands of <syntaxhighlight> tags on the page, and the page is generated by a bot, it seems to me like the ideal solution is to make the bot perform the syntax highlighting locally using your favorite fast library, and save the resulting HTML markup to the page.