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

Function benchmarkConcurrentQueryMemory

benchmark/performance.js:678–711  ·  view source on GitHub ↗

* Benchmark: Concurrent Query GC Pressure * Measures max GC pause under concurrent load with large result sets. * Simulates production conditions where multiple clients query simultaneously, * compounding GC pressure from cursor batch sizes.

(name)

Source from the content-addressed store, hash-verified

676 * compounding GC pressure from cursor batch sizes.
677 */
678async function benchmarkConcurrentQueryMemory(name) {
679 const TestObject = Parse.Object.extend('BenchmarkConcurrentResult');
680 const TOTAL_OBJECTS = 3_000;
681 const SAVE_BATCH_SIZE = 200;
682 const CONCURRENT_QUERIES = 10;
683
684 // Seed data in batches; ~8 KB per document so 3,000 docs ≈ 24 MB total,
685 // exceeding MongoDB's 16 MiB default batch limit to test cursor batching
686 for (let i = 0; i < TOTAL_OBJECTS; i += SAVE_BATCH_SIZE) {
687 const batch = [];
688 for (let j = 0; j < SAVE_BATCH_SIZE && i + j < TOTAL_OBJECTS; j++) {
689 const obj = new TestObject();
690 obj.set('category', (i + j) % 10);
691 obj.set('value', i + j);
692 obj.set('data', `padding-${i + j}-${'x'.repeat(8000)}`);
693 batch.push(obj);
694 }
695 await Parse.Object.saveAll(batch);
696 }
697
698 return measureMemoryOperation({
699 name,
700 iterations: 50,
701 operation: async () => {
702 const queries = [];
703 for (let i = 0; i < CONCURRENT_QUERIES; i++) {
704 const query = new Parse.Query('BenchmarkConcurrentResult');
705 query.limit(TOTAL_OBJECTS);
706 queries.push(query.find({ useMasterKey: true }));
707 }
708 await Promise.all(queries);
709 },
710 });
711}
712
713/**
714 * Benchmark: Query $regex

Callers

nothing calls this directly

Calls 2

measureMemoryOperationFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected