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

Optimized Tags #21

Open
kettek opened this issue Apr 27, 2023 · 2 comments
Open

Optimized Tags #21

kettek opened this issue Apr 27, 2023 · 2 comments

Comments

@kettek
Copy link

kettek commented Apr 27, 2023

In relation to PR #20, HasTags has ended up being one of the heaviest function calls in resolv. In terms of optimizing this, would it be possible to introduce using either:

  • A tag field like TagIDs with corresponding HasTagIDs and related funcs
  • Use generics to allow overriding the tag type
  • Some other smarter idea

I have no problems implementing either one myself. Generics would be more performant, but would introduce some complexity and potential API changes (might be able to "wrap" the second problem, but not certain yet).

@SolarLune
Copy link
Owner

SolarLune commented May 8, 2023

I think I'd like to avoid generics for now considering this is a relatively low-level API, where it should slot in to various build systems - I'd imagine most would have a recent enough version of Golang to allow this, but I'd like to be sure. How would generics make HasTags() faster? Is it because tag names are strings - would it be faster to use non-string tag types?

Also, is there another way on your side to optimize, perhaps by simply assigning an object to a particle collider's Data, and then checking that type?

@kettek
Copy link
Author

kettek commented May 9, 2023

String comparisons are slower than most other basic type comparisons. This compounds very quickly with 60 TPS and more than a handful of physics objects.

As far as ignoring the tags and using my own data structure for comparison, that would probably do the job just fine.

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

2 participants