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

Make encode return iterator instead of vec #2

Merged
merged 9 commits into from
Aug 12, 2022

Conversation

ackintosh
Copy link
Owner

@ackintosh ackintosh commented Aug 3, 2022

This branch is based on protobuf-support. Ref: prometheus#47

Build error below occurs:

error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
   --> src/encoding/proto.rs:199:6
    |
199 | impl<'a, N, A> EncodeMetric for Counter<N, A>
    |      ^^ unconstrained lifetime parameter
Build error:

error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
   --> src/encoding/proto.rs:199:6
    |
199 | impl<'a, N, A> EncodeMetric for Counter<N, A>
    |      ^^ unconstrained lifetime parameter
@ackintosh
Copy link
Owner Author

ackintosh commented Aug 3, 2022

I have compared the allocation count between this branch and the protobuf-support branch. But the allocation counts were equal. 🤔

Diffs of source code to check allocation count

The results of allocation count were equal 🤔

  • This branch -> 49
$ cargo test --lib encoding::proto::tests::encode_counter_family_with_prefix_with_label --all-features -- --show-output

successes:

---- encoding::proto::tests::encode_counter_family_with_prefix_with_label stdout ----
allocation: 49
  • Base branch -> 49
$ cargo test --lib encoding::proto::tests::encode_counter_family_with_prefix_with_label --all-features -- --show-output

successes:

---- encoding::proto::tests::encode_counter_family_with_prefix_with_label stdout ----
allocation: 49

I think, using into_iter() is why the allocation count is not reduced but I have no idea to return an iterator without into_iter().

@mxinden
Copy link

mxinden commented Aug 8, 2022

Thanks for experimenting here. I have a patch on top of this patch in the working. Will report back hopefully end of the day @ackintosh.

@mxinden
Copy link

mxinden commented Aug 8, 2022

I played around with this a bit. Thus far I don't have a full solution yet.

I think mxinden@2e04787 is a step forward, removing the into_iter calls on EncodeLabel implementations.

Still need to give it more thought though.

@ackintosh ackintosh merged commit d06b9f9 into protobuf-support Aug 12, 2022
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.

2 participants