Skip to content

⚡ Bolt: O(N) single-pass answer fragment reassembly - #259

Open
vamzi wants to merge 1 commit into
mainfrom
jules-12193032883361170609-8a136f15
Open

⚡ Bolt: O(N) single-pass answer fragment reassembly#259
vamzi wants to merge 1 commit into
mainfrom
jules-12193032883361170609-8a136f15

Conversation

@vamzi

@vamzi vamzi commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

💡 What:
Refactored the fragmented answer packet reassembly in decode_answer_fragments_from_packet to use an O(N) single-pass bucket-sort algorithm over packet.all_resource_records(). It allocates a fixed-size [Option<DecodedFragment>; 256] array on the stack using a const initializer to completely avoid heap-allocation or Copy/Clone bounds.

🎯 Why:
The original implementation reassembled fragmented DNS answer packets by iteratively calling collect_single_txt in a loop, walking the packet's resource record list up to chunk_total times. In pathological cases with up to 255 fragments, this led to an O(N²) quadratic time complexity.

📊 Impact:
Transforms reassembly performance from O(N²) to O(N) time complexity with zero heap allocations, yielding massive performance gains as the number of fragments increases, while maintaining 100% backward compatibility and exact error propagation.

🔬 Measurement:
Run cargo test -p openhost-pkarr to execute the comprehensive test suite verifying the optimization's correctness under nominal, malformed, and duplicate fragment scenarios.


PR created automatically by Jules for task 12193032883361170609 started by @vamzi

Co-authored-by: vamzi <9899519+vamzi@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant