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

Performance report #734

Open
MewPurPur opened this issue May 14, 2024 · 1 comment
Open

Performance report #734

MewPurPur opened this issue May 14, 2024 · 1 comment

Comments

@MewPurPur
Copy link
Owner

MewPurPur commented May 14, 2024

This report uses splash.svg, an SVG made only from paths, with one of the paths being very long. While this isn't exhaustive, it's pretty representative in my opinion of the things that need to be acknowledged.

<svg width="320" height="128" viewBox="0 0 320 128" xmlns="http://www.w3.org/2000/svg"><linearGradient id="a" x2="1"><stop offset=".2" stop-color="#3d85cc"/><stop offset="1" stop-color="#3060bf"/></linearGradient><path fill="#4c90bf" d="M114 83.5c0 12.5-3 20.5-5.5 24.5s-9 13.5-25 17-30 3-45-4S13 101 17 79l9-8 28 39z"/><path fill="url(#a)" d="M42 87.8c3 4.7 6.5 8.2 14 10.2 15 3 23-1.5 27-7.5 1.5-2.5 1.25-8 .5-10L113 70c1 4.5 1 9 1 13.5-11.5 27.5-37 31.5-50 31-25.5-2.5-32-14-35.5-20.5C25 86 26 77.5 26 72z"/><path fill="#dde" d="M17 79c3.5-15 12-23 18-27 2-1-3 18 7 35.8C32 83.5 27 77 26 73c-2 3-6 5-9 6"/><path fill="#62bcd9" d="M65.5 78c-3-2-7.5-6.5-5-7.5C75.5 66 82 50 83 45.5c1-1 8 8.5 9 13 3-2.5 7.5-7.5 8.5-13 1-1 10 12 12.5 24.5-9 3.5-13.5 13.5-15 12z"/><path fill="#a1dae6" d="M95 85c-2-3-5.5-3.5-7.5-3.5s-3.5 0-8.5.5-12.5-2-14.7-4.84C64 76.8 67 74 72 74.5c10 1 18.5.5 21.5-3 1-1 8.5 6.5 7.5 8.31-3 3.8-5 6.8-6 5.3z"/><path fill="none" stroke="#3461ac" stroke-width="2.5" stroke-linecap="round" d="M88.5 67.5s-5 4-9-1"/><path fill="#f24949" d="M26.5 37.5C24.5 46.5 24 50 22 50s-4.5-2-4.5-8 4-21.5 18.5-32.5S74-1 88 7c3 2 6 4 7 6s-3.5 5.5-12.5 0h-35zm80-18c2 2 4 5 3 7s-5-2.5-9-4-2-5-.5-6c3-2 5.5 2 6.5 3"/><path fill="#8ff249" d="M78 11s5.5 1.5 7.5 4 1.5 7-6 5h-27L33 40s-.5 2-3.5 1.5-3.5-4-3-6S30 27 34 22 53 2 78 11m13 12c-1.5-1 1-3.5 4-1.5s7 5.5 7 7.5-1.5 2.5-3.5 1.5-3-2.5-5.5-2.5-3-1-2.5-2 3.5-1 .5-3"/><path fill="#5555f2" d="M79.5 20c-3.5 2-1.5 3.5-4 5s-4.5 0-9.5-.5C50 23 42 38 40.5 45.5c-.5 4-2.5 1-3.5 0s-2 2-3.5 3-2.5 1-2.5-1.5 3.5-12.5 6-16 12-16.5 28.5-15c6.5 1 10.5 2.5 14 4"/><path fill="#62628c" stroke="#62628c" stroke-linejoin="round" d="M149.694 60.452q-8.064 0-11.952-4.176-3.84-4.224-3.84-13.104 0-8.592 4.032-12.816 4.032-4.272 12-4.272 1.152 0 2.352.144 1.248.096 2.448.336t2.208.576q1.056.336 1.776.768.576.336.912.72t.336.816q0 .48-.288 1.248-.24.72-.672 1.44-.384.72-.864 1.2t-.912.48q-.576 0-1.248-.192-.672-.24-1.536-.48-.864-.288-2.016-.48-1.104-.24-2.64-.24-4.224 0-6.288 2.688-2.016 2.688-2.016 8.112 0 4.08.912 6.48t2.736 3.456q1.824 1.008 4.56 1.008 1.296 0 2.544-.192t1.68-.347V46.58h-4.944q-1.44 0-1.44-2.4v-1.392q0-2.4 1.44-2.4h10.272q1.776 0 1.776 1.92v14.304q0 .624-.384 1.152-.336.48-1.104.864-.96.528-2.592.96-1.632.384-3.552.624-1.872.24-3.696.24m27.984 0q-5.712 0-8.688-3.36t-2.976-9.6q0-6.288 2.976-9.6t8.688-3.312 8.64 3.312q2.976 3.312 2.976 9.6 0 6.24-2.976 9.6-2.928 3.36-8.64 3.36m0-5.616q2.256 0 3.264-1.872 1.056-1.872 1.056-5.472t-1.056-5.424q-1.008-1.872-3.264-1.872t-3.312 1.872q-1.056 1.824-1.056 5.424t1.056 5.472 3.312 1.872m24.672 5.616q-2.592 0-4.656-1.488-2.016-1.488-3.216-4.368-1.152-2.928-1.152-7.104 0-3.936 1.2-6.816t3.456-4.464q2.304-1.632 5.52-1.632 1.824 0 3.024.48t1.92 1.008V25.46q0-.768.672-1.152.72-.432 2.256-.432h1.344q1.536 0 2.208.432.72.384.72 1.152v26.256q0 2.112.096 3.36.144 1.248.24 2.016.144.72.144 1.248 0 .576-.72.96-.672.336-1.68.528-.96.144-1.872.24-.864.048-1.248.048-.576 0-.864-.24-.288-.288-.48-1.008t-.48-2.064q-.528 1.056-1.488 1.872-.912.816-2.16 1.296t-2.784.48m2.112-5.808q1.392 0 2.352-.864 1.008-.864 1.632-1.968V41.108q-.528-.336-1.392-.624t-2.016-.288q-2.208 0-3.312 1.872-1.104 1.824-1.104 5.424 0 3.504.96 5.328t2.88 1.824m27.038 5.808q-2.4 0-4.32-.384-1.872-.336-3.216-.912t-2.208-1.104q-.672-.432-1.104-.816-.432-.432-.432-1.008t.144-1.296q.192-.768.48-1.488.336-.72.672-1.2.384-.48.768-.48.432 0 1.68.624 1.296.576 3.024 1.2 1.776.576 3.696.576 1.392 0 2.256-.336.912-.336 1.344-1.056.48-.72.48-1.824 0-1.152-.672-1.92-.624-.768-1.68-1.344-1.056-.624-2.4-1.104-1.296-.528-2.64-1.152-1.248-.576-2.4-1.344t-2.112-1.872q-.912-1.104-1.44-2.688t-.528-3.744q0-2.592.96-4.416 1.008-1.872 2.64-3.024t3.648-1.68q2.016-.576 4.128-.576 1.536 0 2.976.24 1.488.24 2.688.672 1.2.384 1.92.912.528.336.864.72t.336.768q0 .48-.192 1.248-.144.72-.432 1.44-.24.72-.624 1.2t-.816.48q-.576 0-1.536-.336-.912-.384-2.208-.72-1.248-.384-2.832-.384-1.344 0-2.256.336t-1.392 1.008q-.432.624-.432 1.632 0 1.2.72 2.016.72.768 1.92 1.344 1.248.528 2.64 1.152 1.488.624 3.024 1.392t2.832 1.92q1.296 1.104 2.064 2.832.816 1.68.816 4.224 0 2.832-.96 4.8-.912 1.968-2.496 3.168t-3.504 1.776q-1.92.528-3.888.528m26.5-.288q-1.2 0-1.872-.24-.672-.288-.864-.864l-10.56-30.768q-.048-.24-.096-.432-.048-.24-.048-.432 0-.528.576-.768.576-.288 1.824-.288h2.256q1.056 0 1.776.24.72.192.912.768l7.344 25.296h.192l7.344-25.296q.192-.528.768-.768t1.44-.24h2.064q1.536 0 2.208.288.72.24.72.768 0 .192-.048.432-.048.192-.144.432l-10.56 30.768q-.192.576-.864.864-.672.24-1.872.24zm33 .288q-8.064 0-11.952-4.176-3.84-4.224-3.84-13.104 0-8.592 4.032-12.816 4.032-4.272 12-4.272 1.152 0 2.352.144 1.248.096 2.448.336t2.208.576q1.056.336 1.776.768.576.336.912.72t.336.816q0 .48-.288 1.248-.24.72-.672 1.44-.384.72-.864 1.2t-.912.48q-.576 0-1.248-.192-.672-.24-1.536-.48-.864-.288-2.016-.48-1.104-.24-2.64-.24-4.224 0-6.288 2.688-2.016 2.688-2.016 8.112 0 4.08.912 6.48t2.736 3.456q1.824 1.008 4.56 1.008 1.296 0 2.544-.192t1.68-.347V46.58h-4.944q-1.44 0-1.44-2.4v-1.392q0-2.4 1.44-2.4h10.272q1.776 0 1.776 1.92v14.304q0 .624-.384 1.152-.336.48-1.104.864-.96.528-2.592.96-1.632.384-3.552.624-1.872.24-3.696.24M144.392 95.715q-1.115 0-2.077-.203-.937-.203-1.621-.481-.684-.304-1.115-.583-.253-.177-.456-.355-.177-.177-.177-.405 0-.177.051-.431.076-.279.177-.532.127-.279.253-.456.152-.203.304-.203.253 0 .887.329.633.329 1.571.659.963.329 2.103.329.988 0 1.647-.279.659-.304.988-.887t.329-1.469q0-.709-.329-1.191-.304-.507-.861-.861-.557-.38-1.241-.659t-1.419-.583q-.76-.304-1.495-.659-.735-.38-1.343-.937-.583-.557-.937-1.368-.329-.836-.329-2.052 0-1.115.431-2.001.431-.887 1.216-1.52t1.799-.963q1.039-.329 2.229-.329.684 0 1.393.127t1.317.355q.608.203 1.039.481.228.127.38.304t.152.329q0 .177-.076.456-.051.279-.152.557-.101.253-.253.456-.152.177-.304.177-.253 0-.76-.228t-1.191-.456-1.571-.228q-.912 0-1.545.304-.633.279-.988.836-.355.532-.355 1.292 0 .861.456 1.393.456.507 1.191.836.76.304 1.621.659.811.329 1.647.735.836.38 1.545.988.709.583 1.115 1.469.431.861.431 2.179 0 1.241-.431 2.204-.405.937-1.165 1.571t-1.799.963-2.28.329zm14.208-.127q-.507 0-.785-.127-.279-.127-.355-.329l-5.877-16.543q-.025-.101-.051-.177-.025-.101-.025-.203 0-.203.253-.329.279-.127.887-.127h.481q.431 0 .735.101t.38.329l4.813 14.617h.101l4.763-14.617q.076-.228.355-.329t.684-.101h.405q.659 0 .937.127.279.127.279.329 0 .101-.025.203 0 .076-.051.203l-5.877 16.517q-.076.203-.38.329-.279.127-.76.127zm17.18.127q-4.205 0-6.207-2.204t-2.001-6.865q0-4.535 2.077-6.764 2.103-2.255 6.181-2.255.659 0 1.267.076.633.076 1.191.203.583.127 1.064.304.481.152.836.355.279.177.456.355.177.177.177.355 0 .177-.101.456-.101.253-.253.532-.152.253-.329.431-.177.152-.355.152-.203 0-.532-.127-.304-.127-.785-.304-.456-.177-1.115-.304-.633-.127-1.495-.127-2.812 0-4.155 1.621-1.343 1.596-1.343 5.067 0 2.356.583 3.851.583 1.469 1.799 2.179 1.216.684 3.04.684.684 0 1.343-.101.684-.101 1.216-.279.154-.05.279-.111V87.99h-3.217q-.583 0-.583-.912v-.483q0-.912.583-.912h5.041q.836 0 .836.836v7.093q0 .38-.152.583-.127.203-.431.355-.608.355-1.393.608t-1.672.405-1.849.152zm21.027 0q-3.065 0-4.636-1.621t-1.571-5.117q0-2.28.709-3.8.735-1.52 2.077-2.28 1.343-.785 3.217-.785 1.799 0 2.964.811 1.165.785 1.723 2.255.557 1.469.557 3.471 0 .253-.152.557-.152.279-.405.481-.228.203-.481.203h-7.499q.051 1.925.937 2.812.912.861 2.635.861 1.115 0 1.9-.279.811-.279 1.292-.532.507-.253.659-.253.203 0 .38.253t.279.608q.127.329.127.532 0 .279-.405.583t-1.089.608q-.659.279-1.495.456t-1.723.177zm-3.521-7.853h5.979q0-1.799-.735-2.685-.735-.912-2.128-.912-.937 0-1.621.405t-1.089 1.191q-.38.785-.405 2.001zm15.914 7.853q-1.469 0-2.559-.785-1.064-.785-1.647-2.28-.583-1.52-.583-3.673 0-2.027.583-3.547.608-1.545 1.697-2.432 1.115-.887 2.635-.887 1.013 0 1.9.329.912.304 1.52.76v-6.08q0-.329.279-.481.279-.177.912-.177h.279q.608 0 .887.177.279.152.279.481v14.44q0 1.064.051 1.723.076.659.127 1.039.076.38.076.583 0 .177-.228.304-.203.127-.507.203-.304.051-.633.101-.304.025-.507.025-.253 0-.405-.152-.127-.152-.228-.532-.101-.405-.228-1.064-.431.583-1.039 1.013-.608.431-1.292.684-.659.228-1.368.228zm.785-2.229q.785 0 1.52-.456.735-.481 1.241-1.216V85.43q-.633-.557-1.393-.836-.735-.304-1.469-.304-1.343 0-2.052 1.216t-.709 3.471q0 2.305.76 3.42.76 1.089 2.103 1.089zm10.23 2.103q-.633 0-.887-.152-.253-.177-.253-.481V82.871q0-.304.253-.456.253-.177.887-.177h.355q.633 0 .887.177.253.152.253.456v12.084q0 .304-.253.481-.253.152-.887.152zm.177-14.972q-.735 0-1.039-.152-.304-.177-.304-.481v-1.647q0-.304.304-.456.304-.177 1.039-.177.709 0 1.013.177.304.152.304.456v1.647q0 .304-.304.481-.304.152-1.013.152m9.095 15.099q-1.064 0-1.799-.405-.709-.405-1.064-1.165-.355-.785-.355-1.925v-7.779h-1.14q-.583 0-.583-.912v-.329q0-.912.583-.912h1.14l.329-2.584q.051-.329.279-.481t.659-.152h.38q.532 0 .76.152t.228.481v2.584h1.976q.583 0 .583.912v.329q0 .912-.583.912h-1.976v7.727q0 .735.228 1.039.253.304.861.304.557 0 .785-.127.253-.127.431-.127.152 0 .228.203.101.177.152.456.076.253.076.507.025.228.025.329 0 .279-.38.507-.355.203-.861.329-.507.127-.963.127zm10.013 0q-2.888 0-4.433-1.748-1.52-1.748-1.52-5.016 0-3.293 1.52-5.067 1.545-1.773 4.433-1.773 2.863 0 4.357 1.773 1.52 1.748 1.52 5.067 0 3.293-1.495 5.041-1.469 1.723-4.383 1.723zm0-2.153q1.672 0 2.432-1.14.785-1.14.785-3.496t-.785-3.496q-.76-1.165-2.432-1.165-1.647 0-2.432 1.14-.76 1.14-.76 3.521 0 2.356.76 3.496.785 1.14 2.432 1.14m10.354 2.027q-.608 0-.887-.152-.279-.177-.279-.481v-8.689q0-1.064-.076-1.723-.051-.659-.127-1.039-.051-.38-.051-.583 0-.152.203-.279.228-.127.532-.203t.608-.101q.329-.025.532-.025.253 0 .405.177.152.152.253.557.127.38.228 1.064.355-.659.861-1.089.507-.456 1.115-.684t1.267-.228q.507 0 .735.228t.228.684q0 .253-.051.583-.051.304-.127.608-.076.279-.203.481-.101.177-.279.177-.203 0-.456-.101-.253-.127-.785-.127-.76 0-1.368.405-.583.405-.811 1.115v8.791q0 .304-.279.481-.279.152-.912.152z"/></svg>

Changing the text gave my laptop a 200ms lag spike. Let's go over some of what I consider interesting. Note that some of the below might overlap:

  • 10ms go into parsing path data. (5%)
  • 0.2ms go into drawing the multilines for tangent handles (0.1%)
  • 4.8ms go into drawing the polylines for contours (2.4%)
  • 6ms go into the contour math (3%)
  • 1.4ms go into drawing the handle textures (0.7%)
  • 0.5ms go into checking if the "Optimize SVG" button should be enabled (0.25%)
  • 5ms go into drawing LineEditButton (2.5%)
  • 80ms go into drawing path commands (40%)
  • 1.8ms go into the additional drawing of number sliders (0.9%)
  • 1.2ms go into the additional drawing of color fields (0.6%)
  • 13ms go into the inspector rebuilding (6.5%)
  • 5ms go into redrawing the graphic (2.5%)

Would be great if we get to identify more things.

@MewPurPur
Copy link
Owner Author

MewPurPur commented May 14, 2024

My current ideas are:

  • Multiline drawing can be optimized by using the built-in method in Godot 4.3
  • PathData should become something like 2x faster when the performance of match in GDScript gets addressed by the Godot contributor gang. Other than that, we may still be able to get minor gains from optimizing the logic. The biggest thing would be interoping with C++, which appears to be a bit of an undocumented hassle.
  • Inspector rebuilding could maybe be optimized a little more too, by drawing things before they are really added.
  • Lazy loading would be useful in the inspector, if we can get it to work.
  • It might be smart to not draw path commands until they are on screen.
  • It might be possible to draw path commands (which are just a bunch of the same stylebox) more efficiently.
  • Polylines can maybe be optimized by grouping them up (they are currently one per command, but for example, a lot of consecutive lines can be made into a single polyline)
  • Multithreading; but for now, the only idea for multithreading I have is for the graphic - which can be split into smaller strips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant