Changeset c05c58f for benchmark/io
- Timestamp:
- Jan 27, 2021, 1:02:21 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 761a246
- Parents:
- 7cc532b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/http_ring.cpp
r7cc532b rc05c58f 53 53 }; 54 54 55 volatile size_t total = 0; 56 volatile size_t count = 0; 57 55 58 //========================================================= 56 59 static struct io_uring_sqe * get_sqe(struct io_uring * ring) { … … 64 67 65 68 static void submit(struct io_uring * ) { 69 // io_uring_sqe_set_flags(sqe, IOSQE_ASYNC); 66 70 // io_uring_submit(ring); 67 71 } … … 305 309 ring_accept(ring, opt.acpt.sockfd, opt.acpt.addr, opt.acpt.addrlen, opt.acpt.flags); 306 310 311 int reset = 1; 307 312 bool done = false; 308 313 while(!done) { … … 345 350 346 351 io_uring_cqe_seen(ring, cqe); 352 reset--; 353 if(reset == 0) { 354 size_t ltotal = opt.result.subs; 355 size_t lcount = opt.result.cnts; 356 357 std::cout << "Submit average: " << ltotal << "/" << lcount << "(" << (((double)ltotal) / lcount) << ")" << std::endl; 358 reset = 100000 + (100000 * (ring->ring_fd % 5)); 359 } 347 360 } 348 361 … … 373 386 unsigned backlog = 10; 374 387 bool attach = false; 388 bool sqpoll = false; 375 389 376 390 //=================== 377 391 // Arguments 378 392 int c; 379 while ((c = getopt (argc, argv, "t:p:e:b:a ")) != -1) {393 while ((c = getopt (argc, argv, "t:p:e:b:aS")) != -1) { 380 394 switch (c) 381 395 { … … 395 409 attach = true; 396 410 break; 411 case 'S': 412 sqpoll = true; 413 break; 397 414 case '?': 398 415 default: 399 std::cerr << "Usage: -t <threads> -p <port> -e <entries> -b <backlog> -a " << std::endl;416 std::cerr << "Usage: -t <threads> -p <port> -e <entries> -b <backlog> -aS" << std::endl; 400 417 return EXIT_FAILURE; 401 418 } … … 478 495 pthread_t thrd_hdls[nthreads]; 479 496 options_t thrd_opts[nthreads]; 497 bool fast_poll = true; 498 bool nfix_sqpl = true; 480 499 for(unsigned i = 0; i < nthreads; i++) { 481 if(!attach || i == 0) { 482 io_uring_queue_init(entries, &thrd_rings[i].storage, 0); 483 } 484 else { 485 struct io_uring_params p; 486 memset(&p, 0, sizeof(p)); 487 p.flags = IORING_SETUP_ATTACH_WQ; 500 struct io_uring_params p = { }; 501 if(sqpoll) { 502 p.flags |= IORING_SETUP_SQPOLL; 503 p.sq_thread_idle = 100; 504 } 505 506 if (attach && i != 0) { 507 p.flags |= IORING_SETUP_ATTACH_WQ; 488 508 p.wq_fd = thrd_rings[0].storage.ring_fd; 489 io_uring_queue_init_params(entries, &thrd_rings[i].storage, &p); 490 } 509 } 510 io_uring_queue_init_params(entries, &thrd_rings[i].storage, &p); 511 512 if(0 == (p.features & IORING_FEAT_FAST_POLL )) { fast_poll = false; } 513 if(0 == (p.features & IORING_FEAT_SQPOLL_NONFIXED)) { nfix_sqpl = false; } 491 514 492 515 thrd_opts[i].acpt.sockfd = server_fd; … … 503 526 } 504 527 } 528 529 if( fast_poll) std::cout << "Fast Poll Present" << std::endl; 530 if(!nfix_sqpl) std::cout << "Non-Fixed SQ Poll not Present" << std::endl; 505 531 506 532 //=================== … … 537 563 //=================== 538 564 (std::cout << "Stopping Threads Done... ").flush(); 539 size_t total = 0;540 size_t count = 0;541 565 for(unsigned i = 0; i < nthreads; i++) { 542 566 void * retval; … … 546 570 exit(EXIT_FAILURE); 547 571 } 548 // total += (size_t)retval;549 total += thrd_opts[i].result.subs;550 count += thrd_opts[i].result.cnts;551 572 552 573 io_uring_queue_exit(thrd_opts[i].ring); 553 574 } 554 575 std::cout << "done" << std::endl; 555 std::cout << "Submit average: " << total << "/" << count << "(" << (((double)total) / count) << ")" << std::endl;556 576 557 577 //===================
Note: See TracChangeset
for help on using the changeset viewer.