-
Notifications
You must be signed in to change notification settings - Fork 266
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
New queue implementation #522
base: master
Are you sure you want to change the base?
New queue implementation #522
Conversation
Update the integer_vector_ptr and string_ptr packages to support the changes necessary for a new implementation of queue_t. both packages: - Implement a stack to reuse the ref indices of deallocated pointers - Add vec_t and va_t aliases - Improve consistency in format and substance between the two packages integer_vector_ptr_pkg: - Change the drop parameter in resize to a rotate parameter. This supports reallocating a circular buffer. This parameter is only necessary to support the implementation of queue_t, so there is no need to implement the functionality for string_ptr as well. string_ptr_pkg: - Remove support for the drop parameter when resizing a string_ptr. The only use of it in the entire code base was to support the old implementation of queue_t.
Remove assumption of string range for get_range function in codec_pkg. Add subprograms for encoding and decoding integer_array_t
Previously, queue_t was implemented as a single-string, linear buffer. Update queue_t to use a circular buffer of integers, where each integer represents a string_ptr. Each item contained within the queue is represented by a string_ptr, where the first character is a type mark and the remaining characters are the encoded form of the item.
Add a procedure to deallocate a queue. Move all access to queue internals until after null_queue assertions
Update the com library to support the new implementation of queue_t. Remove all deprecated com library code. Change envelope.message to use msg_t rather than message_t. Also remove use of integer_vector_ptr, string_ptr and queue pools. Updates to the respective packages removes the need to recycle indices with the pool packages.
I've updated The acceptance tests ran fine on my machine. I'm hoping for no surprises. This should be pretty close to complete. |
I just want to be clear. There are some backwards incompatible changes here:
Is this enough to cause a major version increment? If so, perhaps I should continue working on #521 and we can commit everything at once? |
@bradleyharden I haven't looked at the commit yet but when it comes to breaking backward compatibility we prefer keeping the old APIs, if not too inconvenient, as a deprecated approach for a while before removing them. I'm not sure how inconvenient it would be in this case. |
Keeping I can keep the |
This caught my attention while revewing the changes. I'd expect
IMHO, the new major version should include:
I don't think we need to worry about pushing it too soon. |
@bradleyharden, I didn't see your last comment.
If keeping In integer_vector, is
Actually, I believe this is how deprecation should be managed. This would allow to merge this PR without introducing incompatibilities, wouldn't it? |
@umarcor, I suspect that drop was only ever added to
In the new version, I think the solution will be to support both. |
If this PR is fully backwards compatible, then we won't need to consider a major revision yet. @LarsAsplund, do you have any idea when you will get a chance to review? I have pieces of #521 complete, and I would like to keep working on it, but I'm hesitant to do so without this PR accepted. It's a foundation for other changes. |
If @LarsAsplund and/or @kraigher can confirm this, I believe that drop can be removed. Nonetheless, it would probably had beeen named
I thinks it is important to have at least a sentence or a very simple diagram explaining it. I understand it as 'read
The point is that this can be more painful for users than just knowing that the implementation of Is it worth adding this complexity in the source (increasing the effort of users that review the modifications) if it will be dropped in the next release?
I think that this 'core' modifications are reviewed by @kraigher and not only by @LarsAsplund. In this sense, the issue that lead to #507 was started in april and the issue itself is pending since almost a month ago; it conflicts with this PR. I believe we should discuss how are we going to handle the merges, before rushing to it. |
To my knowledge, there is no existing documentation for the That being said, lack of documentation is still a fair criticism. I'll explain
I think you're misunderstanding my proposed solution. The implementation of procedure resize(
ptr : ptr_t;
length : natural;
drop : natural := 0;
rotate : natural := 0); Current calls of resize(ptr, 2**16, 125); or this resize(ptr, 2**16, drop => 125); In either case, my new function will accept the existing call. In my new function, I will check if either This change to the PR would restore backwards compatibility. All existing code that uses |
I was not trying to criticize, but to sincerely ask a question the answer to which I was not sure about; even after looking at the code. That's why I tried to be proactive by proposing a kind of quoted description: 'read n number of elements from the queue and drop them'. Regarding 'drop', I know it does discard the elements from the beginning, so I can give a valid answer to any other user asking about it. I just want to understand 'rotate' too.
Thanks. Hence, given a buffer of eight positions:
I understand how this works when no resizing is involved. Moreover, I wonder if it makes sense to also provide I also understand why this is used in e.g. I am not sure about what will happen if
Now that I understand the differences, I think that 'drop' can be a useful feature to have in a queue. But it should probably be unrelated to Use case: a producer is saving packets of 16 elements in the queue, where the first element is used by a consumer to decide whether to process or ignore it. resize(queue, size, drop => 15);
unsafe_pop(queue); or unsafe_pop(queue, drop => 15); or drop(queue, 15);
unsafe_pop(queue); would allow to skip a packet and get the first item of the next packet.
I did the same for external modes.
What about this? procedure resize (
ref : natural;
length : natural;
drop : natural := 0;
rotate : natural := 0;
value : val_t := 0
) is
variable old_ptr : va_t := storage(ref);
variable new_ptr : va_t := new vec_t'(0 to length - 1 => value);
variable min_length : natural := old_ptr'length-drop;
constant offset : natural := rotate + drop;
begin
-- ??? min_length := minimum(length, min_length);
if length < min_length then
min_length := length;
end if;
for i in 0 to min_length - 1 loop
new_ptr(i) := old_ptr((offset + i) mod old_ptr'length);
end loop;
storage(ref) := new_ptr;
deallocate(old_ptr);
end; |
@umarcor, you seem to be confusing the queue and the underlying data storage ( |
Update the pool packages to be compatible with the new implementation of queue_t. Remove usage of the pool packages through VUnit. The pool packages are made obsolete by changes to the integer_vector_ptr and string_ptr types.
Restore the drop parameter to the resize procedures of string_ptr_t and integer_vector_ptr_t. Improve error checking through the two sets of pointer packages.
861476b
to
8c69104
Compare
@LarsAsplund, I restored the The current string of commits follows the discussion in this PR. If you would like, I can rewrite the history to make it easier to follow the changes from Also, before the final merge, I will need to rebase it onto the current master. I'm only one commit behind right now, but I don't see any sense in rebasing until you're ready to actually pull. |
Thinking more about queue pools made me realize I had a bug in Once again, this series of commits reflects events as they occurred. If you would rather I reformat the commits to better show the changes relative to |
This is a first step toward #521. Introducing a new implementation of
queue_t
will allow me to create a new, generalizedelement_t
oritem_t
that can represent any VHDL value. Performance tests indicate that this implementation is faster than the current implementation.I'm creating a draft PR for now, so that you can start to review the changes. I tried to group the changes into 3 reasonable commits. I still need to update
com
to use support the newqueue_pkg
before this will be ready to pull.