test: create framework for testing memory#4921
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4921 +/- ##
==========================================
+ Coverage 81.38% 81.69% +0.31%
==========================================
Files 333 334 +1
Lines 130056 132747 +2691
Branches 130056 132747 +2691
==========================================
+ Hits 105847 108454 +2607
+ Misses 20654 20649 -5
- Partials 3555 3644 +89
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fcab0f6 to
fe8a7e2
Compare
| stats.max_bytes_allocated, | ||
| (batch_size * 2) as isize, | ||
| "Max memory usage exceeded" | ||
| ); |
There was a problem hiding this comment.
I wonder if it would make sense to wrap this up in a macro. Would that promote more widespread usage?
#[maxallocs=10*1024*1024]
{
let tmp_dir = tempfile::tempdir().unwrap();
let tmp_path = tmp_dir.path().to_str().unwrap();
let _dataset = InsertBuilder::new(tmp_path)
.execute_stream(data)
.await
.unwrap();
}
There was a problem hiding this comment.
We can add that later if we find it simplifies things. Will be easier to see once we have more tests in here and see what patterns are repeating.
|
Had to disable this for MacOS. We can implement a version that is cross platform in a future PR. |
Adds a new integration test `resource_test` which contains a utility for
making assertions about memory use with a span. This needs to be in a
separate integration tests because it hooks into the global memory
allocator, and doing that for all tests would probably make them quite
slow.
Here's an example of how this can be used:
```rust
let alloc_tracker = AllocTracker::new();
{
let _guard = alloc_tracker.enter();
// Do something that allocates, even in async tasks
}
let stats = alloc_tracker.stats();
assert_lt!(stats.max_bytes_allocated, 100_000_000, "Used more than 100MB");
assert_eq!(stats.total_bytes_allocated, stats.total_bytes_deallocated, "No memory leaked");
```
Closes lance-format#4761
Adds a new integration test
resource_testwhich contains a utility for making assertions about memory use with a span. This needs to be in a separate integration tests because it hooks into the global memory allocator, and doing that for all tests would probably make them quite slow.Here's an example of how this can be used:
Closes #4761