Changeset eeb4866 for benchmark/io/http


Ignore:
Timestamp:
Feb 1, 2021, 12:42:13 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:
cd70477
Parents:
9715567
Message:

Changed read/write to send/recv to work around small bug in io_uring.
Some clean-up.

File:
1 edited

Legend:

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

    r9715567 reeb4866  
    88#include <unistd.h>
    99#include <liburing.h>
     10
     11// #define NOBATCHING
     12// #define USE_ASYNC
    1013
    1114// Options passed to each threads
     
    167170                , buffer( new char[buffer_size])
    168171                , iterator(nullptr)
    169         {
    170                 ::stats.conns.max++;
    171                 ::stats.conns.current++;
    172         }
     172        {}
    173173
    174174        ~connection() {
     
    192192        static void submit(struct io_uring * ring, struct io_uring_sqe * sqe, connection * conn) {
    193193                (void)ring;
    194                 // io_uring_sqe_set_flags(sqe, IOSQE_ASYNC);
     194                #ifdef USE_ASYNC
     195                        io_uring_sqe_set_flags(sqe, IOSQE_ASYNC);
     196                #endif
    195197                io_uring_sqe_set_data(sqe, conn);
    196                 // io_uring_submit(ring);
     198                #ifdef NOBATCHING
     199                        io_uring_submit(ring);
     200                #endif
    197201        }
    198202
     
    206210                state = REQUESTING;
    207211                struct io_uring_sqe * sqe = get_sqe(ring);
    208                 io_uring_prep_read(sqe, fd, (void*)buffer, buffer_size, 0);
     212                io_uring_prep_recv(sqe, fd, (void*)buffer, buffer_size, 0);
    209213                submit(ring, sqe);
    210214        }
     
    226230                state = ANSWERING;
    227231                struct io_uring_sqe * sqe = get_sqe(ring);
    228                 io_uring_prep_write(sqe, fd, iterator, to_send, 0);
     232                io_uring_prep_send(sqe, fd, iterator, to_send, 0);
    229233                submit(ring, sqe);
    230234        }
     
    247251                // Count the connections
    248252                ::stats.completions.conns++;
     253                ::stats.conns.current++;
     254                if(::stats.conns.current > ::stats.conns.max) {
     255                        ::stats.conns.max = ::stats.conns.current;
     256                }
    249257
    250258                // Read on the data
     
    373381                if( res == to_send ) {
    374382                        // Yes, more stats
    375                         stats.answers++;
    376                         if(stats.answers == 2) ::stats.conns.used++;
     383                        this->stats.answers++;
     384                        if(this->stats.answers == 1) ::stats.conns.used++;
    377385                        // Then read a new request
    378386                        request(ring);
     
    459467                        req->handle( ring, cqe->res, opt );
    460468
     469                        // Every now and then, print some stats
    461470                        reset--;
    462471                        if(reset == 0) {
    463472                                std::cout << "Submit average: " << sqes << "/" << call << "(" << (((double)sqes) / call) << ")" << std::endl;
     473                                // Reset to some random number of completions
     474                                // use the ring_fd in the number of threads don't all print at once
    464475                                reset = 100000 + (100000 * (ring->ring_fd % 5));
    465476                        }
     
    755766        std::cout << "Max FD: " << max_fd << std::endl;
    756767        std::cout << "Successful connections: " << global_stats.conns.used << std::endl;
     768        std::cout << "Max concurrent connections: " << global_stats.conns.max << std::endl;
    757769        std::cout << "Accepts on non-zeros: " << global_stats.recycle_errors << std::endl;
    758770        std::cout << "Leaked conn objects: " << global_stats.conns.current << std::endl;
    759771}
     772
     773// compile-command: "g++ http_ring.cpp -std=c++2a -pthread -luring -O3" //
Note: See TracChangeset for help on using the changeset viewer.