Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Supervised AqlValue] Make aggregators use supervised AqlValue#22103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cpjulia wants to merge23 commits intofeature/supervised-aql-value
base:feature/supervised-aql-value
Choose a base branch
Loading
fromfeature/supervised-aggregator

Conversation

@cpjulia
Copy link
Contributor

@cpjuliacpjulia commentedNov 14, 2025
edited by cursorbot
Loading

Scope & Purpose

This PR makes use of#22034 by passing the resource monitor as argument to the AqlValue constructors in Aggregator.cpp

  • 💩 Bugfix
  • 🍕 New feature
  • 🔥 Performance improvement
  • 🔨 Refactoring/simplification

Checklist

  • Tests
    • Regression tests
    • C++Unit tests
    • integration tests
    • resilience tests
  • 📖 CHANGELOG entry made
  • 📚 documentation written (release notes, API changes, ...)
  • Backports
    • Backport for 3.12.0:(Please link PR)
    • Backport for 3.11:(Please link PR)
    • Backport for 3.10:(Please link PR)

Related Information

(Please reference tickets / specification / other PRs etc)

  • Docs PR:
  • Enterprise PR:
  • GitHub issue / Jira ticket:
  • Design document:

Note

Pass ResourceMonitor to AqlValue constructions across aggregators and simplify MIN/MAX memory handling; expose monitor via Aggregator and ResourceUsageScope.

  • AQL Aggregators:
    • Return supervisedAqlValue fromget() by passing_resourceMonitor (e.g.,AVERAGE_STEP1,VARIANCE_*_STEP1,UNIQUE,SORTED_UNIQUE,MERGE_LISTS,PUSH).
    • SimplifyMIN/MAX memory handling: replace manual resource usage adjustments withdestroy()/erase() before cloning.
  • Core plumbing:
    • Add_resourceMonitor member toAggregator and propagate through constructors/usages.
    • AddresourceMonitor() accessor toResourceUsageScope.

Written byCursor Bugbot for commited49a3c. This will update automatically on new commits. Configurehere.

Copy link

@cursorcursorbot left a comment

Choose a reason for hiding this comment

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

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on November 28

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit theCursor dashboard to activate Pro and start your 14-day free trial.

@cpjuliacpjulia changed the base branch fromdevel tofeature/supervised-aql-valueNovember 14, 2025 15:24
builderCopy.close();
returnAqlValue(std::move(*builderCopy.steal()));
returnAqlValue(std::move(*builderCopy.steal()),
&_usageScope.resourceMonitor());
Copy link

Choose a reason for hiding this comment

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

Bug: Double Memory Accounting in AQL

TheAqlValue constructor is being passed&_usageScope.resourceMonitor() for a buffer that's already supervised viaSupervisedBuffer. Thebuilder member is initialized withSupervisedBuffer(resourceMonitor) which already tracks memory through the resource monitor. Passing the resource monitor pointer again to theAqlValue constructor causes double accounting of memory usage. The fix should either not pass the resource monitor pointer (likeAggregatorMergeLists does), or use a non-supervised buffer initially.

Fix in Cursor Fix in Web

@knakatasfknakatasf changed the titleFeature/supervised aggregator[Supervised AqlValue] Aggregators return supervised AqlValueNov 17, 2025
Copy link

@cursorcursorbot left a comment

Choose a reason for hiding this comment

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

Bug: Memory Accounting Scope Mismatch

Memory tracking was removed fromAggregatorMin::reduce(), butcmpValue.clone() doesn't use the aggregator's_resourceMonitor. Theclone() method either uses no resource monitor or usescmpValue's monitor, so memory allocated for the aggregator'svalue member isn't tracked in the aggregator's resource scope, causing incorrect memory accounting.

arangod/Aql/Aggregator.cpp#L182-L191

voidreduce(AqlValueconst& cmpValue)override {
if (!cmpValue.isNull(true) &&
(value.isEmpty() ||
AqlValue::Compare(_vpackOptions, value, cmpValue,true) >0)) {
// the value `null` itself will not be used in MIN() to compare lower than
// e.g. value `false`
value.destroy();
value = cmpValue.clone();
}

Fix in Cursor Fix in Web


Copy link

@cursorcursorbot left a comment

Choose a reason for hiding this comment

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

Bug: AqlValue Clones Escape Memory Tracking

Manual memory tracking was removed but the stored value is not created as a supervised AqlValue. Whenvalue = cmpValue.clone() is assigned, the resulting value won't be automatically tracked by the ResourceMonitor. The memory used by this internally stored value should either be manually tracked (as before) or created as a supervised AqlValue by passing&_resourceMonitor to the constructor.

arangod/Aql/Aggregator.cpp#L182-L191

voidreduce(AqlValueconst& cmpValue)override {
if (!cmpValue.isNull(true) &&
(value.isEmpty() ||
AqlValue::Compare(_vpackOptions, value, cmpValue,true) >0)) {
// the value `null` itself will not be used in MIN() to compare lower than
// e.g. value `false`
value.destroy();
value = cmpValue.clone();
}

Fix in Cursor Fix in Web


Bug: Resource monitor misses new memory allocations.

Manual memory tracking was removed but the stored value is not created as a supervised AqlValue. Whenvalue = cmpValue.clone() is assigned, the resulting value won't be automatically tracked by the ResourceMonitor. The memory used by this internally stored value should either be manually tracked (as before) or created as a supervised AqlValue by passing&_resourceMonitor to the constructor.

arangod/Aql/Aggregator.cpp#L219-L226

voidreduce(AqlValueconst& cmpValue)override {
if (value.isEmpty() ||
AqlValue::Compare(_vpackOptions, value, cmpValue,true) <0) {
value.destroy();
value = cmpValue.clone();
}
}

Fix in Cursor Fix in Web


Bug: Unsupervised MIN Clones Evade Memory Tracking

Theget() method returnsvalue.clone() which creates an unsupervised AqlValue. Unlike other aggregators updated in this PR that pass&_resourceMonitor to return statements (e.g., lines 354, 489, 681), MIN still returns an unsupervised clone. Manual memory tracking was removed fromreduce() but the return value was never updated to be supervised, so memory usage won't be tracked by ResourceMonitor.

arangod/Aql/Aggregator.cpp#L193-L199

AqlValueget()constoverride {
if (value.isEmpty()) {
returnAqlValue(AqlValueHintNull());
}
return value.clone();
}

Fix in Cursor Fix in Web


Bug: MAX Aggregator: Memory Untracked by ResourceMonitor

Theget() method returnsvalue.clone() which creates an unsupervised AqlValue. Unlike other aggregators updated in this PR that pass&_resourceMonitor to return statements (e.g., lines 354, 489, 681), MAX still returns an unsupervised clone. Manual memory tracking was removed fromreduce() but the return value was never updated to be supervised, so memory usage won't be tracked by ResourceMonitor.

arangod/Aql/Aggregator.cpp#L227-L233

AqlValueget()constoverride {
if (value.isEmpty()) {
returnAqlValue(AqlValueHintNull());
}
return value.clone();
}

Fix in Cursor Fix in Web


Copy link

@cursorcursorbot left a comment

Choose a reason for hiding this comment

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

Bug: MIN/MAX aggregators lose resource tracking on clone

The manual memory tracking code was removed fromAggregatorMin::reduce() andAggregatorMax::reduce(), assuming automatic tracking. However,cmpValue.clone() is called without passing a ResourceMonitor parameter. Sinceclone() doesn't accept a ResourceMonitor argument, the cloned value is created as an untracked VPACK_MANAGED_SLICE. This breaks resource accounting: the old value is destroyed and removed from tracking, but the new cloned value is never registered with the resource monitor.

arangod/Aql/Aggregator.cpp#L182-L192

voidreduce(AqlValueconst& cmpValue)override {
if (!cmpValue.isNull(true) &&
(value.isEmpty() ||
AqlValue::Compare(_vpackOptions, value, cmpValue,true) >0)) {
// the value `null` itself will not be used in MIN() to compare lower than
// e.g. value `false`
value.destroy();
value = cmpValue.clone();
}
}

Fix in Cursor Fix in Web


Copy link
Member

@mchackimchacki left a comment

Choose a reason for hiding this comment

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

LGTM.

Unrelated comment!

if (memDelta >0) {
resourceUsageScope().increase(memDelta);
}
value.destroy();
Copy link
Member

Choose a reason for hiding this comment

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

Not actually a change in this PR.
But wouldn't we need to test here if value should be destroyed? We do so in the reset call a couple if lines above

if (memDelta >0) {
resourceUsageScope().increase(memDelta);
}
value.destroy();
Copy link
Member

Choose a reason for hiding this comment

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

See above comment

value.destroy();
}else {
value.erase();// clears inline values because destroy() doesn't call
// erase() for this case
Copy link

Choose a reason for hiding this comment

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

Bug: Memory tracking lost when cloning values in aggregators

The refactoring removes resource tracking when cloning values inAggregatorMin andAggregatorMax. The old code calculated memory deltas and adjusted the resource usage scope accordingly. The new code simply clones without tracking, causing memory leaks in resource monitoring. Sinceclone() only preserves the resource monitor for supervised slices, regular managed slices lose tracking entirely.

Additional Locations (1)

Fix in Cursor Fix in Web

@cpjuliacpjuliaforce-pushed thefeature/supervised-aql-value branch from3f236f6 to66c1564CompareDecember 4, 2025 04:07
@cpjuliacpjulia changed the title[Supervised AqlValue] Aggregators return supervised AqlValue[Supervised AqlValue] Make aggregators use supervised AqlValueDec 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@cursorcursor[bot]cursor[bot] left review comments

@mchackimchackimchacki approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@cpjulia@mchacki@knakatasf

[8]ページ先頭

©2009-2025 Movatter.jp