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

remove unnecessary callback use for ArrayWithFind::find_action() #7095

Merged
merged 4 commits into from
Oct 31, 2023

Conversation

ironage
Copy link
Contributor

@ironage ironage commented Oct 30, 2023

The query system supported two ways of dealing with matches: using QueryStateBase::match() and using a custom callback.
The callback was only used in one place, and I replaced it by caching the results array leaf inside our existing QueryStateBase handler class.
There is no noticeable performance drop for the affected query case that was using the callback. Here's the newly added benchmark compared to master showing no significant change for this case:

Req runs:   14  QueryWithForeignAggAvg (MemOnly, EncryptionOff):        min  35.16ms (-2.43%)            max  35.80ms (-1.63%)            med  35.23ms (-2.32%)            avg  35.32ms (-2.19%)            stddev   210us (+99.14%)

The benefit of doing this is that we can delay fetching the values until the match() function which may not even need the values at all, such as when counting the results. This should have some minimal performance improvement when counting results with many matches.
In addition to the code clean up, this also removes a layer of templating throughout the query system which appears to remove about 100K of binary size off our static library (YMMV).

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed.

@ironage ironage self-assigned this Oct 30, 2023
@coveralls-official
Copy link

Pull Request Test Coverage Report for Build james.stone_406

  • 137 of 150 (91.33%) changed or added relevant lines in 10 files are covered.
  • 58 unchanged lines in 10 files lost coverage.
  • Overall coverage increased (+0.2%) to 91.769%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/realm/array_integer.cpp 0 1 0.0%
src/realm/array_integer_tpl.hpp 7 13 53.85%
src/realm/array_with_find.cpp 1 7 14.29%
Files with Coverage Reduction New Missed Lines %
src/realm/table.cpp 1 92.26%
test/object-store/audit.cpp 1 99.93%
src/realm/sync/noinst/server/server_history.cpp 2 67.69%
src/realm/query_expression.cpp 3 87.03%
src/realm/util/future.hpp 3 95.81%
test/fuzz_group.cpp 3 55.28%
test/object-store/realm.cpp 3 99.49%
src/realm/sync/noinst/client_reset.cpp 4 92.99%
src/realm/sync/noinst/client_reset_operation.cpp 4 87.23%
src/realm/sync/transform.cpp 34 68.86%
Totals Coverage Status
Change from base Build 1786: 0.2%
Covered Lines: 232105
Relevant Lines: 252923

💛 - Coveralls

@tgoyne
Copy link
Member

tgoyne commented Oct 30, 2023

I did something similar in 9a33838. I think your approach is better, but find_action_pattern() should also go away (it's been dead for a long time) and the comment describing how find works is now very incorrect.

@ironage ironage force-pushed the js/skunk-2023-October branch from af5bc36 to badac29 Compare October 30, 2023 21:57
@ironage
Copy link
Contributor Author

ironage commented Oct 30, 2023

Thanks for that feedback Thomas, I've removed find_action_pattern() as well. Hopefully this doesn't conflict too much with the other work you have done there!

@ironage ironage requested a review from tgoyne October 30, 2023 21:59
Copy link
Member

@tgoyne tgoyne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a clang-format run and two trivial notes but otherwise looks good.

value = m_source_column->get_any(index);
}
else {
static_cast<void>(m_source_column);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be any reason to need this. If it was an if constexpr guarding the use of m_source_column you might get some spurious warnings but here the member variable is always used.


cond: One of Equal, NotEqual, Greater, etc. classes
Action: One of act_ReturnFirst, act_FindAll, act_Max, act_CallbackIdx, etc, constants
Callback: Optional function to call for each search result. Will be called if action == act_CallbackIdx
Action: One of act_ReturnFirst, act_FindAll, act_Max, etc, constants
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Action template parameter hasn't existed for a while.

@ironage
Copy link
Contributor Author

ironage commented Oct 31, 2023

CI failures appear unrelated.

@ironage ironage merged commit 1946578 into master Oct 31, 2023
2 checks passed
@ironage ironage deleted the js/skunk-2023-October branch October 31, 2023 22:48
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants