bevy/crates
shuo 11a7ff2645 use bevy_utils::HashMap for better performance. TypeId is predefined … (#7642)
…u64, so hash safety is not a concern

# Objective

- While reading the code, just noticed the BundleInfo's HashMap is std::collections::HashMap, which uses a slow but safe hasher.

## Solution

- Use bevy_utils::HashMap instead

benchmark diff (I run several times in a linux box, the perf improvement is consistent, though numbers varies from time to time, I paste my last run result here):

``` bash
cargo bench -- spawn
   Compiling bevy_ecs v0.9.0 (/home/lishuo/developer/pr/bevy/crates/bevy_ecs)
   Compiling bevy_app v0.9.0 (/home/lishuo/developer/pr/bevy/crates/bevy_app)
   Compiling benches v0.1.0 (/home/lishuo/developer/pr/bevy/benches)
    Finished bench [optimized] target(s) in 1m 17s
     Running benches/bevy_ecs/change_detection.rs (/home/lishuo/developer/pr/bevy/benches/target/release/deps/change_detection-86c5445d0dc34529)
Gnuplot not found, using plotters backend
     Running benches/bevy_ecs/benches.rs (/home/lishuo/developer/pr/bevy/benches/target/release/deps/ecs-e49b3abe80bfd8c0)
Gnuplot not found, using plotters backend
spawn_commands/2000_entities
                        time:   [153.94 µs 159.19 µs 164.37 µs]
                        change: [-14.706% -11.050% -6.9633%] (p = 0.00 < 0.05)
                        Performance has improved.
spawn_commands/4000_entities
                        time:   [328.77 µs 339.11 µs 349.11 µs]
                        change: [-7.6331% -3.9932% +0.0487%] (p = 0.06 > 0.05)
                        No change in performance detected.
spawn_commands/6000_entities
                        time:   [445.01 µs 461.29 µs 477.36 µs]
                        change: [-16.639% -13.358% -10.006%] (p = 0.00 < 0.05)
                        Performance has improved.
spawn_commands/8000_entities
                        time:   [657.94 µs 677.71 µs 696.95 µs]
                        change: [-8.8708% -5.2591% -1.6847%] (p = 0.01 < 0.05)
                        Performance has improved.

get_or_spawn/individual time:   [452.02 µs 466.70 µs 482.07 µs]
                        change: [-17.218% -14.041% -10.728%] (p = 0.00 < 0.05)
                        Performance has improved.
get_or_spawn/batched    time:   [291.12 µs 301.12 µs 311.31 µs]
                        change: [-12.281% -8.9163% -5.3660%] (p = 0.00 < 0.05)
                        Performance has improved.

spawn_world/1_entities  time:   [81.668 ns 84.284 ns 86.860 ns]
                        change: [-12.251% -6.7872% -1.5402%] (p = 0.02 < 0.05)
                        Performance has improved.
spawn_world/10_entities time:   [789.78 ns 821.96 ns 851.95 ns]
                        change: [-19.738% -14.186% -8.0733%] (p = 0.00 < 0.05)
                        Performance has improved.
spawn_world/100_entities
                        time:   [7.9906 µs 8.2449 µs 8.5013 µs]
                        change: [-12.417% -6.6837% -0.8766%] (p = 0.02 < 0.05)
                        Change within noise threshold.
spawn_world/1000_entities
                        time:   [81.602 µs 84.161 µs 86.833 µs]
                        change: [-13.656% -8.6520% -3.0491%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
Benchmarking spawn_world/10000_entities: Warming up for 500.00 ms
Warning: Unable to complete 100 samples in 4.0s. You may wish to increase target time to 4.0s, enable flat sampling, or reduce sample count to 70.
spawn_world/10000_entities
                        time:   [813.02 µs 839.76 µs 865.41 µs]
                        change: [-12.133% -6.1970% -0.2302%] (p = 0.05 < 0.05)
                        Change within noise threshold.
```

---

## Changelog

> This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section.

- use bevy_utils::HashMap for Bundles::bundle_ids

## Migration Guide

> This section is optional. If there are no breaking changes, you can delete this section.

- Not a breaking change, hashmap is internal impl.
2023-02-15 04:19:26 +00:00
..
bevy_animation Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_app Cleanup system sets called labels (#7678) 2023-02-14 21:46:07 +00:00
bevy_asset Cleanup system sets called labels (#7678) 2023-02-14 21:46:07 +00:00
bevy_audio IOS, Android... same thing (#7493) 2023-02-06 18:08:49 +00:00
bevy_core Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_core_pipeline implement Reflect for Fxaa (#7527) 2023-02-13 21:55:28 +00:00
bevy_derive update winit to 0.28 (#7480) 2023-02-03 16:41:39 +00:00
bevy_diagnostic Rename schedule v3 to schedule (#7519) 2023-02-06 18:44:40 +00:00
bevy_dylib Rename dynamic feature (#7340) 2023-01-23 14:28:00 +00:00
bevy_dynamic_plugin Adapt path type of dynamically_load_plugin (#6734) 2022-12-05 23:39:43 +00:00
bevy_ecs use bevy_utils::HashMap for better performance. TypeId is predefined … (#7642) 2023-02-15 04:19:26 +00:00
bevy_ecs_compile_fail_tests Fix clippy lints and failed test with Rust 1.66 (#6945) 2022-12-15 18:05:15 +00:00
bevy_encase_derive add helper for macro to get either bevy::x or bevy_x depending on how it was imported (#7164) 2023-01-11 21:12:02 +00:00
bevy_gilrs Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_gltf Add extras field to GltfNode (#6973) 2023-02-13 17:56:36 +00:00
bevy_hierarchy Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_input Rename schedule v3 to schedule (#7519) 2023-02-06 18:44:40 +00:00
bevy_internal Introduce detailed_trace macro, use in TrackedRenderPass (#7639) 2023-02-13 18:20:27 +00:00
bevy_log Fix suppression of all console logs when trace_tracy is enabled (#6955) 2022-12-20 23:45:43 +00:00
bevy_macro_utils Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_math Improve code/comments for Ray::intersect_plane and its tests (#6823) 2022-12-05 22:49:06 +00:00
bevy_mikktspace Release 0.9.0 (#6568) 2022-11-12 20:01:29 +00:00
bevy_pbr Cleanup system sets called labels (#7678) 2023-02-14 21:46:07 +00:00
bevy_ptr Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
bevy_reflect bevy_reflect: Decouple List and Array traits (#7467) 2023-02-13 21:07:53 +00:00
bevy_reflect_compile_fail_tests Enable deriving Reflect on structs with generic types (#7364) 2023-01-28 00:12:06 +00:00
bevy_render Cleanup system sets called labels (#7678) 2023-02-14 21:46:07 +00:00
bevy_scene Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_sprite Cleanup system sets called labels (#7678) 2023-02-14 21:46:07 +00:00
bevy_tasks improve safety comment in scope function (#7534) 2023-02-13 18:20:17 +00:00
bevy_text Fix Window feedback loop between the OS and Bevy (#7517) 2023-02-07 14:18:13 +00:00
bevy_time Rename schedule v3 to schedule (#7519) 2023-02-06 18:44:40 +00:00
bevy_transform Cleanup system sets called labels (#7678) 2023-02-14 21:46:07 +00:00
bevy_ui Changes in the size of a text node should trigger recomputation of its text (#7674) 2023-02-14 14:46:28 +00:00
bevy_utils Introduce detailed_trace macro, use in TrackedRenderPass (#7639) 2023-02-13 18:20:27 +00:00
bevy_window Fix closing window does not exit app in desktop_app mode (#7628) 2023-02-13 19:15:24 +00:00
bevy_winit create window as soon as possible (#7668) 2023-02-14 15:08:04 +00:00