Skip to content
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

Why isn't TBQueue backed by an array? #65

Closed
konsumlamm opened this issue Sep 6, 2023 · 1 comment · Fixed by #70
Closed

Why isn't TBQueue backed by an array? #65

konsumlamm opened this issue Sep 6, 2023 · 1 comment · Fixed by #70

Comments

@konsumlamm
Copy link
Contributor

I expected TBQueue to be backed by an array, instead of a pair of lists. This would get rid of the amortization and should cause less allocations. Have there been any benchmarks showing that the current version is faster?

@bgamari
Copy link
Contributor

bgamari commented Sep 6, 2023

I suppose you want something like the following?

data TBQueue a
   = TBQueue
        (TArray a) -- a ring buffer of entries
        (TVar Int) -- Index of first queued entry
        (TVar Int)  -- Index of last queued entry

This sounds plausible to me.

The implementation is likely as it is since no one has tried improving it. Do try writing an array based implementation and benchmark it against the current list-based approach.

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 a pull request may close this issue.

2 participants