Changeset eeb4866 for benchmark/io/http
- Timestamp:
- Feb 1, 2021, 12:42:13 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:
- cd70477
- Parents:
- 9715567
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/http_ring.cpp
r9715567 reeb4866 8 8 #include <unistd.h> 9 9 #include <liburing.h> 10 11 // #define NOBATCHING 12 // #define USE_ASYNC 10 13 11 14 // Options passed to each threads … … 167 170 , buffer( new char[buffer_size]) 168 171 , iterator(nullptr) 169 { 170 ::stats.conns.max++; 171 ::stats.conns.current++; 172 } 172 {} 173 173 174 174 ~connection() { … … 192 192 static void submit(struct io_uring * ring, struct io_uring_sqe * sqe, connection * conn) { 193 193 (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 195 197 io_uring_sqe_set_data(sqe, conn); 196 // io_uring_submit(ring); 198 #ifdef NOBATCHING 199 io_uring_submit(ring); 200 #endif 197 201 } 198 202 … … 206 210 state = REQUESTING; 207 211 struct io_uring_sqe * sqe = get_sqe(ring); 208 io_uring_prep_re ad(sqe, fd, (void*)buffer, buffer_size, 0);212 io_uring_prep_recv(sqe, fd, (void*)buffer, buffer_size, 0); 209 213 submit(ring, sqe); 210 214 } … … 226 230 state = ANSWERING; 227 231 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); 229 233 submit(ring, sqe); 230 234 } … … 247 251 // Count the connections 248 252 ::stats.completions.conns++; 253 ::stats.conns.current++; 254 if(::stats.conns.current > ::stats.conns.max) { 255 ::stats.conns.max = ::stats.conns.current; 256 } 249 257 250 258 // Read on the data … … 373 381 if( res == to_send ) { 374 382 // 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++; 377 385 // Then read a new request 378 386 request(ring); … … 459 467 req->handle( ring, cqe->res, opt ); 460 468 469 // Every now and then, print some stats 461 470 reset--; 462 471 if(reset == 0) { 463 472 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 464 475 reset = 100000 + (100000 * (ring->ring_fd % 5)); 465 476 } … … 755 766 std::cout << "Max FD: " << max_fd << std::endl; 756 767 std::cout << "Successful connections: " << global_stats.conns.used << std::endl; 768 std::cout << "Max concurrent connections: " << global_stats.conns.max << std::endl; 757 769 std::cout << "Accepts on non-zeros: " << global_stats.recycle_errors << std::endl; 758 770 std::cout << "Leaked conn objects: " << global_stats.conns.current << std::endl; 759 771 } 772 773 // compile-command: "g++ http_ring.cpp -std=c++2a -pthread -luring -O3" //
Note: See TracChangeset
for help on using the changeset viewer.