14 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
7ac990119a frame_center was getting double-added, messing up MovingCameraScene 2019-06-19 16:07:07 -07:00
5dcb113996 Moving the frame_center of camera was not working. This fixes it, but I suspect there is a need for a deeper fix where everything is handled in transform_points_pre_display properly for the various camera classes 2019-05-29 18:28:28 -07:00
89824e3d52 continual_update -> update_mobjects 2019-02-15 20:05:45 -08:00
c23f456fd6 Slightly cleaner implementation of set_cairo_context_path 2019-02-11 16:05:35 -08:00
1f320a3974 Fixed small bug with Camera not properly transforming points 2019-02-11 15:49:12 -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
593dd38b45 frame_duration -> frame_rate 2019-02-03 12:09:20 -08:00
900e6ac837 Use frame_rate, instead of frame_duration, and make that part of the camera rather than the scene 2019-01-25 10:13:17 -08:00
5aa11cf8ad Fixed a problem where in zooming in, stroke widths all grew 2019-01-17 14:09:50 -08:00
739be6a9b2 Added to camera.py (#387) 2019-01-03 13:42:43 -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