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

Bugfix: Remove unintended view distance limit #387

Merged
merged 1 commit into from
May 1, 2024

Conversation

patowen
Copy link
Collaborator

@patowen patowen commented Apr 30, 2024

The math::distance normalizes the input vectors as part of its computation, which results in a loss of precision when an input vector is large.

For situations where that matters, such as in traversal.rs, we use math::mip instead of math::distance. Note that, when the input vectors are already pre-normalized, the distance formula simplifies to (-mip(a, b)).acosh(), which is likely small enough to not need its own function.

Note that the actual bug this fixes is that distance computations in traversal::ensure_nearby were resulting in NaN, which caused the loop to continue on forever, continuing to expand out the graph until running out of memory.

@patowen patowen requested a review from Ralith April 30, 2024 23:58
Copy link
Owner

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

This makes me really want the stronger math types we've discussed before, so we can have distance take pre-normalized inputs and let callers normalize or not as needed.

@Ralith
Copy link
Owner

Ralith commented May 1, 2024

the actual bug this fixes is that distance computations in traversal::ensure_nearby were resulting in NaN

Should we add an assert or a unit test to catch this more easily in the future?

@patowen
Copy link
Collaborator Author

patowen commented May 1, 2024

the actual bug this fixes is that distance computations in traversal::ensure_nearby were resulting in NaN

Should we add an assert or a unit test to catch this more easily in the future?

Perhaps, although that is nontrivial. An assert could be refactored away, and a unit test would cause the tests to exit non-gracefully if they fail (and potentially make GitHub mad at us for hogging a lot of RAM).

That being said, I think I agree with going the unit test route. That will cause such regressions to reliably be caught in CI, even if the way they're caught is not ideal (and I assume GitHub is smart about the resource pool allocations).

@patowen patowen enabled auto-merge (rebase) May 1, 2024 00:34
@patowen patowen disabled auto-merge May 1, 2024 00:36
@patowen patowen enabled auto-merge (rebase) May 1, 2024 00:47
@patowen patowen merged commit c38184c into Ralith:master May 1, 2024
6 checks passed
@patowen patowen deleted the view-distance-bugfix branch May 1, 2024 01:00
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