-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Use 64 bit for world and system tick index #6651
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.
Only a cursory scan. Have not done a full review of the updated logic just yet.
You do not need #[inline(always)]
for most of these functions at this size. They're almost always guaranteed to inline even in debug mode.
Again, like #6327, this needs benchmarking to show the changes in performance here. This also has sizable overlap with #6547, which does something similar on the storage side. There's inevitably going to be merge conflicts between the two.
@@ -292,7 +292,7 @@ pub fn impl_param_set(_input: TokenStream) -> TokenStream { | |||
state: &'s mut Self, | |||
system_meta: &SystemMeta, | |||
world: &'w World, | |||
change_tick: u32, | |||
change_tick: Tick, |
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.
change_tick: Tick, | |
change_tick: #path::change_detection::Tick, |
/// than `SMALL_TICK_AGE_THRESHOLD` may return false positive. | ||
/// Which is acceptable tradeoff given that too old targets should | ||
/// not occur outside some edge cases. | ||
/// |
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.
/// |
} | ||
|
||
impl Tick { | ||
#[inline(always)] |
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.
#[inline(always)] |
pub struct Tick(pub NonZeroU64); | ||
|
||
impl Display for Tick { | ||
#[inline(always)] |
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.
#[inline(always)] |
} | ||
|
||
impl SmallTick { | ||
#[inline(always)] |
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.
#[inline(always)] |
/// not occur outside some edge cases. | ||
/// | ||
#[repr(transparent)] | ||
#[derive(Clone, Copy, Debug)] |
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.
#[derive(Clone, Copy, Debug)] | |
#[derive(Clone, Copy, Debug, Default)] |
impl Default for SmallTick { | ||
#[inline(always)] | ||
fn default() -> Self { | ||
SmallTick::new() | ||
} | ||
} |
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.
impl Default for SmallTick { | |
#[inline(always)] | |
fn default() -> Self { | |
SmallTick::new() | |
} | |
} |
impl Default for Tick { | ||
#[inline(always)] | ||
fn default() -> Self { | ||
Tick::new() | ||
} | ||
} |
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.
impl Default for Tick { | |
#[inline(always)] | |
fn default() -> Self { | |
Tick::new() | |
} | |
} |
} | ||
} | ||
|
||
// #[allow(clippy::useless_conversion)] |
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.
// #[allow(clippy::useless_conversion)] |
// Safety: | ||
// `TICK_BASE_VALUE` is nonzero |
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.
// Safety: | |
// `TICK_BASE_VALUE` is nonzero | |
// SAFETY: `TICK_BASE_VALUE` is nonzero |
#6547 has been merged. Can you rebase? I'll run a set of microbenchmarks for comparison. |
b92d7e0
to
fccdd3b
Compare
Backlog cleanup: closing this and alternate approach #6327 due to inactivity and no clear consensus. |
Objective
Changelog
Tick
andSmallTick
.Tick
now containsNonZeroU64
and never overflow in any reasonable time.SmallTick
are used to store tick index when component addition and last modification. It containsu32
with lower 32 bits ofTick
s 64 bit value.World
now usesTickCounter
that implements tick incrementing and necessary bookkeeping.Migration Guide
System
implementations have to switch to strongly typedTick
values and remove few methods.Pick one
This is alternative to #6327 where components get their ticks grown to 64 bit as well.
And #6327 doesn't introduce strongly typed ticks. Can be implemented though.