Skip to content

Conversation

@fengttt
Copy link
Contributor

@fengttt fengttt commented Dec 6, 2025

User description

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #23226

What this PR does / why we need it:

Code cleanup, remove some strange code.


PR Type

Enhancement


Description

  • Remove unused getShuffleDop function and its tests

  • Simplify shuffle DOP calculation to use ncpu directly

  • Remove unnecessary stringzilla dependency from go.mod


Diagram Walkthrough

flowchart LR
  A["Complex DOP Logic"] -->|Remove| B["Simplified ncpu Usage"]
  C["getShuffleDop Function"] -->|Delete| D["Cleaner Codebase"]
  E["Unused Dependency"] -->|Remove| F["Reduced Dependencies"]
Loading

File Walkthrough

Relevant files
Code cleanup
shuffle.go
Delete unused getShuffleDop function                                         

pkg/sql/plan/shuffle.go

  • Removed getShuffleDop function (37 lines) that contained complex and
    unclear DOP calculation logic
  • Function was replaced with direct ncpu usage in stats.go
+0/-37   
Tests
shuffle_test.go
Remove getShuffleDop test cases                                                   

pkg/sql/plan/shuffle_test.go

  • Removed TestGetShuffleDop test function (63 lines) that tested the
    deleted getShuffleDop function
  • Test covered various CPU and hashmap size scenarios
+0/-63   
Enhancement
stats.go
Simplify shuffle DOP to use ncpu                                                 

pkg/sql/plan/stats.go

  • Replaced complex getShuffleDop call with direct ncpu assignment
  • Added comment explaining the removal of "weird calculate shuffle dop
    logic"
  • Simplified DOP calculation while maintaining childDop comparison logic
+3/-1     
Dependencies
go.mod
Remove stringzilla dependency                                                       

go.mod

  • Removed unused github.com/ashvardanian/stringzilla/golang dependency
+0/-1     
go.sum
Update checksums for removed dependency                                   

go.sum

  • Removed hash entries for github.com/ashvardanian/stringzilla/golang
    package
+0/-2     

@qodo-code-review
Copy link

qodo-code-review bot commented Dec 6, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Audit impact unclear: The change to use ncpu for shuffle DOP may alter runtime behavior but the diff shows no
new or removed logging for critical actions, so audit trail impact cannot be determined
from these hunks alone.

Referred Code
// there was a weird calculate shuffle dop logic here, which does not really make any sense.
// just use ncpu.
dop := ncpu
childDop := qry.Nodes[node.Children[0]].Stats.Dop
if dop < childDop {
	dop = childDop
}

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Edge cases removed: Replacing getShuffleDop with direct ncpu may remove prior edge-case handling for hashmap
size and child DOP interactions, but without full context it’s unclear if this degrades
behavior.

Referred Code
// there was a weird calculate shuffle dop logic here, which does not really make any sense.
// just use ncpu.
dop := ncpu
childDop := qry.Nodes[node.Children[0]].Stats.Dop
if dop < childDop {
	dop = childDop
}

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@mergify mergify bot added the kind/refactor Code refactor label Dec 6, 2025
@qodo-code-review
Copy link

qodo-code-review bot commented Dec 6, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent panic on empty children slice

Add a check for len(node.Children) > 0 before accessing node.Children[0] to
prevent a potential panic if a node with shuffle stats has no children.

pkg/sql/plan/stats.go [1875-1882]

 			// there was a weird calculate shuffle dop logic here, which does not really make any sense.
 			// just use ncpu.
 			dop := ncpu
-			childDop := qry.Nodes[node.Children[0]].Stats.Dop
-			if dop < childDop {
-				dop = childDop
+			if len(node.Children) > 0 {
+				childDop := qry.Nodes[node.Children[0]].Stats.Dop
+				if dop < childDop {
+					dop = childDop
+				}
 			}
 			setNodeDOP(p, rootID, dop)
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a potential index-out-of-bounds panic and proposes a valid check, which improves the code's robustness against unexpected plan structures.

Low
  • Update

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

Labels

kind/refactor Code refactor Review effort 2/5 size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants