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

chore: Clean up merge logic for vectors of key-value structs. #1977

Merged
merged 13 commits into from
May 22, 2024

Conversation

TheWizardTower
Copy link
Contributor

The issue is that the original code is not idiomatic rust, since it's directly indexing acc via acc[pos]. However, looking at merge_key_value_vecs, it already prefers the right value, so I think we can just have the last two lines and get the same result.

Including the refactored code as a comment so we can have a discussion on the PR, we may be doing the merge twice for cache line performance reasons.

Summary:
I've rewritten the logic to merge the two vector maps to be more idiomatic Rust, and avoid a bare vector index. However, I think we can just call merge_key_value_vecs() and achieve the same result, since that function biases towards the right values anyway.

It's possible you all are doing it for optimization reasons, so I would appreciate review from folks who are more familiar with the codebase than I am.

Issue Reference(s):
Fixes #1701

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly. (not sure what documentation exists for this)
  • I have performed a self-review of my code.
  • PR follows the naming convention of <type>(<optional scope>): <title>

The issue is that the original code is not idiomatic rust, since it's
directly indexing acc via acc[pos]. However, looking at
merge_key_value_vecs, it already prefers the right value, so I _think_
we can just have the last two lines and get the same result.

Including the refactored code as a comment so we can have a discussion
on the PR, we may be doing the merge twice for cache line performance
reasons.
@github-actions github-actions bot added the type: chore Routine tasks like conversions, reorganization, and maintenance work. label May 16, 2024
@TheWizardTower TheWizardTower changed the title Chore: Clean up merge logic for vectors of key-value structs. chore: Clean up merge logic for vectors of key-value structs. May 16, 2024
Copy link

codecov bot commented May 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.28%. Comparing base (7c7633c) to head (af52460).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1977      +/-   ##
==========================================
+ Coverage   82.24%   82.28%   +0.04%     
==========================================
  Files         174      174              
  Lines       17763    17804      +41     
==========================================
+ Hits        14609    14650      +41     
  Misses       3154     3154              

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

@tusharmath tusharmath enabled auto-merge (squash) May 22, 2024 06:18
@tusharmath
Copy link
Contributor

LGTM! Thanks @TheWizardTower

@tusharmath tusharmath merged commit f421e5a into tailcallhq:main May 22, 2024
27 checks passed
tusharmath added a commit that referenced this pull request May 22, 2024
Co-authored-by: Tushar Mathur <tusharmath@gmail.com>
Co-authored-by: Kiryl Mialeshka <8974488+meskill@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Mehul Mathur <mathur.mehul01@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: chore Routine tasks like conversions, reorganization, and maintenance work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve merging logic in struct
4 participants