bevyengine / bevy-website

The source files for the official Bevy website
https://bevyengine.org
MIT License
192 stars 330 forks source link

0.13 migration: Add section for entity niche optimization #1029

Open rparrett opened 6 months ago

rparrett commented 6 months ago

Migration guide generator didn't catch

https://github.com/bevyengine/bevy/pull/9907

Because it's unlabeled and the formatting of the description isn't correct.

Unfortunately, the migration section in the description doesn't actually offer any advice for migration, so we'll need to write some.

I'm not actually sure how people can migrate this, other than recreating their scenes. It might be possible to create a small program/script/abuse awk to bit-twiddle entity ids in scene files.

See https://github.com/bevyengine/bevy/pull/11289 for an example of fixing a scene file.

More context: https://discord.com/channels/691052431525675048/1209244908372627507

Testare commented 6 months ago

If you can find all places where there is an entity ID in the scene file, you can add 2^32 to the number (4294967296) or "10000000000" if you want to make it easier to keep different entities distinct to readers. If you have an exceptionally large file or you can't identify all places where you are serializing entities... Then I think you're up a creek w/o a paddle.

In any case, as we are trying to move towards better scene files, I think that having to use such huge numbers for entities is a serious step back =/ I understand using NonZeroU32 for generation helps memory optimization, and using it for generation instead of index was less difficult, I think we need to have some way to represent entities in scene files with numbers at least as low as "1," especially since these entities are intended to be mapped to real entities later.

Testare commented 6 months ago

Also while we're updating the migration guide, the migration guide entry for updating the serialization of Name component seems to be incorrect.

rparrett commented 6 months ago

@irate-devil

What did you mean by

Yep. This entire way of serializing entities is terribly flawed, but the example exists as-is so it's better if it actually works. Certified jank :')

In the issue linked above, and would you have anything to add to a migration guide entry for this PR related to that?

rparrett commented 6 months ago

Also while we're updating the migration guide, the migration guide entry for updating the serialization of Name component seems to be incorrect.

That's a confusing one. Opened a separate issue: https://github.com/bevyengine/bevy-website/issues/1030

notverymoe commented 6 months ago

Talking on discord, there's some hesitancy to offer migration tools. It seems like the migration guide's entry should read something along the lines of "Recreate your scenes, sorry. You can try to manually offset the ids if you want". If one were to create an automatic tool, the easiest path is probably to patch bevy (for the tool specifically) to modify the Entity deserialize to increment the generation, deserialize the scene, reserialize, save - should cover most basic cases. There was a brief mention that we should considering looking at some alternative to Entity as an identifier in scenes/networking, since the internals of Entity are an implementation detail and inherently kinda volatile, nothing set in motion from that, but yeah.