35 Commits

Author SHA1 Message Date
af65c9d5d4 Performance improvement for most scenes (#974)
tl;dr: this is a significant performance improvement for many scenes. 1.7x - 2.6x improvement in animation it/s.

This is a small change to some of the hotest paths in rendering objects. The biggest win comes from not using np.allclose() to check if two points are close enough. In general, NumPy is awesome at operating on large arrays, but overkill for very tiny questions like this. Created a small function to determine if two points are close using the same algorithm, and limited it to 2D points since that's all we need in set_cairo_context_path().

A couple of other minor tweaks to reduce or eliminate other uses of NumPy in this path.

In general, it is better to avoid wrapping lists in np.array when a real NumPy array isn't actually needed.

Added a new file for performance test scenes, with a single scene from the end of a video I've been working on.

Data:

MacBook Pro (16-inch, 2019)
macOS Catalina 10.15.4
2.4 GHz 8-Core Intel Core i9
64 GB 2667 MHz DDR4
Python 3.7.3 (default, Mar  6 2020, 22:34:30)

Profiler: yappi under Pycharm.

Using the scene Perf1 from the included perf_scenes.py, averaged over 5 runs and rendered with:
manim.py perf_scenes.py Perf1 -pl --leave_progress_bars

Before:
Animation 0: FadeInTextMobject, etc.:               8.93it/s
Animation 1: ShowCreationParametricFunction, etc.: 84.66it/s

Profiler shows 48.5% of the run spent under Camera.set_cairo_context_path()

After
Animation 0: FadeInTextMobject, etc.:               23.45it/s  -- 2.63x improvement
Animation 1: ShowCreationParametricFunction, etc.: 149.62it/s  -- 1.77x improvement

Profiler shows 19.9% of the run spent under Camera.set_cairo_context_path()

Less improvement with production-quality renders, and percent improvement varies with scene of course. This appears to be a good win for every scene I'm working on though. I hope it will be for others, too.

NB: there are more perf improvements to be had, of course, but this is the best one I currently have.
2020-04-24 21:04:08 -07:00
557bbff36c Added PGroup 2019-09-24 14:40:21 -07:00
42e0cd07ac Added support for changing and interpolating stroke_width on PMobjects 2019-09-19 13:38:46 -07:00
542ddb9afd Make sure set_opacity changes background stroke as well 2019-06-13 09:26:34 -07:00
f4c2c4642a Fix bug with applying function to VectorizedPoint 2019-03-21 17:50:04 -07:00
84a950425c DashedVMobject should handle case when num_dashes=0 2019-03-21 09:42:06 -07:00
453ae95cee Add stroke opacity to VMobject.get_style 2019-03-20 21:28:19 -07:00
ac9c04d3b8 Bugfix for aligning null VMobjects 2019-03-19 22:29:18 -07:00
45fa02b6b9 Have VMobject.set_style return self 2019-03-19 17:29:55 -07:00
fb99ebaeaf Change how family is handled for VMobject.fade 2019-03-16 22:11:48 -07:00
992d364913 fix get_anchors for VMobjects 2019-03-10 11:56:04 -07:00
4fbe67f262 Added general get_arc_length to VMobject 2019-02-15 15:15:07 -08:00
c47329660f Refactored make_smooth and make_jagged 2019-02-15 14:22:01 -08:00
d943f10123 Fixed make_jagged 2019-02-15 11:51:18 -08:00
2375f3675b Import the function "rotate_vector" 2019-02-13 16:32:37 +08:00
ff53c57d9d Tiny line swap 2019-02-11 22:25:02 -08:00
f429f46df8 Got rid of fade_no_recurse idea 2019-02-11 21:15:15 -08:00
9f76063271 Fix some bugs with VMobject.align_points 2019-02-11 20:52:54 -08:00
72a8bd8cc1 Fixed bug with VMobject.align_points 2019-02-09 10:39:34 -08:00
266f44f10e Added VMobject.set_opacity method 2019-02-07 17:47:16 -08:00
3de8c2f04c Added VMobject.get_subcurve, and cleaned up implementation of DashedVMobject 2019-02-07 15:41:15 -08:00
0ecac2bfb4 Factored out Line.get_start and Line.get_end to be more general Mobject methods 2019-02-07 14:52:40 -08:00
5c7f1b15c0 Bug fix for VMobject.pointwise_become_partial 2019-02-07 10:59:56 -08:00
d88c301622 Updating coordinate system mobjects 2019-02-06 21:16:26 -08:00
24d6113bba Get rid of propagate_style_to_family, since it is basically always true 2019-02-06 16:25:03 -08:00
47f6d6ba38 Rewrote ParametricFunction to have less buggy interpolation 2019-02-06 15:18:11 -08:00
30356f3976 Fix edge case for VMobject.get_subpaths_from_points 2019-02-05 16:17:15 -08:00
b7cf5e82e3 rate_func can no longer be None, must be a function. Use 'linear' instead of None 2019-02-05 15:39:58 -08:00
dcb7dc8a1d Coninuation of VMobject restructuring 2019-02-05 15:25:59 -08:00
1f46904f9b Remove add_control_points, re-implement VMobject.align_points 2019-02-05 13:12:55 -08:00
eaf25ff34b Changing the way VMobject handles its internal bezier curves so as to eliminate the need for sup_paths 2019-02-05 11:02:15 -08:00
33b7371eb1 sheen -> sheen_factor 2019-02-03 12:12:26 -08:00
ba88104177 Added set_style, get_style, and improved match_stlye 2019-01-04 11:50:06 -08:00
afdf907abc fix imports, remove __init__.py files, some pep8 linting 2018-12-27 09:41:41 -08:00
3543a750ba move library code into manimlib, replace relative imports with absolute imports 2018-12-26 20:57:01 -08:00