- Timestamp:
- Aug 7, 2019 12:44:16 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/storage/IoPerf.cpp
r80178 r80185 174 174 /** Size of the random write buffer in 512 byte blocks. */ 175 175 uint32_t cRandWriteBlocks512B; 176 /** Chance in percent to get a write. */ 177 unsigned uWriteChance; 176 178 /** Start timestamp. */ 177 179 uint64_t tsStart; … … 181 183 /** Sequential read write. */ 182 184 uint64_t offNextSeq; 185 /** Data for random acess. */ 186 struct 187 { 188 /** Number of valid entries in the bitmap. */ 189 uint32_t cBlocks; 190 /** Pointer to the bitmap marking accessed blocks. */ 191 uint8_t *pbMapAccessed; 192 /** Number of unaccessed blocks. */ 193 uint32_t cBlocksLeft; 194 } Rnd; 183 195 } Tst; 184 196 } IOPERFJOB; … … 283 295 /** Flag whether to open the file without caching enabled. */ 284 296 static bool g_fNoCache = true; 297 /** Write chance for mixed read/write tests. */ 298 static unsigned g_uWriteChance = 50; 285 299 286 300 /** @name Configured tests, this must match the IOPERFTEST order. … … 358 372 case IOPERFTEST_REV_READ: 359 373 return RTIOQUEUEOP_READ; 374 360 375 case IOPERFTEST_SEQ_READWRITE: 361 376 case IOPERFTEST_RND_READWRITE: 362 AssertMsgFailed(("Not implemented!\n")); 363 break; 377 { 378 uint32_t uRnd = RTRandAdvU32Ex(pJob->hRand, 0, 100); 379 return (uRnd < pJob->uWriteChance) ? RTIOQUEUEOP_WRITE : RTIOQUEUEOP_READ; 380 } 381 364 382 default: 365 383 AssertMsgFailed(("Invalid/unknown test selected: %d\n", pJob->enmTest)); … … 386 404 case IOPERFTEST_SEQ_WRITE: 387 405 case IOPERFTEST_SEQ_READ: 406 case IOPERFTEST_SEQ_READWRITE: 388 407 offNext = pJob->Tst.offNextSeq; 389 408 pJob->Tst.offNextSeq += pJob->cbIoBlock; … … 399 418 case IOPERFTEST_RND_WRITE: 400 419 case IOPERFTEST_RND_READ: 401 case IOPERFTEST_SEQ_READWRITE:402 420 case IOPERFTEST_RND_READWRITE: 403 AssertMsgFailed(("Not implemented!\n")); 404 break; 421 { 422 int idx = -1; 423 424 idx = ASMBitFirstClear(pJob->Tst.Rnd.pbMapAccessed, pJob->Tst.Rnd.cBlocks); 425 426 /* In case this is the last request we don't need to search further. */ 427 if (pJob->Tst.Rnd.cBlocksLeft > 1) 428 { 429 int idxIo; 430 idxIo = RTRandAdvU32Ex(pJob->hRand, idx, pJob->Tst.Rnd.cBlocks - 1); 431 432 /* 433 * If the bit is marked free use it, otherwise search for the next free bit 434 * and if that doesn't work use the first free bit. 435 */ 436 if (ASMBitTest(pJob->Tst.Rnd.pbMapAccessed, idxIo)) 437 { 438 idxIo = ASMBitNextClear(pJob->Tst.Rnd.pbMapAccessed, pJob->Tst.Rnd.cBlocks, idxIo); 439 if (idxIo != -1) 440 idx = idxIo; 441 } 442 else 443 idx = idxIo; 444 } 445 446 Assert(idx != -1); 447 offNext = (uint64_t)idx * pJob->cbIoBlock; 448 pJob->Tst.Rnd.cBlocksLeft--; 449 ASMBitSet(pJob->Tst.Rnd.pbMapAccessed, idx); 450 break; 451 } 405 452 default: 406 453 AssertMsgFailed(("Invalid/unknown test selected: %d\n", pJob->enmTest)); … … 500 547 static int ioPerfJobTestInit(PIOPERFJOB pJob) 501 548 { 549 int rc = VINF_SUCCESS; 550 502 551 switch (pJob->enmTest) 503 552 { … … 505 554 case IOPERFTEST_SEQ_WRITE: 506 555 case IOPERFTEST_SEQ_READ: 556 case IOPERFTEST_SEQ_READWRITE: 507 557 pJob->Tst.offNextSeq = 0; 508 558 break; … … 513 563 case IOPERFTEST_RND_WRITE: 514 564 case IOPERFTEST_RND_READ: 515 case IOPERFTEST_SEQ_READWRITE:516 565 case IOPERFTEST_RND_READWRITE: 517 AssertMsgFailed(("Not implemented!\n")); 518 break; 566 { 567 pJob->Tst.Rnd.cBlocks = (uint32_t)( pJob->cbTestSet / pJob->cbIoBlock 568 + (pJob->cbTestSet % pJob->cbIoBlock ? 1 : 0)); 569 pJob->Tst.Rnd.cBlocksLeft = pJob->Tst.Rnd.cBlocks; 570 pJob->Tst.Rnd.pbMapAccessed = (uint8_t *)RTMemAllocZ( pJob->Tst.Rnd.cBlocks / 8 571 + ((pJob->Tst.Rnd.cBlocks % 8) 572 ? 1 573 : 0)); 574 if (!pJob->Tst.Rnd.pbMapAccessed) 575 rc = VERR_NO_MEMORY; 576 break; 577 } 519 578 default: 520 579 AssertMsgFailed(("Invalid/unknown test selected: %d\n", pJob->enmTest)); … … 524 583 RTTestISub(ioPerfJobTestStringify(pJob->enmTest)); 525 584 pJob->tsStart = RTTimeNanoTS(); 526 return VINF_SUCCESS;585 return rc; 527 586 } 528 587 … … 546 605 case IOPERFTEST_REV_WRITE: 547 606 case IOPERFTEST_REV_READ: 607 case IOPERFTEST_SEQ_READWRITE: 548 608 break; /* Nothing to do. */ 549 609 550 610 case IOPERFTEST_RND_WRITE: 551 611 case IOPERFTEST_RND_READ: 552 case IOPERFTEST_SEQ_READWRITE:553 612 case IOPERFTEST_RND_READWRITE: 554 AssertMsgFailed(("Not implemented!\n"));613 RTMemFree(pJob->Tst.Rnd.pbMapAccessed); 555 614 break; 556 615 default: … … 575 634 case IOPERFTEST_REV_WRITE: 576 635 case IOPERFTEST_REV_READ: 636 case IOPERFTEST_SEQ_READWRITE: 577 637 return pJob->Tst.offNextSeq == pJob->cbTestSet; 578 638 case IOPERFTEST_RND_WRITE: 579 639 case IOPERFTEST_RND_READ: 580 case IOPERFTEST_SEQ_READWRITE:581 640 case IOPERFTEST_RND_READWRITE: 582 AssertMsgFailed(("Not implemented!\n"));641 return pJob->Tst.Rnd.cBlocksLeft == 0; 583 642 break; 584 643 default: … … 712 771 { 713 772 int rc = VINF_SUCCESS; 714 bool fShutdown = false; 715 716 do 773 774 for (;;) 717 775 { 718 776 /* Synchronize with the other jobs and the master. */ … … 721 779 break; 722 780 781 if (pJob->enmTest == IOPERFTEST_SHUTDOWN) 782 break; 783 723 784 rc = ioPerfJobTestIoLoop(pJob); 724 } while ( RT_SUCCESS(rc) 725 && !fShutdown); 785 if (RT_FAILURE(rc)) 786 break; 787 } 726 788 727 789 return rc; … … 776 838 } 777 839 } 840 841 if (RT_SUCCESS(rc)) 842 return rc; 843 844 RTMemPageFree(pJob->pbRandWrite, IOPERF_RAND_DATA_BUF_FACTOR * pJob->cbIoBlock); 778 845 } 779 846 } … … 798 865 * @param cbIoBlock I/O block size for the given job. 799 866 * @param cReqsMax Maximum number of concurrent requests for this job. 867 * @param uWriteChance The write chance for mixed read/write tests. 800 868 */ 801 869 static int ioPerfJobInit(PIOPERFJOB pJob, PIOPERFMASTER pMaster, uint32_t idJob, 802 870 const char *pszIoEngine, const char *pszTestDir, 803 871 IOPERFTESTSETPREP enmPrepMethod, 804 uint64_t cbTestSet, size_t cbIoBlock, uint32_t cReqsMax) 872 uint64_t cbTestSet, size_t cbIoBlock, uint32_t cReqsMax, 873 unsigned uWriteChance) 805 874 { 806 875 pJob->pMaster = pMaster; … … 813 882 pJob->cReqsMax = cReqsMax; 814 883 pJob->cbIoReqReadBuf = cReqsMax * cbIoBlock; 884 pJob->uWriteChance = uWriteChance; 815 885 816 886 int rc = VINF_SUCCESS; … … 946 1016 int rc = ioPerfJobInit(&Job, NULL, 0, g_pszIoEngine, 947 1017 g_szDir, IOPERFTESTSETPREP_SET_SZ, 948 g_cbTestSet, g_cbIoBlock, g_cReqsMax); 1018 g_cbTestSet, g_cbIoBlock, g_cReqsMax, 1019 g_uWriteChance); 949 1020 if (RT_SUCCESS(rc)) 950 1021 {
Note:
See TracChangeset
for help on using the changeset viewer.