Changeset b664af2


Ignore:
Timestamp:
Feb 24, 2021, 12:26:45 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:
2caed18
Parents:
348f81d
Message:

Changed http_ring to have max submission count.

File:
1 edited

Legend:

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

    r348f81d rb664af2  
    6868thread_local stats_block_t stats;
    6969stats_block_t global_stats;
     70
     71thread_local struct __attribute__((aligned(128))) {
     72        size_t to_submit = 0;
     73} local;
    7074
    7175// Get an array of current connections
     
    193197        static void submit(struct io_uring * ring, struct io_uring_sqe * sqe, connection * conn) {
    194198                (void)ring;
     199                local.to_submit++;
    195200                #ifdef USE_ASYNC
    196201                        io_uring_sqe_set_flags(sqe, IOSQE_ASYNC);
     
    407412                switch(state) {
    408413                case ACCEPTING:
    409                         connection::accept(ring, opt);
     414                        // connection::accept(ring, opt);
    410415                        newconn(ring, res);
    411416                        break;
     
    421426
    422427//=========================================================
     428extern "C" {
     429        #include <sys/eventfd.h>  // use for termination
     430}
     431
    423432// Main loop of the WebServer
    424433// Effectively uses one thread_local copy of everything per kernel thread
     
    427436        struct options_t & opt = *(struct options_t *)arg;
    428437        struct io_uring * ring = opt.ring;
     438
     439        int blockfd = eventfd(0, 0);
     440        if (blockfd < 0) {
     441                fprintf( stderr, "eventfd create error: (%d) %s\n", (int)errno, strerror(errno) );
     442                exit(EXIT_FAILURE);
     443        }
     444
     445        int ret = io_uring_register_eventfd(ring, blockfd);
     446        if (ret < 0) {
     447                fprintf( stderr, "io_uring S&W error: (%d) %s\n", (int)-ret, strerror(-ret) );
     448                exit(EXIT_FAILURE);
     449        }
    429450
    430451        // Track the shutdown using a event_fd
     
    445466                // Submit all the answers we have and wait for responses
    446467                int ret = io_uring_submit_and_wait(ring, 1);
     468                local.to_submit = 0;
    447469
    448470                // check errors
     
    455477                sqes += ret;
    456478                call++;
     479
     480
     481                // eventfd_t val;
     482                // ret = eventfd_read(blockfd, &val);
     483
     484                // // check errors
     485                // if (ret < 0) {
     486                //      fprintf( stderr, "eventfd read error: (%d) %s\n", (int)errno, strerror(errno) );
     487                //      exit(EXIT_FAILURE);
     488                // }
    457489
    458490                struct io_uring_cqe *cqe;
     
    466498                                break;
    467499                        }
     500
     501                        if(local.to_submit > 30) break;
    468502
    469503                        auto req = (class connection *)cqe->user_data;
     
    512546        #include <pthread.h>      // for pthreads
    513547        #include <signal.h>       // for signal(SIGPIPE, SIG_IGN);
    514         #include <sys/eventfd.h>  // use for termination
    515548        #include <sys/socket.h>   // for sockets in general
    516549        #include <netinet/in.h>   // for sockaddr_in, AF_INET
Note: See TracChangeset for help on using the changeset viewer.