-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use QLatin1String
for ConfigKey
#11983
Comments
Yes, a latin 1 string is enough. On the other Hände we can improve the even more of we have the string only one in the text segment of our source. The "reference" QString lives current on the heap in s_qCOHash. So I would start by refactor this. Instead of a QHash it may base on a
Than we need only to use that handle only in the engine. What do you think? |
In short: Get rid of the owning QHash first. |
Mhmm, I'm not sure how feasible that is then. Whats the problem with |
A global or static constexpr lives in the text segment and is always available. The address of it may change only during program starts. |
Yes, but in order to assume that in the QHash, we need to make sure to write an interface that enforces that. Otherwise someone will come along and will add something to that table that will become dangling sooner or later. In Rust this would be easy (just use a Also, this will essentially force the hashtable to be computed at compile time (at least it would make it possible, could even be quite efficient with a precomputed perfect hash). However, there are other components in Mixxx that currently depend on being able to create CO's dynamically (samplers being crated lazily, skins using CO's for skin-specific state, etc). So I don't know how feasible this would be. The alternative would be to convert |
With Implicit sharing and const references everywhere, I think we are already close to optimum when we consider to avoid copies. I am concerned to reach this state with std::string easy. On one hand this will save us from the double length of the strings only relevant at initialization. But we have "some" time during startup for that. This is a major benefit during runtime that likely has an effect. A ChannelHandleAndGroup solution for all. Let's do the work for that and the initialization speed up comes for free. |
Please elaborate. |
I think we can do it somehow like this:
This way we can use "&key1[0]" as handle for comparison later.
Yes, the dynamic filling will remain. It would be nice to find a solution that supports a constexpr hashes like outlined above. Extenal code like mappings and skins can look up the strings at runtime or may even compute the hash at compile time. Do we have hash collisions? If we assert that we do not have them, only the Hash would be sufficient for a lookup. |
Not sure if that works, needs experimentation.
If we know the content of the entire table at compile time, we can generate a perfect hash function (see gperf, constexpr-phf, frozen::unordered_map). Static lookups will be cheap as the hash can be derived at compile time. Dynamic lookups would also be cheaper since we know there to be no collisions. Dynamic construction would need a separate table that is independent of the compile-time table. |
Regardless, it makes very little sense to discuss this without being to able to measure any potential gain and whether this is necessary in the first place. |
Why do you write in bold? Testing is always a good idea if you wan to improve performance. The ChannelHandleAndGroup was a mayor performance gain, a similar solution for all will also give some performance. Just moving to std::string may involve a regression due to less optimal compares/hashing because of absence of implicit sharing. I don't think it worth the effort and risk of regressions. Moving to QByteArray cound be a quick win though. |
Because I wanted to emphasize that it makes no sense to discuss details of performance implications before we write benchmarks. That is the very first step to improvement.
Do we have / did we have benchmarks on that? |
We have manual test results documented here: |
Thank you. Then the next step would be to do similar measurements for COs and see whether its worth improving. |
We might want to consider switching
ConfigKey
fromQString
toQLatin1String
as those can be significantly faster apparently and I don't think we need/want Unicode support in COs, do we?Originally posted by @Swiftb0y in #11980 (comment)
The text was updated successfully, but these errors were encountered: