Skip to content

Few implementations of RMQ#52

Merged
Malkovsky merged 27 commits into
mainfrom
feature/rmq
Jun 20, 2026
Merged

Few implementations of RMQ#52
Malkovsky merged 27 commits into
mainfrom
feature/rmq

Conversation

@Malkovsky

Copy link
Copy Markdown
Owner
  • Implemented simple RMQ baselines: segment tree, sparse table
  • Implemented cartesian tree reduction to RMQ +-1 and its base implementation via sparse table (aka FCB algorithm)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d00344a8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread include/pixie/rmq/cartesian_tree_rmq.h Outdated
append_euler(node, depth);
}
if (right_child_[node] != invalid_index) {
euler_tour(right_child_[node], depth + 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Replace recursive Euler traversal for degenerate trees

For monotone inputs the Cartesian tree is a chain, so this recursive call nests once per array element; constructing CartesianTreeRmq on a sorted array with a few hundred thousand elements overflows the default Linux stack (I reproduced a segfault with 500k ascending ints) even though the data size is otherwise reasonable for this library. An iterative Euler traversal avoids crashing on these common worst-case inputs.

Useful? React with 👍 / 👎.

Comment thread src/tests/rmq_tests.cpp
@@ -0,0 +1,308 @@
#include <gtest/gtest.h>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Register the new RMQ tests in CMake

This new test source is never built or run: I checked the PIXIE_TESTS section of the top-level CMakeLists.txt, and it registers unittests, benchmark_tests, test_rmm, louds_tree_tests, and excess_positions_tests, but not src/tests/rmq_tests.cpp. As a result CI will not compile the new RMQ coverage or catch regressions in these new implementations unless an add_executable/gtest_discover_tests entry is added.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.15592% with 370 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.62%. Comparing base (7445639) to head (4251f34).

Files with missing lines Patch % Lines
include/pixie/rmq/cartesian_hybrid_btree.h 83.31% 69 Missing and 52 partials ⚠️
include/pixie/rmq/hybrid_btree.h 81.51% 52 Missing and 58 partials ⚠️
include/pixie/bits.h 91.30% 17 Missing and 13 partials ⚠️
src/tests/rmq_tests.cpp 95.41% 24 Missing ⚠️
include/pixie/experimental/rmm_btree.h 87.11% 13 Missing and 8 partials ⚠️
include/pixie/bitvector.h 86.33% 4 Missing and 15 partials ⚠️
src/tests/excess_positions_tests.cpp 92.72% 13 Missing and 3 partials ⚠️
include/pixie/rmq/cartesian_rmm.h 87.35% 6 Missing and 5 partials ⚠️
include/pixie/rmq/sparse_table.h 88.67% 3 Missing and 3 partials ⚠️
include/pixie/rmq/utils/succinct_monotone_stack.h 92.85% 3 Missing and 2 partials ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
- Coverage   89.22%   88.62%   -0.60%     
==========================================
  Files          17       26       +9     
  Lines        4556     7878    +3322     
  Branches      828     1304     +476     
==========================================
+ Hits         4065     6982    +2917     
- Misses        284      504     +220     
- Partials      207      392     +185     
Flag Coverage Δ
gcov 88.62% <89.15%> (-0.60%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5357398423

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -0,0 +1,188 @@
#include <benchmark/benchmark.h>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Register the new RMQ benchmark target

The new benchmark source is never built: I checked the PIXIE_BENCHMARKS section of the top-level CMakeLists.txt, and it registers targets such as benchmarks, bench_rmm, bench_rmm_btree, louds_tree_benchmarks, and excess_positions_benchmarks, but not src/benchmarks/bench_rmq.cpp. This means the RMQ benchmark coverage added here cannot be run through the normal CMake build, so performance experiments for these new implementations silently miss the benchmark unless a target/link entry is added.

Useful? React with 👍 / 👎.

Comment on lines +59 to +62
bench_name = parts[0]
try:
n = int(parts[1])
except ValueError:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep width as a separate benchmark dimension

For multi-argument Google Benchmark names such as the RMQ benchmarks registered as rmq_sparse_table/<size>/<width>, this parses only parts[1] and later keys series by (bench_name, n), so all widths for the same size get averaged together. That makes the plotted RMQ results misleading because max_width is intentionally varied in bench_rmq.cpp; include the remaining arguments in the series key or otherwise split them instead of collapsing them into one point.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bf81cdb0e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/benchmarks/bench_rmq.cpp Outdated
Comment on lines +566 to +567
const std::vector<std::size_t> sizes = {1ull << 10, 1ull << 14, 1ull << 18,
1ull << 22, 1ull << 26};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Cap sparse-table benchmark sizes

When bench_rmq is run without a filter, this size list is used for every RMQ registered in the loop, including rmq_sparse_table in the same section. At 1ull << 26, SparseTable allocates O(n log n) stored indices (about 1.7B size_t entries, roughly 14 GiB before the input/query vectors), so the normal benchmark target will OOM or spend its time swapping before producing results. Please keep the very large sizes out of the sparse-table baseline or register per-implementation size sets.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f499afec2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .gitmodules Outdated
@@ -0,0 +1,3 @@
[submodule "agentic/cpp"]
path = agentic/cpp
url = git@github.com:Malkovsky/ai_for_cpp.git

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use an HTTPS URL for the public submodule

When a fresh clone or CI job initializes submodules without a GitHub SSH key, this git@github.com: URL fails with public-key authentication before agentic/cpp is populated. Since this commit replaces the previously tracked agentic/cpp files with a submodule that AGENTS.md points agents to read, use an anonymous HTTPS URL for the public submodule so default git submodule update --init works.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: caed4ffcda

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"${BUILD_DIR}/louds_tree_tests"
"${BUILD_DIR}/dfuds_tree_tests"
"${BUILD_DIR}/test_rmm"
"${BUILD_DIR}/rmq_tests"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Build rmq_tests before running coverage

When scripts/coverage_report.sh is run from a clean tree, cmake --build --preset coverage builds only the targets listed in the coverage build preset in CMakePresets.json (unittests, benchmark_tests, test_rmm, louds_tree_tests, dfuds_tree_tests, and excess_positions_tests). Since rmq_tests is not in that preset, this newly added invocation exits with “No such file or directory” before coverage is generated; add rmq_tests to the coverage preset or build it explicitly here before executing it.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Malkovsky Malkovsky merged commit 5959535 into main Jun 20, 2026
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