Changeset c05c58f for benchmark/io/http


Ignore:
Timestamp:
Jan 27, 2021, 1:02:21 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
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
Message:

Minor improvements to http_ring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/http_ring.cpp

    r7cc532b rc05c58f  
    5353};
    5454
     55volatile size_t total = 0;
     56volatile size_t count = 0;
     57
    5558//=========================================================
    5659static struct io_uring_sqe * get_sqe(struct io_uring * ring) {
     
    6467
    6568static void submit(struct io_uring * ) {
     69        // io_uring_sqe_set_flags(sqe, IOSQE_ASYNC);
    6670        // io_uring_submit(ring);
    6771}
     
    305309        ring_accept(ring, opt.acpt.sockfd, opt.acpt.addr, opt.acpt.addrlen, opt.acpt.flags);
    306310
     311        int reset = 1;
    307312        bool done = false;
    308313        while(!done) {
     
    345350
    346351                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                }
    347360        }
    348361
     
    373386        unsigned backlog = 10;
    374387        bool attach = false;
     388        bool sqpoll = false;
    375389
    376390        //===================
    377391        // Arguments
    378392        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) {
    380394                switch (c)
    381395                {
     
    395409                        attach = true;
    396410                        break;
     411                case 'S':
     412                        sqpoll = true;
     413                        break;
    397414                case '?':
    398415                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;
    400417                        return EXIT_FAILURE;
    401418                }
     
    478495        pthread_t    thrd_hdls[nthreads];
    479496        options_t    thrd_opts[nthreads];
     497        bool fast_poll = true;
     498        bool nfix_sqpl = true;
    480499        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;
    488508                        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; }
    491514
    492515                thrd_opts[i].acpt.sockfd  = server_fd;
     
    503526                }
    504527        }
     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;
    505531
    506532        //===================
     
    537563        //===================
    538564        (std::cout << "Stopping Threads Done... ").flush();
    539         size_t total = 0;
    540         size_t count = 0;
    541565        for(unsigned i = 0; i < nthreads; i++) {
    542566                void * retval;
     
    546570                        exit(EXIT_FAILURE);
    547571                }
    548                 // total += (size_t)retval;
    549                 total += thrd_opts[i].result.subs;
    550                 count += thrd_opts[i].result.cnts;
    551572
    552573                io_uring_queue_exit(thrd_opts[i].ring);
    553574        }
    554575        std::cout << "done" << std::endl;
    555         std::cout << "Submit average: " << total << "/" << count << "(" << (((double)total) / count) << ")" << std::endl;
    556576
    557577        //===================
Note: See TracChangeset for help on using the changeset viewer.