I need to run two external processes (on Linux):
pdftotext -tsv one.pdf
pdftotext -tsv two.pdf
For each one I need to acquire the output and post-process it.
Both are completely independent.
(However, once I've finished post-processing I then do some work on
both sets of post-processed data together.)
Each external process takes about 3 secs so it takes just over 6 secs
to acquire the data from both processes.
When I've done something similar in Python I've used the multiprocessing module and this has got my runtime close to the 3 secs.
In my experiments with Tcl's threading I've found the threading startup overhead to be rather large.
What is the fastest way to run two independent processes concurrently
and acquire their outputs using Tcl?
This takes ~1 sec.So it's 2x faster, as expected.
Am 29.04.2026 um 10:51 schrieb Mark Summerfield:
This takes ~1 sec.So it's 2x faster, as expected.
What's the issue?
In my experiments with Tcl's threading I've found the threading
startup overhead to be rather large.
I need to run two external processes (on Linux):
pdftotext -tsv one.pdf
pdftotext -tsv two.pdf
I need to run two external processes (on Linux):
pdftotext -tsv one.pdf
pdftotext -tsv two.pdf
* Mark Summerfield <m.n.summerfield@gmail.com>
| I created a tiny test program (65 LOC; shown at the end) to
| compare timings. I did multiple timings and here're the averages:
| serial (2 LOC) 2.020 sec
| multiprocess (19 LOC) 1.055 sec
| threaded (13 LOC) 1.061 sec
| Since the difference between the multiprocess and threaded
| approaches is so small and that the threaded code is simpler
| and more appealing, I'm going to use the threaded version in
| my programs (which only ever work with two PDFs at a time)
| — so thank you "abu"!
I wonder: you stated in your initial message
Message-ID: <10sschf$3nvs2$1@dont-email.me>
In my experiments with Tcl's threading I've found the threading
startup overhead to be rather large.
Can you tell what is/was the difference to the current solution which obviously has no "startup overhead"?
R'
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,116 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 86:08:18 |
| Calls: | 14,305 |
| Files: | 186,338 |
| D/L today: |
833 files (258M bytes) |
| Messages: | 2,525,504 |