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

Optimize size of Node and Array #7992

Merged
merged 3 commits into from
Aug 27, 2024
Merged

Optimize size of Node and Array #7992

merged 3 commits into from
Aug 27, 2024

Conversation

jedelbo
Copy link
Contributor

@jedelbo jedelbo commented Aug 22, 2024

The size of Node and Array decresed from 64 and 128 to 56 and 112. Some redundant code removed in Spec class.

What, How & Why?

The second commit may fix #7847

☑️ ToDos

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

The size of Node and Array decresed from 64 and 128 to 56 and 112.
Some redundant code removed in Spec class.
Reduse the stack usage of StringIndex::leaf_insert from 832 to 608 (debug)
and StringIndex::TreeInsert from 208 to 128
@jedelbo jedelbo requested a review from tgoyne August 22, 2024 12:58
@jedelbo
Copy link
Contributor Author

jedelbo commented Aug 22, 2024

@tgoyne I was not able to reproduce the issue you described in #7847 on my machine, so I am not able to tell if this PR actually fixes it. Can you help here?

@jedelbo jedelbo marked this pull request as ready for review August 22, 2024 13:45
@tgoyne
Copy link
Member

tgoyne commented Aug 22, 2024

This cuts the -O0 stack space used on the recursive path a bit so it'll reduce the maximum stack space required for an index update. There isn't really a clear answer to if it's by enough.

Comment on lines 937 to +938
case NodeChange::change_None:
return;
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

It appears that this case should never happen, should we have a REALM_UNREACHABLE here?

m_keys.init_from_parent();
}

m_keys.init_from_parent();
Copy link
Contributor

@ironage ironage Aug 22, 2024

Choose a reason for hiding this comment

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

consider adding an assertion that m_top.get_as_ref(s_col_keys_ndx) is not zero (not blocking)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, we don't check the other entries and I am sure we will have an assertion down the line if the ref is zero.

Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

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

nice 👍

Copy link

coveralls-official bot commented Aug 23, 2024

Pull Request Test Coverage Report for Build jorgen.edelbo_406

Details

  • 82 of 84 (97.62%) changed or added relevant lines in 10 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on je/optimize at 91.11%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/realm/index_string.cpp 59 61 96.72%
Totals Coverage Status
Change from base Build 2575: 91.1%
Covered Lines: 217348
Relevant Lines: 238556

💛 - Coveralls

It is a long time since there was a difference in how init_from_parent()
and update_from_parent() should work.
@jedelbo jedelbo requested a review from ironage August 26, 2024 09:34
@jedelbo
Copy link
Contributor Author

jedelbo commented Aug 26, 2024

@ironage please have a second look. I have made some more changes.

Comment on lines -1955 to +1956
m_top.update_from_parent();
m_spec.update_from_parent();
m_top.init_from_parent();
m_spec.init_from_parent();
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, good to clean this confusion up.

@jedelbo jedelbo merged commit bc0a677 into master Aug 27, 2024
43 of 45 checks passed
@jedelbo jedelbo deleted the je/optimize branch August 27, 2024 14:56
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stack overflow in Upgrade_Database_23
3 participants