@@ -20,7 +20,6 @@ import java.time.format.DateTimeFormatter
2020import java.util.concurrent.LinkedBlockingQueue as BlockingQueue
2121import java.util.concurrent.ThreadLocalRandom
2222import java.util.concurrent.TimeUnit
23- import kotlin.math.abs
2423import kotlin.system.exitProcess
2524import kotlinx.serialization.SerialName
2625import kotlinx.serialization.Serializable
@@ -207,6 +206,7 @@ private val g_tests = mutableListOf<TestProfile>()
207206data class ConfigContext (
208207 val enabled : Boolean = false ,
209208 @SerialName(" num_users" ) val numUsers : Int = 0 ,
209+ @SerialName(" num_users_active" ) val numUsersActive : Int = USER_THREAD_QSIZE ,
210210 @SerialName(" num_threads" ) val numThreads : Int = 0 ,
211211 @SerialName(" user_params" ) val userParams : Map <String , JsonPrimitive > = mapOf(),
212212)
@@ -229,7 +229,7 @@ data class ConfigTest(
229229 @SerialName(" aps_rate" ) val throughputRate : Double = 0.0 ,
230230 @SerialName(" aps_rate_step_change" ) val throughputRateStepChange : Double = 0.0 ,
231231 @SerialName(" aps_rate_step_count" ) val throughputRateStepCount : Int = 1 ,
232- @SerialName(" worker_thread_queue_size " ) val workInProgress : Int = 0 ,
232+ @SerialName(" num_users_active " ) val numUsersActive : Int = 0 ,
233233 @SerialName(" scenario_actions" ) val actions : List <ConfigAction > = listOf(),
234234 @SerialName(" scenario_workflow" ) val workflow : String = " " ,
235235)
@@ -301,7 +301,7 @@ fun initConfig(text: String): String {
301301 // println("${k}")
302302 val e = entry.value
303303 if (e.enabled) {
304- val v = RuntimeContext (k, e.numUsers, e.numThreads, e.userParams)
304+ val v = RuntimeContext (k, e.numUsers, e.numUsersActive, e. numThreads, e.userParams)
305305 g_contexts.add(v)
306306 }
307307 }
@@ -323,7 +323,7 @@ fun initConfig(text: String): String {
323323 arrivalRate = e.throughputRate,
324324 arrivalRateStepChange = e.throughputRateStepChange,
325325 arrivalRateStepCount = e.throughputRateStepCount,
326- queueLengths = listOf (e.workInProgress) ,
326+ numUsersActive = e.numUsersActive ,
327327 actions =
328328 mutableListOf<Action >().apply {
329329 if (e.workflow.isEmpty()) {
@@ -392,28 +392,18 @@ val wthread_wait_stats = Histogram(histogramNumberOfSignificantValueDigits)
392392
393393/* -------------------------------------------------------------------------*/
394394
395- private fun getQueueLengths (context : RuntimeContext , test : TestProfile ): List <Int > {
396- val list: MutableList <Int > = mutableListOf ()
397- test.queueLengths.forEach { queueLength ->
398- list.add(
399- when {
400- queueLength == 0 ->
401- if (context.numThreads == 0 ) context.numUsers * USER_THREAD_QSIZE
402- else context.numThreads * USER_THREAD_QSIZE
403- queueLength > 0 ->
404- if (context.numThreads == 0 ) context.numUsers * queueLength
405- else context.numThreads * queueLength // Actions per Thread
406- else -> abs(queueLength) // Actions across all Threads
407- }
408- )
395+ private fun getQueueLengths (context : RuntimeContext , test : TestProfile ): Int {
396+ return if (test.numUsersActive != 0 ) {
397+ test.numUsersActive
398+ } else {
399+ context.numUsersActive
409400 }
410- return list
411401}
412402
413403/* -------------------------------------------------------------------------*/
414404
415405private fun getTest (context : RuntimeContext , test : TestProfile ): TestProfile {
416- return test.copy(queueLengths = getQueueLengths(context, test))
406+ return test.copy(numUsersActive = getQueueLengths(context, test))
417407}
418408
419409/* -------------------------------------------------------------------------*/
@@ -431,20 +421,12 @@ private fun createActionGenerator(list: List<Int>): Iterator<Int> {
431421
432422/* -------------------------------------------------------------------------*/
433423
434- private fun runTest (
435- testCase : TestProfile ,
436- contextId : Int ,
437- indexTestCase : Int ,
438- indexUserProfile : Int ,
439- queueLength : Int ,
440- ) {
424+ private fun runTest (testCase : TestProfile , contextId : Int , indexTestCase : Int , queueLength : Int ) {
441425 var cpuTime: Long = 0
442426 var tsBegin = java.time.LocalDateTime .now().format(formatter)
443427 val output = mutableListOf (" " )
444428 output.add(" ======================================================================" )
445- output.add(
446- " = [${contextId} ][${indexTestCase} ][${indexUserProfile} ][${queueLength} ] ${testCase.name} - $tsBegin "
447- )
429+ output.add(" = [${contextId} ][${indexTestCase} ][${queueLength} ] ${testCase.name} - $tsBegin " )
448430 output.add(" ======================================================================" )
449431 Console .put(output)
450432
@@ -574,7 +556,7 @@ private fun runTest(
574556 durationMillis,
575557 testCase,
576558 indexTestCase,
577- indexUserProfile ,
559+ 0 ,
578560 queueLength,
579561 tsBegin,
580562 tsEnd,
@@ -693,7 +675,7 @@ private fun runTest(
693675 durationMillis.toInt(),
694676 testCase,
695677 indexTestCase,
696- indexUserProfile ,
678+ 0 ,
697679 queueLength,
698680 tsBegin,
699681 tsEnd,
@@ -717,13 +699,7 @@ private fun runTest(
717699
718700 // Pre-warmup
719701 //
720- // Since we could have 1 or more population set sizes, only perform the
721- // start-up phase
722- // on the first set, i.e., with index 0.
723- //
724- if (indexUserProfile == 0 ) {
725- assignTasks(testCase.duration.startupDurationMillis, " PreWarmup" , 0 , 0 , 0.0 )
726- }
702+ assignTasks(testCase.duration.startupDurationMillis, " PreWarmup" , 0 , 0 , 0.0 )
727703
728704 // Warmup
729705 timeMillisEnd = TimeUnit .NANOSECONDS .toMillis(System .nanoTime())
@@ -781,11 +757,14 @@ private fun runTulip(
781757 Console .put(" ======================================================================" )
782758 Console .put(" " )
783759 Console .put(" NUM_USERS = $MAX_NUM_USERS " )
760+ Console .put(" NUM_USERS_ACTIVE = ${context.numUsersActive} " )
784761 if (MAX_NUM_THREADS == 0 ) {
785762 MAX_NUM_THREADS = MAX_NUM_USERS
763+ Console .put(" NUM_VIRTUAL_THREADS = $MAX_NUM_THREADS " )
764+ } else {
765+ Console .put(" NUM_THREADS = $MAX_NUM_THREADS " )
766+ Console .put(" NUM_USERS_PER_THREAD = ${MAX_NUM_USERS / MAX_NUM_THREADS } " )
786767 }
787- Console .put(" NUM_THREADS = $MAX_NUM_THREADS " )
788- Console .put(" NUM_USERS_PER_THREAD = ${MAX_NUM_USERS / MAX_NUM_THREADS } " )
789768 if ((MAX_NUM_USERS / MAX_NUM_THREADS ) * MAX_NUM_THREADS != MAX_NUM_USERS ) {
790769 Console .put(" " )
791770 Console .put(" NUM_USERS should equal n*NUM_THREADS, where n >= 1" )
@@ -799,10 +778,9 @@ private fun runTulip(
799778 } else {
800779 g_workflow = workflows[x.workflow]
801780 }
802- x.queueLengths.forEachIndexed { indexUserProfile, queueLength ->
803- // Thread.sleep(5000)
804- runTest(x, contextId, indexTestCase, indexUserProfile, queueLength)
805- }
781+ val numUsersActive = x.numUsersActive
782+ // Thread.sleep(5000)
783+ runTest(x, contextId, indexTestCase, numUsersActive)
806784 g_workflow = null
807785 }
808786 }
0 commit comments