Repository navigation
Conversation
| // Run the CDEF strength search and the CDEF filtering on the encoder worker | ||
| // threads when there are several. The output is the same with or without it. | ||
| // 0: single thread. | ||
| int enable_cdef_mt; |
There was a problem hiding this comment.
Suggest to remove the speed features here. MT functions should be called whenever there are > 1 threads available. Please refer to existing MT implementation.
There was a problem hiding this comment.
Thanks Yunqing for the comment.
Hi @yeqing-wu, what do you think about this?
There was a problem hiding this comment.
@yunqingwang1, We may need to re-evaluate all MT implementations. As more components get multithreaded and the single-threaded baseline keeps getting faster, the fixed cost of MT (job dispatch, thread synchronization/barriers, per-thread data setup and merging, load imbalance, cache contention) becomes a larger share of the runtime. For lightweight stages, that overhead can cancel out the gain or even make things slower. A per-component switch lets us A/B each MT path in the future to test their performance, if they cannot help, we can remove the MT code of that component to simplify the code. What do you think?
There was a problem hiding this comment.
Once av2-enc is finalized or stable enough, we can re-evaluate every MT implementation. And then remove the control flags when MT can help. MT paths that don't help will be removed entirely.
There was a problem hiding this comment.
Ok, I understand now - thanks for the explanation. That is fine for testing. I am ok with these 2 options: 1. keep these flags in a separate struct instead of LOOP_FILTER_SPEED_FEATURES; 2. If you prefer to add them in LOOP_FILTER_SPEED_FEATURES, please add comment to explain why they are needed and when they will be removed. Would this be ok?
There was a problem hiding this comment.
Thanks. I'll go with option 2: the flags stay in LOOP_FILTER_SPEED_FEATURES with a comment explaining that they exist for A/B testing and will be removed once av2-enc is stable and the MT paths are re-evaluated.
|
@YixinDu1 Thank you for adding MT support in this area. Do you see how much time CDEF + CCSO take in the encoder now, and is the achieved encoder speedup with A1 (4 threads)/A2 (2 threads) good enough (i.e. in line with the expectation)? |
Let me run a quick tool off test for CDEF/CCSO to provide more context. |
Hi @yunqingwang1, here are the tool off results compared with our patch savings:
The patch recovers about 38% of the CDEF + CCSO time on A1 (2.1 of 5.5) and about 25% on A2 (0.6 of 2.4). |
58f5335 to
40eb4df
Compare
|
Same for this PR |
Run the CDEF strength search and the CDEF and CCSO filtering on the encoder worker threads. Worker 0 now gets a thread, so the existing loop filter and loop restoration multithreading also runs on it. The enable_cdef_mt and enable_ccso_mt speed features, on by default, turn the threading off. Anchor: commit b38429d CTC: AV2 CTC v8 (33 frames, RA) ``` Speed 0 (cpu-used=0) +--------------+-------+-------+-------+-------+-------+--------+ | Class | Y | Cb | Cr | wAvg | Enc% | Ratio | +--------------+-------+-------+-------+-------+-------+--------+ | A1 | 0.00 | 0.00 | 0.00 | 0.00 | 99.9 | N/A | | A2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.9 | N/A | | Avg w/o B2 | 0.00 | 0.00 | 0.00 | 0.00 | 100.0 | N/A | +--------------+-------+-------+-------+-------+-------+--------+ Speed 1 (cpu-used=1) +--------------+-------+-------+-------+-------+-------+--------+ | Class | Y | Cb | Cr | wAvg | Enc% | Ratio | +--------------+-------+-------+-------+-------+-------+--------+ | A1 | 0.00 | 0.00 | 0.00 | 0.00 | 100.0 | N/A | | A2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.8 | N/A | | Avg w/o B2 | 0.00 | 0.00 | 0.00 | 0.00 | 100.0 | N/A | +--------------+-------+-------+-------+-------+-------+--------+ Speed 2 (cpu-used=2) +--------------+-------+-------+-------+-------+-------+--------+ | Class | Y | Cb | Cr | wAvg | Enc% | Ratio | +--------------+-------+-------+-------+-------+-------+--------+ | A1 | 0.00 | 0.00 | 0.00 | 0.00 | 98.7 | N/A | | A2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.6 | N/A | | Avg w/o B2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.8 | N/A | +--------------+-------+-------+-------+-------+-------+--------+ Speed 3 (cpu-used=3) +--------------+-------+-------+-------+-------+-------+--------+ | Class | Y | Cb | Cr | wAvg | Enc% | Ratio | +--------------+-------+-------+-------+-------+-------+--------+ | A1 | 0.00 | 0.00 | 0.00 | 0.00 | 98.9 | N/A | | A2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.4 | N/A | | Avg w/o B2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.7 | N/A | +--------------+-------+-------+-------+-------+-------+--------+ Speed 4 (cpu-used=4) +--------------+-------+-------+-------+-------+-------+--------+ | Class | Y | Cb | Cr | wAvg | Enc% | Ratio | +--------------+-------+-------+-------+-------+-------+--------+ | A1 | 0.00 | 0.00 | 0.00 | 0.00 | 98.9 | N/A | | A2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.1 | N/A | | Avg w/o B2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.5 | N/A | +--------------+-------+-------+-------+-------+-------+--------+ Speed 5 (cpu-used=5) +--------------+-------+-------+-------+-------+-------+--------+ | Class | Y | Cb | Cr | wAvg | Enc% | Ratio | +--------------+-------+-------+-------+-------+-------+--------+ | A1 | 0.00 | 0.00 | 0.00 | 0.00 | 98.3 | N/A | | A2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.2 | N/A | | Avg w/o B2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.2 | N/A | +--------------+-------+-------+-------+-------+-------+--------+ Speed 6 (cpu-used=6) +--------------+-------+-------+-------+-------+-------+--------+ | Class | Y | Cb | Cr | wAvg | Enc% | Ratio | +--------------+-------+-------+-------+-------+-------+--------+ | A1 | 0.00 | 0.00 | 0.00 | 0.00 | 97.9 | N/A | | A2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.4 | N/A | | Avg w/o B2 | 0.00 | 0.00 | 0.00 | 0.00 | 99.4 | N/A | +--------------+-------+-------+-------+-------+-------+--------+ Speed 6 (cpu-used=6), threads=8, row-mt=1, A1 and A2 only +--------------+-------+-------+-------+-------+-------+--------+ | Class | Y | Cb | Cr | wAvg | Enc% | Ratio | +--------------+-------+-------+-------+-------+-------+--------+ | A1 | 0.00 | 0.00 | 0.00 | 0.00 | 97.9 | N/A | | A2 | 0.00 | 0.00 | 0.00 | 0.00 | 98.3 | N/A | +--------------+-------+-------+-------+-------+-------+--------+ ```
40eb4df to
76bd8ce
Compare

Run the CDEF strength search and the CDEF and CCSO filtering on the encoder worker threads. Worker 0 now gets a thread, so the existing loop filter and loop restoration multithreading also runs on it. The enable_cdef_mt and enable_ccso_mt speed features, on by default, turn the threading off.
Anchor: commit b38429d
CTC: AV2 CTC v8 (33 frames, RA)