Compiling a 130 pages long report with xelatex takes my PC about 4 seconds, of which at least 1 second is spent at one particular page, and some more time at a later page.
The page where most time is spent is one in a sequence of very similar pages, all ending with a
\clearpage command; hence there are no issues with line/page breaks or float placement. The page contains formulae and figures, but so do many other pages before and after. Of course I have checked the size of the figures: no different from those on other pages. Of course I have looked into the log file: nothing different from the many other similar pages.
When part of the page is commented out, xelatex hangs no longer at this page, but at the following one. This indicates strongly that the problem has nothing to do with specific page contents but is rather due to some internal operations that set in when a certain amount of input has been read and digested. Xosview indicates that xetex is far from using up my 8GB RAM.
How can I proceed to find out what makes xelatex hang at peculiar, inconspicuous pages?
I am not satisfied with the answer "big images". I want to thoroughly understand why xetex smoothly digests, say, eleven big images, but hangs at #12.
I am not satisfied with the answer "it's sometimes unavoidable". At most, it's unavoidable with the official version of xelatex. But if e.g. the problem has to do with finite stack sizes, why not recompile xelatex with larger stacks.
So this question is really about understanding quite specifically what's going on within xelatex when the above described behavior is observed. Understanding at as deep a level as necessary to think about possible countermeasures (not workarounds).
I freely admit that gaining a few seconds per compilation round may not be worth such effort. Yet again, this is not about practicalities, but about understanding: I am just curious!