-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathManager.cpp
1899 lines (1616 loc) · 60.8 KB
/
Manager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ######################################################################### */
/* ## ## */
/* ## (Iometer) / Manager.cpp ## */
/* ## ## */
/* ## ------------------------------------------------------------------- ## */
/* ## ## */
/* ## Job .......: Implementation of the Manager class for Iometer, ## */
/* ## which contains a list of workers and provides ## */
/* ## functions for manager-level actions (creating and ## */
/* ## removing workers, communication between Iometer and ## */
/* ## a single copy of Dynamo, etc.). A Manager object is ## */
/* ## created whenever a copy of Dynamo logs in. ## */
/* ## ## */
/* ## ------------------------------------------------------------------- ## */
/* ## ## */
/* ## Intel Open Source License ## */
/* ## ## */
/* ## Copyright (c) 2001 Intel Corporation ## */
/* ## All rights reserved. ## */
/* ## Redistribution and use in source and binary forms, with or ## */
/* ## without modification, are permitted provided that the following ## */
/* ## conditions are met: ## */
/* ## ## */
/* ## Redistributions of source code must retain the above copyright ## */
/* ## notice, this list of conditions and the following disclaimer. ## */
/* ## ## */
/* ## Redistributions in binary form must reproduce the above copyright ## */
/* ## notice, this list of conditions and the following disclaimer in ## */
/* ## the documentation and/or other materials provided with the ## */
/* ## distribution. ## */
/* ## ## */
/* ## Neither the name of the Intel Corporation nor the names of its ## */
/* ## contributors may be used to endorse or promote products derived ## */
/* ## from this software without specific prior written permission. ## */
/* ## ## */
/* ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND ## */
/* ## CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, ## */
/* ## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ## */
/* ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ## */
/* ## DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE ## */
/* ## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ## */
/* ## OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ## */
/* ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, ## */
/* ## OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## */
/* ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ## */
/* ## TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ## */
/* ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY ## */
/* ## OF SUCH DAMAGE. ## */
/* ## ## */
/* ## ------------------------------------------------------------------- ## */
/* ## ## */
/* ## Remarks ...: <none> ## */
/* ## ## */
/* ## ------------------------------------------------------------------- ## */
/* ## ## */
/* ## Changes ...: 2004-06-11 ([email protected]) ## */
/* ## - Add code to allow potentially invalid access specs ## */
/* ## but warn the user. ## */
/* ## 2003-10-17 ([email protected]) ## */
/* ## - Moved to the use of the IOMTR_[OSFAMILY|OS|CPU]_* ## */
/* ## global defines. ## */
/* ## - Integrated the License Statement into this header. ## */
/* ## 2003-04-25 ([email protected]) ## */
/* ## - Updated the global debug flag (_DEBUG) handling ## */
/* ## of the source file (check for platform etc.). ## */
/* ## - Added new header holding the changelog. ## */
/* ## ## */
/* ######################################################################### */
#include "stdafx.h"
#include "Manager.h"
#include "ManagerList.h"
#include "GalileoApp.h"
#include "GalileoView.h"
// Needed for MFC Library support for assisting in finding memory leaks
//
// NOTE: Based on the documentation[1] I found, it should be enough to have
// a "#define new DEBUG_NEW" statement for the case, that we are
// running Windows. There should be no need for checking the _DEBUG
// flag and no need for redefiniting the THIS_FILE string. Maybe there
// will be a MFC hacker who could advice here.
// [1] = http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_debug_new.asp
//
#if defined(IOMTR_OS_WIN32) || defined(IOMTR_OS_WIN64)
#ifdef IOMTR_SETTING_MFC_MEMALLOC_DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#endif
Manager::Manager()
{
id = IOERROR;
ResetResults(WHOLE_TEST_PERF);
ResetResults(LAST_UPDATE_PERF);
tcps.SetSize(INITIAL_ARRAY_SIZE, ARRAY_GROW_STEP);
vis.SetSize(INITIAL_ARRAY_SIZE, ARRAY_GROW_STEP);
disks.SetSize(INITIAL_ARRAY_SIZE, ARRAY_GROW_STEP);
workers.SetSize(INITIAL_ARRAY_SIZE, ARRAY_GROW_STEP);
port = NULL;
}
Manager::~Manager()
{
// Removing all worker, disk info, and net info from the manager.
while (WorkerCount()) {
delete GetWorker(0);
workers.RemoveAt(0);
}
RemoveDiskInfo();
RemoveNetInfo();
// Close the manager's communications pipe.
port->Close();
delete port;
}
//
// Returns the index of the manager.
//
int Manager::GetIndex()
{
for (int m = 0; m < theApp.manager_list.ManagerCount(); m++) {
if (this == theApp.manager_list.GetManager(m))
return m;
}
return IOERROR;
}
//
// Returns an indication of all types of workers that a manager has.
//
TargetType Manager::Type()
{
int i, worker_count;
TargetType type = GenericType;
worker_count = WorkerCount();
for (i = 0; i < worker_count; i++)
type = (TargetType) (type | workers[i]->Type());
// See if the manager is active.
// (A manager may be active even if none of its workers are.)
if (ActiveInCurrentTest())
type = (TargetType) (type | ActiveType);
return type;
}
//
// Get information about a given worker. This returns the nth worker of the
// specified type.
//
Worker *Manager::GetWorker(int index, TargetType type)
{
int i, worker_count;
// Make sure the desired worker exists.
if (index < 0 || index >= WorkerCount(type))
return NULL;
// Find the worker.
worker_count = WorkerCount();
for (i = 0; i < worker_count; i++) {
if (IsType(workers[i]->Type(), type)) {
if (!index--)
return workers[i];
}
}
ASSERT(0); // requested worker not found - should not happen
return NULL;
}
//
// Get the first worker having the specified name, if any.
//
Worker *Manager::GetWorkerByName(const char *wkr_name, const int wkr_id)
{
int i, worker_count;
if (!wkr_name) {
ErrorMessage("Invalid string in Manager::GetWorkerByName()");
return NULL;
}
worker_count = WorkerCount();
for (i = 0; i < worker_count; i++) {
if (strcmp(workers[i]->name, wkr_name) == 0 && workers[i]->id == wkr_id) {
return workers[i];
}
}
// Didn't find it (not an error).
return NULL;
}
//
// Adding a new worker to the worker list. The new worker is always added to
// the end of the list. A connection to the worker is also made
// * May use a given worker as a template.
// * May specify the new worker's name. (Ignored if src_worker is defined.)
//
Worker *Manager::AddWorker(TargetType type, Worker * src_worker, const CString & in_name)
{
Message msg;
Worker *new_worker;
// Adding the new worker to the manager.
if (WorkerCount() >= MAX_WORKERS)
return (NULL);
// Request that a new worker be spawned.
// The data of the message is the number of workers to spawn.
msg.purpose = ADD_WORKERS;
msg.data = 1;
if (Send(&msg) != MESSAGE_SIZE)
ErrorMessage("Message may not be sent correctly in Manager::AddWorker().");
if (Receive(&msg) != MESSAGE_SIZE)
ErrorMessage("Message may not be received correctly in Manager::AddWorker().");
// Verifying that the worker was created.
if (!msg.data)
return (NULL);
// Allocating space for the new worker under the manager.
new_worker = new Worker(this, type);
// Adding worker to end of the worker list.
workers.Add(new_worker);
if (!src_worker) {
// Set the name of the worker based on the number of workers for
// this manager
CString worker_name;
if (in_name.IsEmpty())
worker_name.Format("Worker %d", WorkerCount());
else
worker_name = in_name;
strcpy(new_worker->name, worker_name);
} else {
// Copy the template's name and other information.
new_worker->Clone(src_worker);
}
// Reassign the disambiguating IDs this manager's workers.
IndexWorkers();
return new_worker;
}
//
// Removing a worker from the list. Return FALSE if all workers have
// been removed.
//
BOOL Manager::RemoveWorker(int index, TargetType type)
{
Worker *worker;
int main_index;
// Get the desired worker.
if (!(worker = GetWorker(index, type))) {
ErrorMessage("Invalid worker in Manager::RemoveWorker().");
return FALSE;
}
main_index = worker->GetIndex();
// Informing Dynamo to remove the worker.
// The data of the message is the index of the worker to remove.
Send(main_index, EXIT);
// Remove the worker from memory.
workers.RemoveAt(main_index);
delete worker;
// Reassign the disambiguating IDs this manager's workers.
IndexWorkers();
return WorkerCount(type);
}
//
// Returns the number of workers in the worker list.
//
int Manager::WorkerCount(TargetType type)
{
int i, count = 0, worker_count;
worker_count = workers.GetSize();
for (i = 0; i < worker_count; i++) {
if (IsType(workers[i]->Type(), type))
count++;
}
return count;
}
//
// Number of targets for all workers under this manager.
//
int Manager::TargetCount(TargetType type)
{
int w, count = 0, wkr_count = WorkerCount();
for (w = 0; w < wkr_count; w++)
count += GetWorker(w)->TargetCount(type);
return count;
}
//
// Removing all cached disk information for manager and all its workers.
//
void Manager::RemoveDiskInfo()
{
int i, wkr_count;
// Deleting Disk_Info objects held in "disks" array
for (i = 0; i < InterfaceCount(GenericDiskType); i++)
delete disks[i];
// Deleting memory used by "disks" array itself
disks.RemoveAll();
// Removing all disk targets assigned to the manager's workers.
wkr_count = WorkerCount();
for (i = 0; i < wkr_count; i++)
GetWorker(i)->RemoveTargets(GenericDiskType);
}
//
// Removing all cached network information for manager and all its workers.
//
void Manager::RemoveNetInfo()
{
int i, net_count, wkr_count;
// Deleting network information referenced by "tcp" array
net_count = tcps.GetSize();
for (i = 0; i < net_count; i++)
delete tcps[i];
tcps.RemoveAll();
net_count = vis.GetSize();
for (i = 0; i < net_count; i++)
delete vis[i];
vis.RemoveAll();
// Removing all network targets assigned to the manager's workers.
wkr_count = WorkerCount();
for (i = 0; i < wkr_count; i++)
GetWorker(i)->RemoveTargets(GenericNetType);
}
//
// Setting the test specifications for all workers.
//
BOOL Manager::SetAccess(int access_index)
{
int w, wkr_count = WorkerCount();
for (w = 0; w < wkr_count; w++) {
if (!GetWorker(w)->SetAccess(access_index))
return FALSE;
}
return TRUE;
}
//
// Initializing results for the manager.
//
void Manager::ResetResults(int which_perf)
{
if ((which_perf < 0) || (which_perf >= MAX_PERF))
return;
memset(&(results[which_perf]), 0, sizeof(Results));
}
//
// Resetting all results related to the manager. This includes resetting all results
// for its workers and whatever results a worker relies on.
//
void Manager::ResetAllResults()
{
int w, wkr_count = WorkerCount();
ResetResults(WHOLE_TEST_PERF);
ResetResults(LAST_UPDATE_PERF);
// Resetting results for all worker threads as well.
for (w = 0; w < wkr_count; w++)
GetWorker(w)->ResetAllResults();
}
//
// Removing all targets from manager's workers.
//
void Manager::RemoveTargets(TargetType type)
{
int w;
// A target might be a network client, so always check against the current
// worker count (WorkerCount()) and not a saved value.
for (w = 0; w < WorkerCount(); w++)
GetWorker(w)->RemoveTargets(type);
}
//
// Resets a worker's drives to indicate that they are not running.
//
void Manager::ClearActiveTargets()
{
int w, wkr_count = WorkerCount();
for (w = 0; w < wkr_count; w++)
GetWorker(w)->ClearActiveTargets();
}
//
// Marks which targets accessible by a worker are to run, and sending the
// worker the list. Returns number of targets actually set (IOERROR in case of error).
//
int Manager::SetActiveTargets(int worker_index, int targets_to_set)
{
return GetWorker(worker_index)->SetActiveTargets(targets_to_set);
}
//
// Peeking to see if a given worker has sent back a message that's waiting
// in its message queue.
//
DWORD Manager::Peek(int worker_index)
{
return port->Peek();
}
//
// Sending a message to Dynamo.
//
DWORDLONG Manager::Send(Message * msg)
{
return port->Send(msg);
}
DWORDLONG Manager::SendData(Data_Message * data_msg)
{
return port->Send(data_msg, DATA_MESSAGE_SIZE);
}
DWORDLONG Manager::Send(int data, int purpose)
{
Message msg;
msg.purpose = purpose;
msg.data = data;
return Send(&msg);
}
//
// Getting a message from Dynamo.
//
DWORDLONG Manager::Receive(Message * msg)
{
return port->Receive(msg);
}
DWORDLONG Manager::ReceiveData(Data_Message * data_msg)
{
return port->Receive(data_msg, DATA_MESSAGE_SIZE);
}
DWORDLONG Manager::Receive()
{
Message msg;
return Receive(&msg);
}
//
// Updating the list of targets known by a manager. This retrieves the
// target information from Dynamo.
//
void Manager::UpdateTargetLists()
{
// Query worker for list of available targets.
Send(MANAGER, REPORT_TARGETS);
// Reset information about currently stored targets.
RemoveDiskInfo();
RemoveNetInfo();
// Get the reply containing the target information and initialize the lists.
InitTargetList(&disks);
InitTargetList(&tcps);
InitTargetList(&vis);
}
//
// Initialize the specified target list using the target specifications
// given in the data message.
//
void Manager::InitTargetList(CTypedPtrArray < CPtrArray, Target_Spec * >*targets)
{
int i;
Data_Message *data_msg;
Target_Spec *target_spec;
data_msg = new Data_Message;
// Receive the target specifications in a data message.
ReceiveData(data_msg);
// Add the targets to the specified array.
for (i = 0; i < data_msg->count; i++) {
target_spec = new Target_Spec;
memcpy(target_spec, &data_msg->data.targets[i], sizeof(Target_Spec));
// Initialize the target specs to the default settings.
target_spec->queue_depth = 1;
target_spec->test_connection_rate = FALSE;
target_spec->trans_per_conn = 1;
targets->Add(target_spec);
}
delete data_msg;
}
//
// Sets each workers targets to run for the next test. This call will result
// in each worker sending their active target list to Dynamo.
//
BOOL Manager::SetTargets()
{
int w, wkr_count = WorkerCount();
for (w = 0; w < wkr_count; w++) {
if (!GetWorker(w)->SetTargets())
return FALSE;
}
return TRUE;
}
//
// Setting targets that need to be prepared for the specified worker.
//
void Manager::SetTargetsToPrepare(int worker_index)
{
GetWorker(worker_index)->SetTargetsToPrepare();
}
//
// Receives the answer to a prepare command.
//
BOOL Manager::PreparedAnswer()
{
Message msg;
int t, i;
// Get the notification message that the prepare is done.
Receive(&msg);
// Verify that all targets were successfully prepared.
if (!msg.data)
return FALSE;
Worker *wkr;
int w, wkr_count = WorkerCount();
for (w = 0; w < wkr_count; w++) {
wkr = GetWorker(w);
// Update the ready status of all disk targets that the worker prepared.
for (t = 0; t < wkr->TargetCount(); t++) {
// Find the worker's corresponding disk in the manager's disk list.
for (i = 0; i < InterfaceCount(GenericDiskType); i++) {
if (!strcmp(wkr->GetTarget(t)->spec.name, GetInterface(i, GenericDiskType)->name)) {
GetInterface(i, GenericDiskType)->disk_info.ready = TRUE;
}
}
}
}
// Update the Targets display if a manager or worker is selected,
// in case the manager or worker that just finished preparing its
// drives is currently displayed. This will update the icon.
theApp.pView->m_pPageDisk->ShowData();
return TRUE;
}
//
// Saving the manager's results to a file along with all of its workers and
// their targets.
//
void Manager::SaveResults(ostream * file, int access_index, int result_type)
{
int stat;
char specname[MAX_WORKER_NAME];
if (!ActiveInCurrentTest())
return;
// Save manager's results.
(*file) << "MANAGER" << "," << name << "," << GetCommonAccessSpec(access_index, specname)
<< "," // Space for managers running.
<< "," << WorkerCount(ActiveType)
<< "," << TargetCount(ActiveType) + WorkerCount((TargetType) (GenericClientType | ActiveType))
<< "," << results[WHOLE_TEST_PERF].IOps
<< "," << results[WHOLE_TEST_PERF].read_IOps
<< "," << results[WHOLE_TEST_PERF].write_IOps
<< "," << results[WHOLE_TEST_PERF].MBps_Bin
<< "," << results[WHOLE_TEST_PERF].read_MBps_Bin
<< "," << results[WHOLE_TEST_PERF].write_MBps_Bin
<< "," << results[WHOLE_TEST_PERF].MBps_Dec
<< "," << results[WHOLE_TEST_PERF].read_MBps_Dec
<< "," << results[WHOLE_TEST_PERF].write_MBps_Dec
<< "," << results[WHOLE_TEST_PERF].transactions_per_second
<< "," << results[WHOLE_TEST_PERF].connections_per_second
<< "," << results[WHOLE_TEST_PERF].ave_latency
<< "," << results[WHOLE_TEST_PERF].ave_read_latency
<< "," << results[WHOLE_TEST_PERF].ave_write_latency
<< "," << results[WHOLE_TEST_PERF].ave_transaction_latency
<< "," << results[WHOLE_TEST_PERF].ave_connection_latency
<< "," << results[WHOLE_TEST_PERF].max_latency
<< "," << results[WHOLE_TEST_PERF].max_read_latency
<< "," << results[WHOLE_TEST_PERF].max_write_latency
<< "," << results[WHOLE_TEST_PERF].max_transaction_latency
<< "," << results[WHOLE_TEST_PERF].max_connection_latency
<< "," << results[WHOLE_TEST_PERF].total_errors
<< "," << results[WHOLE_TEST_PERF].raw.read_errors << "," << results[WHOLE_TEST_PERF].raw.write_errors
// Save raw result information as well.
<< "," << results[WHOLE_TEST_PERF].raw.bytes_read
<< "," << results[WHOLE_TEST_PERF].raw.bytes_written
<< "," << results[WHOLE_TEST_PERF].raw.read_count
<< "," << results[WHOLE_TEST_PERF].raw.write_count
<< "," << results[WHOLE_TEST_PERF].raw.connection_count << ",";
if (GetConnectionRate(ActiveType) == ENABLED_VALUE)
(*file) << GetTransPerConn(ActiveType);
else
(*file) << AMBIGUOUS_VALUE;
(*file) << "," << results[WHOLE_TEST_PERF].raw.read_latency_sum
<< "," << results[WHOLE_TEST_PERF].raw.write_latency_sum
<< "," << results[WHOLE_TEST_PERF].raw.transaction_latency_sum
<< "," << results[WHOLE_TEST_PERF].raw.connection_latency_sum
<< "," << results[WHOLE_TEST_PERF].raw.max_raw_read_latency
<< "," << results[WHOLE_TEST_PERF].raw.max_raw_write_latency
<< "," << results[WHOLE_TEST_PERF].raw.max_raw_transaction_latency
<< "," << results[WHOLE_TEST_PERF].raw.max_raw_connection_latency
<< "," << results[WHOLE_TEST_PERF].raw.counter_time;
(*file) << "," << GetDiskStart((TargetType) (GenericDiskType | ActiveType))
<< "," << GetDiskSize((TargetType) (GenericDiskType | ActiveType))
<< "," << GetQueueDepth(ActiveType);
for (stat = 0; stat < CPU_UTILIZATION_RESULTS; stat++)
(*file) << "," << results[WHOLE_TEST_PERF].CPU_utilization[stat];
(*file) << "," << timer_resolution
<< "," << results[WHOLE_TEST_PERF].CPU_utilization[CPU_IRQ]
<< "," << results[WHOLE_TEST_PERF].CPU_effectiveness;
for (stat = 0; stat < NI_COMBINE_RESULTS; stat++)
(*file) << "," << results[WHOLE_TEST_PERF].ni_statistics[stat];
for (stat = 0; stat < TCP_RESULTS; stat++)
(*file) << "," << results[WHOLE_TEST_PERF].tcp_statistics[stat];
for (int x = 0; x < LATENCY_BIN_SIZE; x++) {
(*file) << "," << results[WHOLE_TEST_PERF].raw.latency_bin[x];
}
(*file) << endl;
// Save individual CPU results.
for (int cpu = 0; cpu < processors; cpu++) {
(*file) << "PROCESSOR" << "," << "CPU " << cpu << ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,";
for (stat = 0; stat < CPU_UTILIZATION_RESULTS; stat++)
(*file) << "," << results[WHOLE_TEST_PERF].individual_CPU_utilization[cpu][stat];
(*file) << "," << timer_resolution
<< "," << results[WHOLE_TEST_PERF].individual_CPU_utilization[cpu][CPU_IRQ]
<< ","; // Space for CPU_effectiveness (no way to calculate IOs per processor)
for (stat = 0; stat < NI_COMBINE_RESULTS + TCP_RESULTS; stat++)
(*file) << ","; // space for network results
(*file) << endl;
}
// If requested, save workers' results.
if (result_type == RecordAll || result_type == RecordNoTargets) {
for (int i = 0; i < WorkerCount(); i++)
{
GetWorker(i)->SaveResults(file, access_index, result_type);
GetWorker(i)->SaveResultsInstantaneousWorkerAverage(access_index, result_type);
}
}
}
//
// Updating the results stored with the manager.
//
void Manager::UpdateResults(int which_perf, bool instantaneousDump)
{
Worker *worker;
Data_Message *data_msg;
CPU_Results *cpu_results;
Net_Results *net_results;
_int64 start_perf_time, end_perf_time;
int i, stat; // loop control variables
if ((which_perf < 0) || (which_perf >= MAX_PERF))
return;
ResetResults(which_perf);
// Dynamo will send one reply for itself and one for every worker running.
// Send appropriate request for results to manager.
if (which_perf == WHOLE_TEST_PERF) {
if (Send(MANAGER, REPORT_RESULTS) == PORT_ERROR)
return;
} else // which_perf == LAST_UPDATE_PERF
{
if (Send(MANAGER, REPORT_UPDATE) == PORT_ERROR)
return;
}
data_msg = new Data_Message;
// Get results from manager.
if (ReceiveData(data_msg) == PORT_ERROR)
{
delete data_msg;
return;
}
cpu_results = &(data_msg->data.manager_results.cpu_results);
net_results = &(data_msg->data.manager_results.net_results);
start_perf_time = data_msg->data.manager_results.time_counter[FIRST_SNAPSHOT];
end_perf_time = data_msg->data.manager_results.time_counter[LAST_SNAPSHOT];
// Reset aggregate related utilizations.
for (stat = 0; stat < CPU_RESULTS; stat++)
results[which_perf].CPU_utilization[stat] = (double)0;
for (stat = 0; stat < NI_COMBINE_RESULTS; stat++)
results[which_perf].ni_statistics[stat] = (double)0;
// Loop though all CPUs.
for (i = 0; i < processors; i++) {
// Loop through the utilization counters.
for (stat = 0; stat < CPU_RESULTS; stat++) {
// Storing returned CPU utilization statistics.
results[which_perf].individual_CPU_utilization[i][stat] = cpu_results->CPU_utilization[i][stat];
results[which_perf].CPU_utilization[stat] += cpu_results->CPU_utilization[i][stat]; // calc. ave. below
}
}
// Determine average aggregate CPU related utilizations.
// Interrupts per second is a total, so is not averaged across CPUs.
if (processors) {
for (stat = 0; stat < CPU_UTILIZATION_RESULTS; stat++)
results[which_perf].CPU_utilization[stat] /= processors;
}
// Record all network related statistics.
for (stat = 0; stat < TCP_RESULTS; stat++)
results[which_perf].tcp_statistics[stat] = net_results->tcp_stats[stat];
for (i = 0; i < net_results->ni_count; i++) {
results[which_perf].ni_statistics[NI_PACKETS] += net_results->ni_stats[i][NI_PACKETS];
results[which_perf].ni_statistics[NI_ERRORS] += net_results->ni_stats[i][NI_OUT_ERRORS];
results[which_perf].ni_statistics[NI_ERRORS] += net_results->ni_stats[i][NI_IN_ERRORS];
}
//
// Update Worker Results
//
for (i = 0; i < WorkerCount(); i++) {
worker = GetWorker(i);
// Only update the results of workers active in the current test.
if (!worker->ActiveInCurrentTest()) {
// Reset the results of idle workers to prevent any older results
// from being visible.
worker->ResetAllResults();
continue;
}
// Receive an update from a worker and process the results.
worker->UpdateResults(which_perf, instantaneousDump);
// Recording maximum time any of the workers ran.
if (worker->results[which_perf].raw.counter_time > results[which_perf].raw.counter_time)
results[which_perf].raw.counter_time = worker->results[which_perf].raw.counter_time;
// Recording error results.
results[which_perf].total_errors += worker->results[which_perf].total_errors;
results[which_perf].raw.read_errors += worker->results[which_perf].raw.read_errors;
results[which_perf].raw.write_errors += worker->results[which_perf].raw.write_errors;
// Recording results related to the number of I/Os completed.
results[which_perf].IOps += worker->results[which_perf].IOps;
results[which_perf].read_IOps += worker->results[which_perf].read_IOps;
results[which_perf].write_IOps += worker->results[which_perf].write_IOps;
results[which_perf].raw.read_count += worker->results[which_perf].raw.read_count;
results[which_perf].raw.write_count += worker->results[which_perf].raw.write_count;
// Recording throughput results.
results[which_perf].MBps_Bin += worker->results[which_perf].MBps_Bin;
results[which_perf].read_MBps_Bin += worker->results[which_perf].read_MBps_Bin;
results[which_perf].write_MBps_Bin += worker->results[which_perf].write_MBps_Bin;
results[which_perf].MBps_Dec += worker->results[which_perf].MBps_Dec;
results[which_perf].read_MBps_Dec += worker->results[which_perf].read_MBps_Dec;
results[which_perf].write_MBps_Dec += worker->results[which_perf].write_MBps_Dec;
results[which_perf].raw.bytes_read += worker->results[which_perf].raw.bytes_read;
results[which_perf].raw.bytes_written += worker->results[which_perf].raw.bytes_written;
// Recording results related to the number of transactions completed.
results[which_perf].transactions_per_second += worker->results[which_perf].transactions_per_second;
results[which_perf].raw.transaction_count += worker->results[which_perf].raw.transaction_count;
// Recording results related to the number of connections completed.
results[which_perf].connections_per_second += worker->results[which_perf].connections_per_second;
results[which_perf].raw.connection_count += worker->results[which_perf].raw.connection_count;
// Recording maximum latency results.
if (results[which_perf].max_latency < worker->results[which_perf].max_latency)
results[which_perf].max_latency = worker->results[which_perf].max_latency;
if (results[which_perf].max_read_latency < worker->results[which_perf].max_read_latency) {
results[which_perf].max_read_latency = worker->results[which_perf].max_read_latency;
results[which_perf].raw.max_raw_read_latency =
worker->results[which_perf].raw.max_raw_read_latency;
}
if (results[which_perf].max_write_latency < worker->results[which_perf].max_write_latency) {
results[which_perf].max_write_latency = worker->results[which_perf].max_write_latency;
results[which_perf].raw.max_raw_write_latency =
worker->results[which_perf].raw.max_raw_write_latency;
}
if (results[which_perf].max_transaction_latency < worker->results[which_perf].max_transaction_latency) {
results[which_perf].max_transaction_latency =
worker->results[which_perf].max_transaction_latency;
results[which_perf].raw.max_raw_transaction_latency =
worker->results[which_perf].raw.max_raw_transaction_latency;
}
if (results[which_perf].max_connection_latency < worker->results[which_perf].max_connection_latency) {
results[which_perf].max_connection_latency = worker->results[which_perf].max_connection_latency;
results[which_perf].raw.max_raw_connection_latency =
worker->results[which_perf].raw.max_raw_connection_latency;
}
results[which_perf].raw.read_latency_sum += worker->results[which_perf].raw.read_latency_sum;
results[which_perf].raw.write_latency_sum += worker->results[which_perf].raw.write_latency_sum;
results[which_perf].raw.transaction_latency_sum +=
worker->results[which_perf].raw.transaction_latency_sum;
results[which_perf].raw.connection_latency_sum +=
worker->results[which_perf].raw.connection_latency_sum;
for (int x = 0; x < LATENCY_BIN_SIZE; x++)
results[which_perf].raw.latency_bin[x] += worker->results[which_perf].raw.latency_bin[x];
// Copying results only reported for the manager to the workers.
// This allows the results to be displayed in the results page in the GUI.
for (stat = 0; stat < CPU_RESULTS; stat++)
worker->results[which_perf].CPU_utilization[stat] = results[which_perf].CPU_utilization[stat];
for (stat = 0; stat < TCP_RESULTS; stat++)
worker->results[which_perf].tcp_statistics[stat] = results[which_perf].tcp_statistics[stat];
for (stat = 0; stat < NI_COMBINE_RESULTS; stat++)
worker->results[which_perf].ni_statistics[stat] = results[which_perf].ni_statistics[stat];
}
// Calculate CPU_effectiveness (number of IOs per second divided by CPU efficiency)
if (results[which_perf].CPU_utilization[CPU_TOTAL_UTILIZATION] != (double)0) // avoid a divide by zero
results[which_perf].CPU_effectiveness =
results[which_perf].IOps / results[which_perf].CPU_utilization[CPU_TOTAL_UTILIZATION];
else
results[which_perf].CPU_effectiveness = (double)0;
// Calculating average latencies.
if (results[which_perf].raw.read_count || results[which_perf].raw.write_count) {
results[which_perf].ave_latency =
(double)(_int64) (results[which_perf].raw.read_latency_sum +
results[which_perf].raw.write_latency_sum)
* (double)1000 / timer_resolution /
(double)(_int64) (results[which_perf].raw.read_count +
results[which_perf].raw.write_count);
if (results[which_perf].raw.read_count)
results[which_perf].ave_read_latency =
(double)(_int64) results[which_perf].raw.read_latency_sum * (double)1000 /
timer_resolution / (double)(_int64) results[which_perf].raw.read_count;
else
results[which_perf].ave_read_latency = (double)0;
if (results[which_perf].raw.write_count)
results[which_perf].ave_write_latency =
(double)(_int64) results[which_perf].raw.write_latency_sum * (double)1000 /
timer_resolution / (double)(_int64) results[which_perf].raw.write_count;
else
results[which_perf].ave_write_latency = (double)0;
if (results[which_perf].raw.transaction_count) {
results[which_perf].ave_transaction_latency =
(double)(_int64) results[which_perf].raw.transaction_latency_sum * (double)1000 /
timer_resolution / (double)(_int64) (results[which_perf].raw.transaction_count);
} else {
results[which_perf].ave_transaction_latency = (double)0;
}
} else {
results[which_perf].ave_latency = (double)0;
results[which_perf].ave_read_latency = (double)0;
results[which_perf].ave_write_latency = (double)0;
results[which_perf].ave_transaction_latency = (double)0;
}
// Calculating average connection time.
if (results[which_perf].raw.connection_count) {
results[which_perf].ave_connection_latency =
(double)(_int64) (results[which_perf].raw.connection_latency_sum) * (double)1000 /
timer_resolution / (double)(_int64) results[which_perf].raw.connection_count;
} else {
results[which_perf].ave_connection_latency = (double)0;
}
delete data_msg;
}
///////////////////////////////////////////////////////////////////////////////
//
// The following functions update the values for the starting sector, the
// number of sectors to access, the queue depth, and the disk selection.
// On the Manager level, it propagates down the tree to all the workers and
// calls the workers function.
//
///////////////////////////////////////////////////////////////////////////////
void Manager::SetDiskSize(DWORDLONG disk_size)
{
int w, wkr_count;
// Loop through all the workers.
wkr_count = WorkerCount(GenericDiskType);
for (w = 0; w < wkr_count; w++)
GetWorker(w, GenericDiskType)->SetDiskSize(disk_size);
}
void Manager::SetDiskStart(DWORDLONG disk_start)
{
int w, wkr_count;
// Loop through all the workers.
wkr_count = WorkerCount(GenericDiskType);
for (w = 0; w < wkr_count; w++)
GetWorker(w, GenericDiskType)->SetDiskStart(disk_start);
}
void Manager::SetQueueDepth(int queue_depth, TargetType type)
{
int w, wkr_count;
// Loop through all the workers.
wkr_count = WorkerCount(type);
for (w = 0; w < wkr_count; w++)
GetWorker(w, GenericDiskType)->SetQueueDepth(queue_depth);
}
void Manager::SetMaxSends(int max_sends)
{
int w, wkr_count;
// Loop through all the workers.
wkr_count = WorkerCount(VIServerType);
for (w = 0; w < wkr_count; w++)
GetWorker(w, VIServerType)->SetMaxSends(max_sends);
}
void Manager::SetLocalNetworkInterface(int iface_index)
{
int w, wkr_count;
// Loop through all the workers.
wkr_count = WorkerCount(GenericServerType);
for (w = 0; w < wkr_count; w++)
GetWorker(w, GenericServerType)->SetLocalNetworkInterface(iface_index);
}
void Manager::SetConnectionRate(BOOL test_connection_rate, TargetType type)
{
int w, wkr_count;
// Loop through all the workers.
wkr_count = WorkerCount(type);
for (w = 0; w < wkr_count; w++)
GetWorker(w, type)->SetConnectionRate(test_connection_rate);