Refactor concurrency handling to introduce STALE_HEARTBEAT_THRESHOLD_MS constant and utilize SweepstoreWorkerTicketSnapshot for improved state management
This commit is contained in:
@@ -60,21 +60,25 @@ Future<void> main() async {
|
||||
|
||||
Sweepstore store = Sweepstore(filePath);
|
||||
store.initialise(
|
||||
concurrentWorkers: 18
|
||||
concurrentWorkers: 32
|
||||
);
|
||||
initialiseMasterListener(file.openSync(mode: FileMode.append));
|
||||
|
||||
print(binaryDump(file.readAsBytesSync()));
|
||||
|
||||
int iteration = 100;
|
||||
int iteration = 0;
|
||||
|
||||
for (int j = 0; j < iteration; j++) {
|
||||
print("Concurrent Workers: ${store._concurrencyHeader.numberOfWorkers}");
|
||||
print("Stale Ticket Threshold: ${STALE_HEARTBEAT_THRESHOLD_MS}ms");
|
||||
|
||||
while (true) {
|
||||
int concurrencyTest = 128;
|
||||
final receivePort = ReceivePort();
|
||||
int completedJobs = 0;
|
||||
|
||||
final stopwatch = Stopwatch()..start();
|
||||
|
||||
print('\x1B[95mStarting iteration #$iteration with $concurrencyTest concurrent jobs...\x1B[0m');
|
||||
for (int i = 0; i < concurrencyTest; i++) {
|
||||
await Isolate.spawn((message) {
|
||||
final index = message['index'] as int;
|
||||
@@ -101,7 +105,9 @@ Future<void> main() async {
|
||||
|
||||
print('\x1B[95mAll jobs completed!\x1B[0m');
|
||||
print('\x1B[95mTime taken: ${stopwatch.elapsedMilliseconds}ms (${stopwatch.elapsed.inSeconds}s)\x1B[0m');
|
||||
print(" ");
|
||||
|
||||
// sleep(Duration(seconds: 2));
|
||||
iteration++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user