Changeset f3e87af for benchmark/io
- Timestamp:
- Jan 19, 2021, 3:32:14 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:
- 2fab24e3
- Parents:
- 3acbf89
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified benchmark/io/http/http_ring.cpp ¶
r3acbf89 rf3e87af 45 45 46 46 int endfd; 47 unsigned entries;47 struct io_uring * ring; 48 48 49 49 struct { … … 297 297 struct options_t & opt = *(struct options_t *)arg; 298 298 299 struct io_uring ring_storage; 300 struct io_uring * ring = &ring_storage; 301 io_uring_queue_init(opt.entries, ring, 0); 299 struct io_uring * ring = opt.ring; 302 300 303 301 char endfd_buf[8]; … … 348 346 } 349 347 350 io_uring_queue_exit(ring);351 352 348 return (void*)count; 353 349 } 354 350 355 351 //========================================================= 352 struct __attribute__((aligned(128))) aligned_ring { 353 struct io_uring storage; 354 }; 355 356 356 #include <bit> 357 357 … … 371 371 unsigned entries = 256; 372 372 unsigned backlog = 10; 373 bool attach = false; 373 374 374 375 //=================== 375 376 // Arguments 376 377 int c; 377 while ((c = getopt (argc, argv, "t:p:e:b: ")) != -1) {378 while ((c = getopt (argc, argv, "t:p:e:b:a")) != -1) { 378 379 switch (c) 379 380 { … … 390 391 backlog = atoi(optarg); 391 392 break; 393 case 'a': 394 attach = true; 395 break; 392 396 case '?': 393 397 default: 394 std::cerr << "Usage: -t <threads> -p <port> -e <entries> -b <backlog> " << std::endl;398 std::cerr << "Usage: -t <threads> -p <port> -e <entries> -b <backlog> -a" << std::endl; 395 399 return EXIT_FAILURE; 396 400 } … … 464 468 //=================== 465 469 // Run Server Threads 466 std::cout << "Starting " << nthreads << " Threads" << std::endl; 467 pthread_t thrd_hdls[nthreads]; 468 options_t thrd_opts[nthreads]; 470 std::cout << "Starting " << nthreads << " Threads"; 471 if(attach) { 472 std::cout << " with attached Rings"; 473 } 474 std::cout << std::endl; 475 476 aligned_ring thrd_rings[nthreads]; 477 pthread_t thrd_hdls[nthreads]; 478 options_t thrd_opts[nthreads]; 469 479 for(unsigned i = 0; i < nthreads; i++) { 480 if(!attach || i == 0) { 481 io_uring_queue_init(entries, &thrd_rings[i].storage, 0); 482 } 483 else { 484 struct io_uring_params p; 485 memset(&p, 0, sizeof(p)); 486 p.flags = IORING_SETUP_ATTACH_WQ; 487 p.wq_fd = thrd_rings[0].storage.ring_fd; 488 io_uring_queue_init_params(entries, &thrd_rings[i].storage, &p); 489 } 490 470 491 thrd_opts[i].acpt.sockfd = server_fd; 471 492 thrd_opts[i].acpt.addr = (struct sockaddr *)&address; 472 493 thrd_opts[i].acpt.addrlen = (socklen_t*)&addrlen; 473 494 thrd_opts[i].acpt.flags = 0; 474 thrd_opts[i].endfd = efd;475 thrd_opts[i]. entries = entries;495 thrd_opts[i].endfd = efd; 496 thrd_opts[i].ring = &thrd_rings[i].storage; 476 497 477 498 int ret = pthread_create(&thrd_hdls[i], nullptr, proc_loop, &thrd_opts[i]); … … 527 548 total += thrd_opts[i].result.subs; 528 549 count += thrd_opts[i].result.cnts; 550 551 io_uring_queue_exit(thrd_opts[i].ring); 529 552 } 530 553 std::cout << "done" << std::endl;
Note: See TracChangeset
for help on using the changeset viewer.