Config object hash#501
Conversation
|
ConfigObject has always been a giant train-wreck thread-safety wise. @kain88-de wrote a nice mixxx-devel post arguing for QSettings a while back and I believe he already started work on it: https://github.com/mixxxcommunity/mixxx/tree/max-linke-qsettings |
I don't think they should be joined -- one is for runtime control processing and one is a representation of the user's preferences. |
|
Yes I thought about switching to QSettings. In fact I wanted to start working on that after the release since it will touch almost every file in mixxx. |
|
Ok, thank you. Than we can merge this to 1.12? |
|
@daschuer, why did you decide to work on this change? Did the linear behavior of QList show up in profiling as problematic? I'm worried that QHash is more crash-prone when touched across threads than QList. I'm against making a change like this so close to the release unless it is motivated by a good reason. |
|
I have no profiling results, but the problem shows up during debugging my StringAtom Branch. And since I was afraid there are some more regular config value look ups and the solution was so obvious ... that the result. |
|
I can't remember a bug in this code in the past 7 years of working on Mixxx and we haven't touched it much in that time period either. I'm for taking the safe route and not messing with what isn't broken and then making big changes after the release. |
|
Ok. I thought we are currently optimizing the performance .. But anyway: there is an other more important issue: The seek errors with mp3 |
Indeed we are! But performance changes should be motivated by data. |
yeah profiling mixxx is really hard, and I've gone down a few dead-ends in the past looking at functions that, say, show up high in gprof results. RJ pointed out that if my CPU isn't even hitting 100%, xruns are not happening because of inefficient algorithms :). My instincts have been proven wrong a few times. In the case of the beats-lookup change I made, that's something RJ and I had gone over before, noticing the mutex locking and noticing the inefficiency of calculating the same data twice to get two different pieces of data out of the result. And then I discovered we were doing way way way more beat lookups than were necessary, so I went and did that patch. There's also a danger in creating artificial benchmarks to justify changes -- if you have to run something X-million times to see a difference, but that code path isn't called very often in mixxx, it's not really helpful. |
There was a problem hiding this comment.
This won't necessarily group same-group keys together since qHash(ConfigKey) can spread them in different hash buckets. A QMap may be better because its iteration order is sorted by its keys. Or we could group the ConfigKeys by group when saving.
There was a problem hiding this comment.
Nice Idea!
Now it uses QMap, which produces a sorted mixxx.cfg file.
Very convenient.
|
OK, now a mutex is in place to protect against the race condition from bug https://bugs.launchpad.net/mixxx/+bug/1428500 Edit: Fixed bug URL |
|
Since this branch fixed a race condition. I would like to merge it soon. |
|
Coming back to this since we've released. Other than the minor comments, looks good to me -- thanks! |
|
Thank you for review. |
There was a problem hiding this comment.
It's common practice to implement comparison operators as free functions with left- and right-hand-side parameters (lhs/rhs) of the same type. Just add "friend" and a second parameter here.
There was a problem hiding this comment.
Our style guide gives a reason why to prefer it: "Prefer to define non-modifying binary operators as non-member functions. If a binary operator is defined as a class member, implicit conversions will apply to the right-hand argument, but not the left-hand one. It will confuse your users if a < b compiles but b < a doesn't."
https://google.github.io/styleguide/cppguide.html#Operator_Overloading
There was a problem hiding this comment.
Very good and concise explanation :)
On 01/12/2016 09:41 AM, RJ Ryan wrote:
In src/configobject.h
#501 (comment):static ConfigKey parseCommaSeparated(QString key); inline bool isNull() const { return group.isNull() && item.isNull(); }
- // comparison function for ConfigKeys. Used by a QHash in ControlObject
- inline bool operator==(const ConfigKey& other) const {
Our style guide gives a reason why to prefer it: "Prefer to define
non-modifying binary operators as non-member functions. If a binary
operator is defined as a class member, implicit conversions will apply to
the right-hand argument, but not the left-hand one. It will confuse your
users if a < b compiles but b < a doesn't."https://google.github.io/styleguide/cppguide.html#Operator_Overloading
—
Reply to this email directly or view it on GitHub
https://github.com/mixxxdj/mixxx/pull/501/files#r49427091.
This replaces the linear lookup code by a qHash.
(Maybe this is a first step towards joining config and control objects)