Skip to content

Conversation

@romange
Copy link
Collaborator

@romange romange commented Dec 9, 2025

Change BackedArguments to keep prefix sums of all lengths of its items Based on the idea from #6176 (comment)

Copilot AI review requested due to automatic review settings December 9, 2025 14:54
Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestions posted.

Comment augment review to trigger a new review at any time.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the BackedArguments class to use prefix sums (offsets) instead of individual lengths for storing argument metadata. This change enables O(1) random access to arguments by upgrading the iterator from forward_iterator to random_access_iterator, eliminating the need to track byte offsets separately when traversing arguments.

Key changes:

  • Replaced lens_ vector with offsets_ vector to store prefix sums instead of individual lengths
  • Upgraded iterator category to random_access_iterator_tag with arithmetic operators (operator+, operator-, etc.)
  • Simplified WrapperBacked in ParsedArgs by removing the ofs_bytes_ tracking member

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/common/backed_args.h Core refactoring: replaced length tracking with offset (prefix sum) storage; upgraded iterator to random access with arithmetic operators
src/facade/facade_types.h Simplified WrapperBacked by removing ofs_bytes_ member; updated front(), ToSlice(), and Tail() to use new random access capabilities
src/facade/memcache_parser.h Updated Command::key() to use empty() instead of lens_.empty()
src/facade/memcache_parser.cc Changed from tokens[0] to tokens_view[0] for consistency after prefix removal
src/facade/memcache_parser_test.cc Simplified ToArgs() to construct vector directly from iterator range

Change BackedArguments to keep prefix sums of all lengths of its items
Based on the idea from #6176 (comment)

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
@romange romange merged commit dd26604 into main Dec 10, 2025
10 checks passed
@romange romange deleted the Pr3 branch December 10, 2025 09:17
dranikpg pushed a commit to dranikpg/dragonfly that referenced this pull request Dec 11, 2025
…dragonflydb#6189)

Change BackedArguments to keep prefix sums of all lengths of its items
Based on the idea from dragonflydb#6176 (comment)

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants