Skip to content

Changes advance to advance on time to support large intervals - #8

Open
TimEvens wants to merge 2 commits into
mainfrom
adv-change
Open

Changes advance to advance on time to support large intervals#8
TimEvens wants to merge 2 commits into
mainfrom
adv-change

Conversation

@TimEvens

Copy link
Copy Markdown
Collaborator

No description provided.

@TimEvens
TimEvens requested a review from GhostofCookie June 12, 2026 22:47
FORCE_INLINE void clear() noexcept
{
if (_queue.empty()) {
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seemed right to return early

for (std::size_t i = 0; i < intervals_elapsed; ++i) {
bucket_type& bucket = _buckets[get_future_bucket_index(i)];
bucket.clear();
bucket.shrink_to_fit();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to reclaim space in the bucket, otherwise we retain the allocated space.

[[nodiscard]] FORCE_INLINE constexpr index_type bucket_count() const noexcept
{
// The spare bucket prevents max-duration TTLs pushed mid-interval from being cleared early.
return (_duration / _interval) + 1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could also potentially crash since now you could in theory get a future bucket index that is == to the size of the vector, which would be a bad access.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, but buckets are a map. Right. Hmm... still not sure about this.

Comment thread include/timeq/time_queue.h
}

if (delta >= _duration) {
const auto intervals_elapsed = delta / _interval;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const auto intervals_elapsed = delta / _interval;
const auto buckets_elapsed = delta / _interval;

* MAke another version of the timequeue that doesn't use buckets.

* Change to fast_time_queue.

* Improve benchmarks.

* Remove queue clear duration division by 5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants