Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow performance causing dropped frame for main streaming/recording #1

Open
1 of 4 tasks
norihiro opened this issue Jul 24, 2022 · 0 comments
Open
1 of 4 tasks
Labels
enhancement New feature or request

Comments

@norihiro
Copy link
Owner

norihiro commented Jul 24, 2022

Issue description

When enable this filter, sometimes it causes dropped frame for main streaming and recording.

Current status of investigation

Profile

Checking rendering time with adding profile.

ajaof_render: min=2.579 ms, median=4.488 ms, max=10.32 ms, 99th percentile=9.094 ms
  • Trial 1 - Separate stage-surface
    With separating staging (until gs_stage_texture) and mapping (gs_stagesurface_map and later) into different iteration, rendering time is reduced and the number of dropped frame looks reduced. (I had 3 runs and the numbers are slightly different.)
    The code is 2ac4699.
ajaof_render: min=0.017 ms, median=0.602 ms, max=19.639 ms, 99th percentile=17.333 ms
ajaof_render_render: min=0.017 ms, median=0.272 ms, max=5.12 ms, 99th percentile=0.861 ms
ajaof_render_output: min=0.565 ms, median=0.92 ms, max=19.637 ms, 99th percentile=17.748 ms
ajaof_render: min=0.055 ms, median=0.584 ms, max=15.644 ms, 99th percentile=10.016 ms
ajaof_render_render: min=0.054 ms, median=0.259 ms, max=4.331 ms, 99th percentile=0.64 ms
ajaof_render_output: min=0.565 ms, median=0.693 ms, max=15.644 ms, 99th percentile=12.179 ms
ajaof_render: min=0.029 ms, median=0.669 ms, max=19.953 ms, 99th percentile=16.839 ms
ajaof_render_render: min=0.028 ms, median=0.285 ms, max=3.744 ms, 99th percentile=0.788 ms
ajaof_render_output: min=0.61 ms, median=1.297 ms, max=19.952 ms, 99th percentile=17.677 ms
  • Trial 2 - Breakdown profile more
    It is not clear which is actually slow. Maybe gs_stagesurface_map or video_output_lock_frame. If later, prepare a new thread to call video_output_lock_frame.
  • Trial 3 - Run stage-surface as the graphics task
    The graphics tasks are executed after all other rendering while the rendering routine ajaof_render is called at very beginning of rendering the main texture. Assuming gs_stage_texture is actually executed in pipeline, this approach might improve performance without slowing the output.
    If Trial 2 reveals the necessity to have another thread, another idea is call gs_stagesurface_map from the new thread. The call will be automatically delayed by obs_enter_graphics().
  • Misc - memcpy
    If linesize == video_linesize, call just one memcpy.
    On i7-7700, This improve time of copying 1920x1080 frame data from 1.122 ms to 0.607 ms
@norihiro norihiro added the enhancement New feature or request label Jul 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant