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

Exceptions are expensive and may be avoided for lookup misses #60

Closed
yaauie opened this issue Dec 16, 2019 · 0 comments · Fixed by #61
Closed

Exceptions are expensive and may be avoided for lookup misses #60

yaauie opened this issue Dec 16, 2019 · 0 comments · Fixed by #61
Assignees

Comments

@yaauie
Copy link
Contributor

yaauie commented Dec 16, 2019

The Resolv APIs this plugin uses throw exceptions when there is no name associated with an address (or vice versa; read: lookup miss, not lookup failure), and our implmentation relies on these costly exceptions for flow control (Resolv#getname(address), Resolv#getaddress(name)).

But Resolv also provides public APIs that treat a lookup misses as non-exceptional (Resolv#each_name(address,&block), Resolv#each_address(name,&block), which still handle lookup failure exceptionally). I believe that we should look into using these APIs, and will need to modify our implementation to handle these lookup misses in the normal (non-exceptional) flow control.

@yaauie yaauie self-assigned this Dec 16, 2019
yaauie added a commit to yaauie/logstash-filter-dns that referenced this issue Jan 3, 2020
yaauie added a commit to yaauie/logstash-filter-dns that referenced this issue Jan 4, 2020
By using `Resolv#each_name` and `Resolv#each_address`, and returning the first
match from the block or returning nil if no matches were found, we can mirror
the behavior of `Resolv#getname` and `Resolv#getaddress` without raising
exceptions on lookup misses.

Adjusts flow-control to handle a nil return value as a lookup miss instead of
relying on exception handlers.

Resolves: logstash-plugins#60
@yaauie yaauie closed this as completed in #61 Jan 6, 2020
yaauie added a commit that referenced this issue Jan 6, 2020
By using `Resolv#each_name` and `Resolv#each_address`, and returning the first
match from the block or returning nil if no matches were found, we can mirror
the behavior of `Resolv#getname` and `Resolv#getaddress` without raising
exceptions on lookup misses.

Adjusts flow-control to handle a nil return value as a lookup miss instead of
relying on exception handlers.

Resolves: #60
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.

1 participant