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

Support int priorities in FastPriorityQueue #32

Open
BlueRaja opened this issue Jun 13, 2017 · 6 comments
Open

Support int priorities in FastPriorityQueue #32

BlueRaja opened this issue Jun 13, 2017 · 6 comments

Comments

@BlueRaja
Copy link
Owner

ints are nearly always faster than floats. Given how popular this library has become, and how many people are using it for non-pathfinding applications, it would be nice to have another queue that supports int for people who don't need float

@dougmill
Copy link
Contributor

dougmill commented Jul 9, 2017

I've actually switched to uint and ulong now. Signed values are inconvenient to work with sometimes, and I might need the extra range of 64 bits.

@BlueRaja
Copy link
Owner Author

BlueRaja commented Jul 10, 2017

Have you profiled this? My understanding is that uint is generally slower than int because the JIT isn't programmed to optimize it as aggressively (because it's not a CLS-compliant type), but I've never verified that myself.

In any case, using uint in APIs is highly discouraged because of CLS-compliance.

@dougmill
Copy link
Contributor

I just now profiled it, and the results were mixed. Some times uint was faster, some times int was faster. int was faster more often, but the margin was never big.

In any case, performance is not among my reasons for choosing unsigned types.

I'm certainly not suggesting that you support uint instead of int, but it might be useful (especially if you get code generation working for it) to support uint in addition to int.

@Bedivierre
Copy link

Maybe you can add another class with two generic types (node and priority value) and comparison delegate (or second type must support eq, lt and gt operations). This can be a stupid idea but though

@BlueRaja
Copy link
Owner Author

@Bedivierre This already exists, and is what SimplePriorityQueue is built off of. Unfortunately it's ~10-15% slower than FastPriorityQueue in my pathfinding benchmarks because the JIT is not able to properly optimize the comparison

@pajama
Copy link

pajama commented Sep 21, 2020

This would also help support determinism across hardware. Please consider using long to maintain precision.

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

No branches or pull requests

4 participants