bevy/crates
James Liu 9eb69282ef Directly copy moved Table components to the target location (#5056)
# Objective
Speed up entity moves between tables by reducing the number of copies conducted. Currently three separate copies are conducted: `src[index] -> swap scratch`, `src[last] -> src[index]`, and `swap scratch -> dst[target]`. The first and last copies can be merged by directly using the copy `src[index] -> dst[target]`, which can save quite some time if the component(s) in question are large.

## Solution
This PR does the  following:

 - Adds `BlobVec::swap_remove_unchecked(usize, PtrMut<'_>)`, which is identical to `swap_remove_and_forget_unchecked`, but skips the `swap_scratch` and directly copies the component into the provided `PtrMut<'_>`.
 - Build `Column::initialize_from_unchecked(&mut Column, usize, usize)` on top of it, which uses the above to directly initialize a row from another column. 
 - Update most of the table move APIs to use `initialize_from_unchecked` instead of a combination of `swap_remove_and_forget_unchecked` and `initialize`.

This is an alternative, though orthogonal, approach to achieve the same performance gains as seen in #4853. This (hopefully) shouldn't run into the same Miri limitations that said PR currently does.  After this PR, `swap_remove_and_forget_unchecked` is still in use for Resources and swap_scratch likely still should be removed, so #4853 still has use, even if this PR is merged.

## Performance
TODO: Microbenchmark

This PR shows similar improvements to commands that add or remove table components that result in a table move. When tested on `many_cubes sphere`, some of the more command heavy systems saw notable improvements. In particular, `prepare_uniform_components<T>`, this saw a reduction in time from 1.35ms to 1.13ms (a 16.3% improvement) on my local machine, a similar if not slightly better gain than what #4853 showed [here](https://github.com/bevyengine/bevy/pull/4853#issuecomment-1159346106).

![image](https://user-images.githubusercontent.com/3137680/174570088-1c4c6fd7-3215-478c-9eb7-8bd9fe486b32.png)

The command heavy `Extract` stage also saw a smaller overall improvement:

![image](https://user-images.githubusercontent.com/3137680/174572261-8a48f004-ab9f-4cb2-b304-a882b6d78065.png)
---

## Changelog
Added: `BlobVec::swap_remove_unchecked`.
Added: `Column::initialize_from_unchecked`.
2022-06-27 16:52:26 +00:00
..
bevy_animation Clippy improvements (#4665) 2022-05-31 01:38:07 +00:00
bevy_app Add global init and get accessors for all newtyped TaskPools (#2250) 2022-06-09 02:43:24 +00:00
bevy_asset Add reload_asset method to AssetServer. (#5106) 2022-06-26 21:45:04 +00:00
bevy_audio Clippy improvements (#4665) 2022-05-31 01:38:07 +00:00
bevy_core Add global init and get accessors for all newtyped TaskPools (#2250) 2022-06-09 02:43:24 +00:00
bevy_core_pipeline Allow unbatched render phases to use unstable sorts (#5049) 2022-06-23 10:52:49 +00:00
bevy_derive Decouple some dependencies (#3886) 2022-04-27 19:08:11 +00:00
bevy_diagnostic Cleanups in diagnostics (#3871) 2022-06-20 17:02:25 +00:00
bevy_dylib Bump Bevy to 0.8.0-dev (#4505) 2022-04-17 23:04:52 +00:00
bevy_dynamic_plugin Bump Bevy to 0.8.0-dev (#4505) 2022-04-17 23:04:52 +00:00
bevy_ecs Directly copy moved Table components to the target location (#5056) 2022-06-27 16:52:26 +00:00
bevy_ecs_compile_fail_tests Replace ReadOnlyFetch with ReadOnlyWorldQuery (#4626) 2022-06-13 23:35:54 +00:00
bevy_encase_derive Migrate to encase from crevice (#4339) 2022-05-18 21:09:21 +00:00
bevy_gilrs Update gilrs to v0.9 (#4848) 2022-05-30 17:26:23 +00:00
bevy_gltf gltf: do not import IoTaskPool in wasm (#5038) 2022-06-20 10:32:44 +00:00
bevy_hierarchy add a SceneBundle to spawn a scene (#2424) 2022-06-09 20:34:09 +00:00
bevy_input Update MouseMotion and CursorMoved docs (#5090) 2022-06-26 13:40:43 +00:00
bevy_internal enable optional dependencies to stay optional (#5023) 2022-06-20 10:32:43 +00:00
bevy_log bevy_log: upgrade to tracing-tracy 0.10.0 (#4991) 2022-06-13 22:40:29 +00:00
bevy_macro_utils bevy_reflect_derive: Tidying up the code (#4712) 2022-05-12 19:43:23 +00:00
bevy_math Document bevy_math (#4591) 2022-04-26 18:23:29 +00:00
bevy_mikktspace Generate vertex tangents using mikktspace (#3872) 2022-05-31 22:53:54 +00:00
bevy_pbr Separate PBR and tone mapping into 2 functions (#5078) 2022-06-26 00:00:23 +00:00
bevy_ptr Clippy improvements (#4665) 2022-05-31 01:38:07 +00:00
bevy_reflect Make Reflect safe to implement (#5010) 2022-06-27 16:52:25 +00:00
bevy_render Default image sampler doc fix (#5047) 2022-06-26 02:26:29 +00:00
bevy_scene Fix ron deprecation (#5021) 2022-06-15 19:18:53 +00:00
bevy_sprite Add reusable shader functions for transforming position/normal/tangent (#4901) 2022-06-14 00:32:33 +00:00
bevy_tasks Miri can set thread names now (#5108) 2022-06-26 21:28:00 +00:00
bevy_text Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
bevy_time Split time functionality into bevy_time (#4187) 2022-05-26 00:27:18 +00:00
bevy_transform change panicking test to not run on global task pool (#4998) 2022-06-20 17:35:55 +00:00
bevy_ui depend on dioxus(and bevy)-maintained fork of stretch (taffy) (#4716) 2022-06-21 22:57:59 +00:00
bevy_utils update hashbrown to 0.12 (#5035) 2022-06-17 22:34:58 +00:00
bevy_window Update MouseMotion and CursorMoved docs (#5090) 2022-06-26 13:40:43 +00:00
bevy_winit Fix wasm examples (#4967) 2022-06-11 20:10:13 +00:00