Skip to content

Bp implementation#38

Open
Sanya239 wants to merge 5 commits intomainfrom
bp-implementation
Open

Bp implementation#38
Sanya239 wants to merge 5 commits intomainfrom
bp-implementation

Conversation

@Sanya239
Copy link
Copy Markdown
Collaborator

No description provided.

@Sanya239 Sanya239 requested a review from Malkovsky April 19, 2026 16:13
Comment thread include/pixie/bp_tree.h Outdated
/**
* @brief Returns the size of the tree
*/
size_t size() const { return num_bits_; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: size() returns bit-length, not node count

size() is documented as the tree size but returns num_bits_ (2 * number of nodes). Callers expecting node count will get a 2x value. Consider returning num_bits_ / 2 or renaming to clarify the unit.

Comment thread include/pixie/bp_tree.h Outdated
return 0;
}
BpNode child = first_child(node);
int child_count = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: child_count uses int and can overflow

For large degrees, int can overflow before being returned as size_t, which can wrap to a huge value. Use size_t for the counter to avoid overflow.

Comment thread include/pixie/utils.h Outdated
const std::vector<std::vector<size_t>>& adj) {
size_t bp_size = tree_size * 2;
std::vector<uint64_t> bp((bp_size + 63) / 64, 0);
std::vector<std::pair<int, int>> stack;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: pos and stack indices use int, risk overflow

pos indexes into the BP bitvector and can exceed INT_MAX for large trees, leading to out-of-bounds writes. Use size_t for pos and the stack pair to keep indices in range.

Comment thread include/pixie/rmm_tree.h
std::string result;
result.resize(num_bits);

for (size_t i = 0; i < num_bits; ++i) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SUGGESTION: Optimize bit-to-string conversion for large vectors

The per-bit loop does a shift and index for every bit. A byte-level LUT (256-entry) or word-level conversion can reduce overhead when exporting large bitvectors.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This will wait for better times

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 19, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
include/pixie/rmm_tree.h 2206 Consider a LUT/word-level conversion in to_string() for large bitvectors
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
Files Reviewed (2 files)
  • include/pixie/bp_tree.h - 0 issues
  • include/pixie/utils.h - 0 issues

Reviewed by gpt-5.2-codex-20260114 · 147,189 tokens

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

❌ Patch coverage is 0.67568% with 147 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.64%. Comparing base (59f0fb9) to head (a77e711).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/tests/bp_tree_tests.cpp 0.00% 68 Missing ⚠️
include/pixie/utils.h 2.38% 41 Missing ⚠️
include/pixie/bp_tree.h 0.00% 38 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
- Coverage   86.35%   81.64%   -4.72%     
==========================================
  Files          11       13       +2     
  Lines        2850     3012     +162     
  Branches      562      590      +28     
==========================================
- Hits         2461     2459       -2     
- Misses        254      419     +165     
+ Partials      135      134       -1     
Flag Coverage Δ
gcov 81.64% <0.67%> (-4.72%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread include/pixie/rmm_tree.h
}
build(leaf_block_bits, max_overhead);
}
public:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please make it so that there's a single private section on top and a single public section at bottom of class declaration

Comment thread include/pixie/bp_tree.h
/**
* @brief A node class of BP tree
*/
struct BpNode {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please make it so it is public part of the BpTree class and is simply called Node.

Comment thread include/pixie/bp_tree.h
* @brief A tree class based on the balances parentheses (BP)
* representation
*/
class BpTree {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I also think it is better to write abbreviations in upper case for class names, i.e. BPTree

Comment thread include/pixie/bp_tree.h
class BpTree {
private:
const size_t num_bits_;
RmMTree rmm;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

rmm_

Comment thread include/pixie/bp_tree.h
/**
* @brief Indicates if @p node is a root
*/
static bool is_root(const BpNode& node) { return node.number == 0; }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Although the implementation doesn't depend on the tree instance, in fact it is a tree method, so please remove static.

Comment thread include/pixie/bp_tree.h
/**
* @brief Returns first child of a @p node
*/
static BpNode first_child(const BpNode& node) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The same thing about static

Comment thread CMakeLists.txt
gtest_main
${PIXIE_DIAGNOSTICS_LIBS})

add_executable(bp_tree_tests
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Tests should be added to coverage/build-test workflows (but not for AVX-512).

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.

2 participants