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

RSValue array cleanup - [MOD-7145] #4612

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

GuyAv46
Copy link
Collaborator

@GuyAv46 GuyAv46 commented Apr 30, 2024

Describe the changes in the pull request

Remove unnecessary initialization and branching, as we almost exclusively were calling RSValue_NewArrayEx(arr, len, RSVAL_ARRAY_NOINCREF | RSVAL_ARRAY_ALLOC); (with these flags), and in the few cases we don't we can get the same behavior with minor adjustments.
We can then delete RSValue_NewArrayEx and use RSValue_NewArray that gives the same behavior as the prior call with the commonly used flags, without branching and no-op loops

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

@GuyAv46 GuyAv46 requested a review from oshadmi April 30, 2024 11:48
Copy link

codecov bot commented Apr 30, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.25%. Comparing base (2b77d2e) to head (c0923bc).

Files Patch % Lines
src/rlookup.c 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4612      +/-   ##
==========================================
- Coverage   86.26%   86.25%   -0.02%     
==========================================
  Files         190      190              
  Lines       34847    34828      -19     
==========================================
- Hits        30061    30040      -21     
- Misses       4786     4788       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GuyAv46 GuyAv46 enabled auto-merge May 29, 2024 08:24
@GuyAv46 GuyAv46 changed the title RSValue array cleanup RSValue array cleanup - [MOD-7145] May 29, 2024
@GuyAv46 GuyAv46 requested a review from DvirDukhan May 29, 2024 12:58
src/aggregate/reducers/to_list.c Outdated Show resolved Hide resolved
src/aggregate/reducers/random_sample.c Outdated Show resolved Hide resolved
@GuyAv46 GuyAv46 requested a review from DvirDukhan June 4, 2024 11:06
* Helper function to allocate memory before passing it to RSValue_NewArray
*/
static inline RSValue **RSValue_AllocateArray(uint32_t len) {
return (RSValue **)rm_malloc(len * sizeof(RSValue *));
Copy link
Contributor

Choose a reason for hiding this comment

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

calloc :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don’t we care about the performance difference? In all the places we fill the entire array anyway. This is not a partially initialized struct but an array of pointers.
I added a memset call in the only place we might not fill the array (and in this case it also most likely a but in the trieMap or its iterator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants