Making Paragraph::latex() thread safe?
Scott Kostyshak
skostysh at lyx.org
Tue Aug 30 12:04:37 UTC 2022
On Tue, Aug 30, 2022 at 12:02:24PM +0200, Pavel Sanda wrote:
> On Mon, Aug 29, 2022 at 03:52:19PM -0400, Scott Kostyshak wrote:
> > I think the speedup will be even faster if we could make Paragraph::latex() thread-safe.
>
> Before tuning threads - are you sure that the sequential run can be broken in this way, i.e. whether subsequent paragraphs are not dependent on some information produced before (like some counters, etc)?
Currently the iterations do depend on each other. At least some of those dependencies can be fixed. I didn't want to put that much time into it though until we addressed the thread-unsafe code.
> > If I protect it with a mutex, then things work much better. But that's exactly the code that I need to run in parallel for my knitr child documents to export in parallel. Could someone explain intuitively why this code is not thread-safe? Is there any hope of making it thread-safe without major surgery?
>
> The bottlenecks I typically experience are of two kinds:
> 1) pictures conversion (having parallel code would be great even for document load when ton of pics gets converted!)
Indeed this would be nice.
> 2) final pdflatex compilation
>
> The latex generation part is just neligible.
Makes sense.
> Point 1 seems to be a good candidate for paralelization. External calls (like knitr) might be as well in case, again, its evaluation can't be dependent on the previous insets. But in this case I am almost sure some previous knitr inset might produce something needed for the subsequent ones ...
You are right that knitr cannot be parallelized within a document. It is more the case that it would be nice to run knitr for child1.lyx in one thread and run knitr for child2.lyx in a separate thread.
Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20220830/36015549/attachment.asc>
More information about the lyx-devel
mailing list