Bug 414006 - Spacer tool is prohibitively slow with many timeline clips
Summary: Spacer tool is prohibitively slow with many timeline clips
Status: CONFIRMED
Alias: None
Product: kdenlive
Classification: Applications
Component: User Interface (show other bugs)
Version: git-master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL:
Keywords: efficiency
: 441662 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-11-10 16:35 UTC by Bill Robinson
Modified: 2024-04-08 13:07 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
fritzibaby: Brainstorm+


Attachments
callgrind output from when trying to use the time slicing tool with (2.00 MB, text/plain)
2019-11-10 16:35 UTC, Bill Robinson
Details
another callgrind output - with debug 6.17.0 MLT this time. (2.59 MB, text/plain)
2019-11-10 19:33 UTC, Bill Robinson
Details
callgrind output using spacer tool on big project (469.73 KB, application/gzip)
2021-09-09 19:35 UTC, Bill Robinson
Details
large project file causing spacer tool to be slow (210.26 KB, application/gzip)
2021-09-09 19:38 UTC, Bill Robinson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Robinson 2019-11-10 16:35:36 UTC
Created attachment 123823 [details]
callgrind output from when trying to use the time slicing tool with

SUMMARY
When trying to use the spacer tool to close gaps in the video where I've cut pieces out and rearranged, 

STEPS TO REPRODUCE
1. Have video with many clips in the timeline, cut it up and have lots of gaps (I'm talking about 50+ little segments)
2. Use the spacer tool to try and close the gaps where there are many clips to the right

OBSERVED RESULT
Program hangs for approximately 10 seconds before clips jump to their new position.


EXPECTED RESULT
Clips should move much more quickly. <100ms ideally, maybe <1s minimally.


System info:
CPU: Intel Core i7-5820K @ 3.3GHz, 12-core
Memory: 48 GiB
OS: Ubuntu 19.10 eoan 64-bit

I've run just that operation with the valgrind tool callgrind and generated profiling information. I was clicking around in it, but couldn't really work it out. It looks maybe like it's an MLT problem with just moving lots of clips... ?
Comment 1 Bill Robinson 2019-11-10 19:33:44 UTC
Created attachment 123828 [details]
another callgrind output - with debug 6.17.0 MLT this time.
Comment 2 Bill Robinson 2019-11-10 19:43:43 UTC
So it looks like just shuffling along these clips they are being removed and then reinserted.

It appears that Mlt::Playlist::insert_at->mlt_playlist_insert_at is called 360 times and this causes 2,800,000+ calls to mlt_playlist_virtual_refresh and 28,000,000+ calls to mlt_properties_get_data which is where most of the freeze happens.

This is making kdenlive unusable for me :( 

Is it possible to get a version of that timeline-shuffling spacer tool that just  changes the start/end properties of the clips instead of removing/re-adding them, because it seems to be very expensive in MLT.

Thanks
Comment 3 emohr 2019-11-18 17:15:21 UTC
Thank you for this analysis. This is very helpful. Do you experience other steps which creates similar amount of calls?
Comment 4 farid 2021-03-13 21:54:22 UTC
Thanks for the great input, hopefully this can be fixed for 21.04. Also tracked here: https://invent.kde.org/multimedia/kdenlive/-/issues/963
Comment 5 emohr 2021-08-05 17:29:29 UTC
@Bill In the meantime we made some performance improvements. Please test with the actual master.
Comment 6 farid 2021-08-23 20:33:09 UTC
@bill do you think you can compile and test this commit: https://invent.kde.org/multimedia/kdenlive/-/merge_requests/216
Comment 7 Bill Robinson 2021-08-23 20:42:28 UTC
Thanks! I will have a go at it next week. It's on my list! :)
Comment 8 Bill Robinson 2021-08-23 20:44:31 UTC
Thanks! I will have a go at it next week. It's on my list! :)
Comment 9 Bill Robinson 2021-09-09 19:35:48 UTC
Created attachment 141429 [details]
callgrind output using spacer tool on big project

I updated to the latest master and also I have tried the sandsmark/martin/texture-cache branch. Both are still about as slow using the spacer tool.

I have recorded another doing one move with the spacer tool of a big project with lots of edits.

You can uncompress it and then open it with kcachegrind, maybe it's useful. 


I will also attach the project file
Comment 10 Bill Robinson 2021-09-09 19:38:00 UTC
Created attachment 141430 [details]
large project file causing spacer tool to be slow

Please find attached the compressed project file that causes the spacer tool to be really slow for me. I can't attach the clips as they're from a personal family project.

Thanks
Comment 11 Julius Künzel 2021-10-05 18:08:39 UTC
*** Bug 441662 has been marked as a duplicate of this bug. ***