Commit c610e48
authored
fix(oiiotool): Allow thread control for --parallel-frames (#4818)
Fixes #4811
This patch makes oiiotool's initial cursory scan of the command line
notice a `--threads` and carfully honor it when parallelizing the frame
loop.
Explanatory background info:
The cited issue shows something subtle happening with oiiotool's
`--parallel-frames` argument. The symptom was that it was using too many
threads and running out of memory, and seemed impervious to the use of
`--threads` to properly control it.
The reason is that oiiotool first scans the command line args in a
cursory way looking for signs of a "sequence", like a `--frames` or any
filename containing frame wildcards (like `linear.%04d.exr`) and also
noting if there is a `--parallel-frames`, but not actually taking any
actions for any of the commands yet.
Having seen that there are frame wildcards, what it then does is execute
the whole command line, once for each frame number that matched the
pattern. And since it noted that a `--parallel-frames` argument was
present somewhere, it does it with a parallel for loop. But how many
threads does it use? Well, enough for all the cores, since in some sense
it has not yet noticed the `--threads` argument. Moving the `--threads`
to be placed prior to the `--parallel-frames` doesn't help, either.
The suggested workaround was to set the default number of threads with
the environment variable `OPENIMAGEIO_THREADS` prior to launching
oiiotool. But this patch is a more robust solution.
Signed-off-by: Larry Gritz <lg@larrygritz.com>1 parent 09250af commit c610e48
2 files changed
Lines changed: 47 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
616 | 617 | | |
617 | 618 | | |
618 | 619 | | |
619 | | - | |
| 620 | + | |
620 | 621 | | |
621 | 622 | | |
| 623 | + | |
| 624 | + | |
622 | 625 | | |
623 | 626 | | |
624 | 627 | | |
| |||
7228 | 7231 | | |
7229 | 7232 | | |
7230 | 7233 | | |
7231 | | - | |
7232 | | - | |
7233 | | - | |
| 7234 | + | |
| 7235 | + | |
| 7236 | + | |
| 7237 | + | |
7234 | 7238 | | |
7235 | 7239 | | |
7236 | 7240 | | |
| |||
7305 | 7309 | | |
7306 | 7310 | | |
7307 | 7311 | | |
7308 | | - | |
7309 | | - | |
| 7312 | + | |
| 7313 | + | |
| 7314 | + | |
7310 | 7315 | | |
7311 | 7316 | | |
7312 | 7317 | | |
| |||
7336 | 7341 | | |
7337 | 7342 | | |
7338 | 7343 | | |
| 7344 | + | |
| 7345 | + | |
| 7346 | + | |
| 7347 | + | |
| 7348 | + | |
7339 | 7349 | | |
7340 | 7350 | | |
7341 | 7351 | | |
| |||
7441 | 7451 | | |
7442 | 7452 | | |
7443 | 7453 | | |
7444 | | - | |
| 7454 | + | |
| 7455 | + | |
7445 | 7456 | | |
7446 | | - | |
| 7457 | + | |
| 7458 | + | |
| 7459 | + | |
7447 | 7460 | | |
7448 | 7461 | | |
7449 | 7462 | | |
7450 | 7463 | | |
7451 | 7464 | | |
7452 | 7465 | | |
7453 | 7466 | | |
7454 | | - | |
| 7467 | + | |
| 7468 | + | |
7455 | 7469 | | |
7456 | 7470 | | |
7457 | 7471 | | |
| |||
7465 | 7479 | | |
7466 | 7480 | | |
7467 | 7481 | | |
| 7482 | + | |
| 7483 | + | |
| 7484 | + | |
| 7485 | + | |
| 7486 | + | |
| 7487 | + | |
| 7488 | + | |
| 7489 | + | |
| 7490 | + | |
| 7491 | + | |
| 7492 | + | |
| 7493 | + | |
| 7494 | + | |
| 7495 | + | |
| 7496 | + | |
| 7497 | + | |
| 7498 | + | |
| 7499 | + | |
7468 | 7500 | | |
7469 | 7501 | | |
7470 | 7502 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
| 162 | + | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
| |||
397 | 398 | | |
398 | 399 | | |
399 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
400 | 405 | | |
401 | 406 | | |
402 | 407 | | |
| |||
0 commit comments