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

allow forward declaration of values held by reader #208

Merged
merged 1 commit into from
Sep 15, 2024

Conversation

TheCoconutChef
Copy link
Contributor

This commit enables the forward declaration of a type held by a reader without any new memory allocation or virtual methods. This is achieved by creating a new class -- observable_reader_node -- in the reader_node hierarchy which acts as a view for the type held by reader_node.

Performance Impact

Ad-hoc benchmarks (i.e. not in commit) were performed with nanobench. (https://nanobench.ankerl.com/index.html)

Compared to baseline, the impact on a reader get method was non-existent. The same was true for map. The impact on watch seemingly ranged from indiscernible to rather small, i.e. in the order of 0.5-1.5%, although why there even is an impact isn't clear.

Downsides and Limitations

  1. If it matters, the protected keyword has now been introduced within the reader node class hierarchy. This is because the link method and the observers access method had to be moved in observable_reader_node to avoid virtual method declaration.
  2. While the values held by a reader are now fwd declarable, those held by a cursor are not. This arguably introduces an inconsistency in the API.

This commit enables the forward declaration of a type held by a reader
without any new memory allocation or virtual methods. This is achieved
by creating a new class  -- observable_reader_node -- in the reader_node
hierarchy which acts as a view for the type held by reader_node.

Performance Impact

Ad-hoc benchmarks (i.e. not in commit) were performed with nanobench.
(https://nanobench.ankerl.com/index.html)

Compared to baseline, the impact on a reader get method was
non-existent. The same was true for map. The impact on watch seemingly
ranged from indiscernible to rather small, i.e. in the order of
0.5-1.5%, although why there even is an impact isn't clear.

Downsides and Limitations

1. If it matters, the protected keyword has now been introduced within
   the reader node class hierarchy. This is because the link method and
   the observers access method had to be moved in observable_reader_node
   to avoid virtual method declaration.
2. While the values held by a reader are now fwd declarable, those held
   by a cursor are not. This arguably introduces an inconsistency in the
   API.
Copy link
Owner

@arximboldi arximboldi left a comment

Choose a reason for hiding this comment

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

This is great, thank you!

@arximboldi
Copy link
Owner

I agree that point 2. is somewhat an inconsistency, but we can work on this later.

@arximboldi arximboldi merged commit 6c6f868 into arximboldi:master Sep 15, 2024
6 of 7 checks passed
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