MCPcopy
hub / github.com/parse-community/parse-server / benchmarkLargeResultMemory

Function benchmarkLargeResultMemory

benchmark/performance.js:642–670  ·  view source on GitHub ↗

* Benchmark: Large Result Set GC Pressure * Measures max GC pause when querying many large documents, which is affected * by MongoDB cursor batch size configuration. Without a batch size limit, * the driver processes larger data chunks between yield points, creating more * garbage that triggers

(name)

Source from the content-addressed store, hash-verified

640 * garbage that triggers longer GC pauses.
641 */
642async function benchmarkLargeResultMemory(name) {
643 const TestObject = Parse.Object.extend('BenchmarkLargeResult');
644 const TOTAL_OBJECTS = 3_000;
645 const SAVE_BATCH_SIZE = 200;
646
647 // Seed data in batches; ~8 KB per document so 3,000 docs ≈ 24 MB total,
648 // exceeding MongoDB's 16 MiB default batch limit to test cursor batching
649 for (let i = 0; i < TOTAL_OBJECTS; i += SAVE_BATCH_SIZE) {
650 const batch = [];
651 for (let j = 0; j < SAVE_BATCH_SIZE && i + j < TOTAL_OBJECTS; j++) {
652 const obj = new TestObject();
653 obj.set('category', (i + j) % 10);
654 obj.set('value', i + j);
655 obj.set('data', `padding-${i + j}-${'x'.repeat(8000)}`);
656 batch.push(obj);
657 }
658 await Parse.Object.saveAll(batch);
659 }
660
661 return measureMemoryOperation({
662 name,
663 iterations: 100,
664 operation: async () => {
665 const query = new Parse.Query('BenchmarkLargeResult');
666 query.limit(TOTAL_OBJECTS);
667 await query.find({ useMasterKey: true });
668 },
669 });
670}
671
672/**
673 * Benchmark: Concurrent Query GC Pressure

Callers

nothing calls this directly

Calls 2

measureMemoryOperationFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected