-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
Improve performance of 3D scenes by initializing all objects at once #3022
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me see how this behaves.
self._visible() | ||
self._draggable() | ||
@property | ||
def data(self) -> List[Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use a simple method, not a property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you think a method would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A method is easier to mock to facilitate unit testing.
Ok, I see your point. I'd like to stick with the property nonetheless, because mocking this property for a unit test is not a concert at the moment and a property feels more idiomatic in this case.
This performs great! There is almost no delay for the shape 50x50 and maybe half-a-second delay for the 100x100 field. Does this PR improve the updates too? |
A method is easier to mock to facilitate unit testing.
…On Mon, May 6, 2024, 11:36 Falko Schindler ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In nicegui/elements/scene_object3d.py
<#3022 (comment)>:
> @@ -42,16 +42,19 @@ def with_name(self, name: str) -> Self:
self._name()
return self
- def send(self) -> None:
- """Send the object to the client."""
- self._create()
- self._name()
- self._material()
- self._move()
- self._rotate()
- self._scale()
- self._visible()
- self._draggable()
+ @Property
+ def data(self) -> List[Any]:
Why do you think a method would be better?
—
Reply to this email directly, view it on GitHub
<#3022 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAKSHBAUSYZPIVSKJXPPQ3ZA5FK5AVCNFSM6AAAAABHHVNK6GVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDANBQGM3DQOBUGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Yes, this is mergeable already. Thanks!
…On Mon, May 6, 2024, 11:49 Falko Schindler ***@***.***> wrote:
Does this PR improve the updates too?
@kovalp <https://github.com/kovalp> No, this PR only improves the object
initialization. Updates will be tackled by PR #3017
<#3017> or other improvements.
Anyway, I think we should merge this PR because it greatly improves the
ui.scene element.
—
Reply to this email directly, view it on GitHub
<#3022 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAKSHA4W5TOR3RZW2E2J23ZA5G33AVCNFSM6AAAAABHHVNK6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJVGU4TANJRGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Is this improvement effective for existing scenes or only for the newly created scenes? |
@kovalp It should also improve the performance when creating new scenes dynamically, e.g. on button click. Every scene sends an "init" event to the server which responds with an "init_objects" message containing all 3D object information. Thus it benefits from the new condensed format. |
Ok, but what about existing scene objects?
I guess whenever I have time I will try to figure out it myself.
…On Tue, May 7, 2024, 22:27 Falko Schindler ***@***.***> wrote:
@kovalp <https://github.com/kovalp> It should also improve the
performance when creating new scenes dynamically, e.g. on button click.
Every scene sends an "init" event to the server which responds with an
"init_objects" message containing all 3D object information. Thus it
benefits from the new condensed format.
—
Reply to this email directly, view it on GitHub
<#3022 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAKSHAT7XFQ4F3AJB7CVODZBE2MXAVCNFSM6AAAAABHHVNK6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJZGI2DSMBTGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
As I said in #3022 (comment), updates to existing objects will be addressed by PR #3017 and other improvements. |
I am looking forward to the acceleration of updates.
I will try to formulate my question in form of a code snippet later.
Maybe I am using the objects not in an optimal way.
…On Tue, May 7, 2024, 22:39 Falko Schindler ***@***.***> wrote:
As I said in #3022 (comment)
<#3022 (comment)>,
updates to existing objects will be addressed by PR #3017
<#3017> and other improvements.
—
Reply to this email directly, view it on GitHub
<#3022 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAKSHFPJAHWWGMM7FOL2DDZBE3ZJAVCNFSM6AAAAABHHVNK6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJZGI3DSNZWG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This PR experiments with sending a single initialization message with all 3D objects at once to reduce the time for creating complex 3D scenes like discussed in #3009.
A demo with 10,000 boxes runs even faster than with PR #3017:
This approach not only bundles multiple commands into one message, it also cuts the payload significantly by focusing on the actual data rather the sending loads of overhead for every attribute. It could be combined with PR #3017 to improve the speed for updating existing objects.