-
Notifications
You must be signed in to change notification settings - Fork 872
Bug fix/cleanup register planning #11336
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
Conversation
…anup-register-planning
…anup-register-planning
…anup-register-planning
|
Just out of curiosity - why do you sort the RegisterId vectors? I did not see anything that relies on the order (though I could have easily missed that). |
|
You are right, nothing reies on the order of the registers in the vector. |
goedderz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the cleanup in the RegisterPlan!
I have two notes, though:
- I'd like to keep the set of input registers in the ExecutorInfos. While it's currently not in use, it is useful and I want to use it when working on the register planning in the next weeks.
- The change from
std::unordered_set<RegisterId>to a sortedstd::vector<RegisterId>is too global for my taste. A local copy of the set inExecutorInfosor so would have sufficed for the performance gain, while keeping the changes more local and not encumbering all future work with sorting a vector everywhere, which surely someone will not know or not remember when making a change. Alternatively some kind of minimal wrapper would help, so not everyone has to remember sorting it everytime (e.g. aclass RegisterSetwith only a constructor,emplace,beginandend).
| // effects when peeking at the registers' values in the AqlItemBlock later). | ||
| #ifdef ARANGODB_ENABLE_MAINTAINER_MODE | ||
| TRI_ASSERT(std::is_sorted(_registersToKeep.begin(), _registersToKeep.end())); | ||
| TRI_ASSERT(std::is_sorted(_registersToClear.begin(), _registersToClear.end())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intentionally omit a similar check for _outRegs?
| TRI_ASSERT(std::is_sorted(_registersToClear.begin(), _registersToClear.end())); | |
| TRI_ASSERT(std::is_sorted(_registersToClear.begin(), _registersToClear.end())); | |
| TRI_ASSERT(std::is_sorted(_outRegs.begin(), _outRegs.end())); |
| // sic: It's possible that a current output register is immediately cleared! | ||
| TRI_ASSERT(regToClear < nrOutputRegisters); | ||
| TRI_ASSERT(_registersToKeep->find(regToClear) == _registersToKeep->end()); | ||
| TRI_ASSERT(std::find(_registersToKeep.begin(), _registersToKeep.end(), regToClear) == _registersToKeep.end()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| TRI_ASSERT(std::find(_registersToKeep.begin(), _registersToKeep.end(), regToClear) == _registersToKeep.end()); | |
| TRI_ASSERT(!std::binary_search(_registersToKeep.begin(), _registersToKeep.end(), regToClear)); |
| for (auto const& regToKeep : _registersToKeep) { | ||
| TRI_ASSERT(regToKeep < nrInputRegisters); | ||
| TRI_ASSERT(_registersToClear->find(regToKeep) == _registersToClear->end()); | ||
| TRI_ASSERT(std::find(_registersToClear.begin(), _registersToClear.end(), regToKeep) == _registersToClear.end()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| TRI_ASSERT(std::find(_registersToClear.begin(), _registersToClear.end(), regToKeep) == _registersToClear.end()); | |
| TRI_ASSERT(!std::binary_search(_registersToClear.begin(), _registersToClear.end(), regToKeep)); |
| * | ||
| * @return The indices of the input registers. | ||
| */ | ||
| std::shared_ptr<std::unordered_set<RegisterId> const> getInputRegisters() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to keep this information (the set of input registers). It will make it easy to add useful assertions to AQL that will immediately help when rewriting the register planning.
| // TODO: improve on this | ||
| if (std::find(registers.begin(), registers.end(), col) == registers.end()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // TODO: improve on this | |
| if (std::find(registers.begin(), registers.end(), col) == registers.end()) { | |
| if (!std::binary_search(registers.begin(), registers.end(), col)) { |
| totalNrRegs++; | ||
| } | ||
|
|
||
| void RegisterPlan::registerVariable(Variable const* v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
|
||
| /// @brief get registers to clear | ||
| std::unordered_set<RegisterId> const& getRegsToClear() const; | ||
| std::vector<RegisterId> const& getRegsToClear() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary and counterproductive. While I agree that there might be a performance gain when this is used in the OutputAqlItemRow, everywhere else it's just harder to read (that something is a vector gives me much less information than something being some kind of set) and error-prone. Anyone doing changes to any register set now has to know and remember that it has to be sorted.
|
Obsoleted by #11385 |
Scope & Purpose
Clean up the AQL register planning code a bit, and simplify APIs a bit.
Testing & Verification
This change is already covered by existing tests, such as scripts/unittest shell_server_aql, scripts/unittest catch.
http://172.16.10.101:8080/view/PR/job/arangodb-matrix-pr/9164/