metauni / metaboard

Multiplayer drawing boards for sharing knowledge in Roblox.
Mozilla Public License 2.0
29 stars 6 forks source link

High memory usage for world lines using RoundedParts #19

Closed dmurfet closed 2 years ago

dmurfet commented 2 years ago

The new RoundedParts world lines use roughly 3X the number of parts (since each line has two end cylinders) and it is therefore not surprising that the memory usage is increased. Here is a very rough experiment in TRS, using the 8-Fold board with the following contents:

Screen Shot 2021-12-28 at 9 34 57 pm

This board has 63 curves, Canvas has 5889 descendants. Subtracting the 63 curves and dividing by three (RoundedParts is on) we have 1942 lines (about 30 lines per curve).

This board is loaded as a persistent board and then 8 additional boards have the same contents. Here is the memory usage of TRS with and without RoundedParts, and with and without the 8-fold board (i.e. with it in ServerStorage) on my MacBook Pro approximately 10sec after loading into the server (the memory usage has stabilised).

Parts + no 8-fold board: {1150, 1140, 1146, 1130}Mb. avg = 1142Mb.
Parts + 8-fold board: {1235,1236,1236, 1260}Mb. avg = 1242Mb

Parts 8-fold board delta avg = 100Mb

RoundedParts + no 8-fold board: {1141, 1182, 1077, 1150}Mb. avg = 1138Mb.
RoundedParts + 8-fold board: {1333, 1377, 1383, 1380}Mb. avg = 1368Mb.

RoundedParts 8-fold board delta avg = 230Mb

Note that with ordinary Parts, we get an estimate of 100/9 ~ 11Mb per board so about 5.5Mb per 1000 lines. I've estimated with an old version of the boards 3000-5000 lines per board full of math in a "normal" talk, yielding an estimate of between 16-28Mb of memory usage per board, which is consistent with estimates of memory usage I have made before. But with rounded parts we are 2.3X that, around 37-65Mb per board.

Note that on low-resource devices (like my Macbook Air) memory usage and FPS hits from the large number of parts are the primary constraints on how many useful boards can be put in a world.

I think we cannot currently afford the memory usage of RoundedParts.

dmurfet commented 2 years ago

Just for fun, here is a full board with the Rounded Parts and 8-fold board in another part of the world. The memory usage here is 1775Mb, so one would estimate that this board is using about 400Mb on its own. With Parts instead of RoundedParts, this would be more like 174Mb.

Screen Shot 2021-12-28 at 9 04 26 pm copy
blinkybool commented 2 years ago

There is a threshold for gui lines which says when to start adding UICorners, because it doesn't make a difference at lower thicknesses. We could do the same with the world lines and tweak the threshold as desired

blinkybool commented 2 years ago

Also I'm curious how much better squared lines look if you just remove the initial length-zero line, which is an ugly unrotated square sticking out like a sore thumb.

Edit: I mean remove it during the first update on the drawing task, so that you can still draw a single dot.

dmurfet commented 2 years ago

Right, I agree that it is only for something like the upper 1/4 of the pen thicknesses that the Parts lines are unattractive and RoundedParts are much better. Those unrotated squares are the worst.

dmurfet commented 2 years ago

Fixed in v0.3.4 by moving back to Parts by default, but @billy-price has suggested a tradeoff where we use Parts for thin lines and RoundedParts for thick lines where Parts are ugliest. This SometimesRoundedParts is on the future roadmap but I'm closing this issue for now.