Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove direct dependency on amphp/file, improve CPU usage and perf
amphp/file was replaced with ResourceInputStream, which might result in blocking operations, however so far I did not notice any. Following removal of amphp/file dependency in amphp/dns (at d26f9bb), this change should (when new version of amphp/dns is released) result in eliminating requirement of 3 indirect dependencies. This change improves: - CPU utilization (from ~51% to ~35%) - max speed (from 78.8MiB/s to 170MiB/s) Given stdin `head -c 1G </dev/urandom | pv -q -L 10000000`: Before: 83205.359732 task-clock (msec) # 0.776 CPUs utilized 279,904 context-switches # 0.003 M/sec 15,297 cpu-migrations # 0.184 K/sec 5,318 page-faults # 0.064 K/sec 79,455,374,201 cycles # 0.955 GHz 44,104,516,695 instructions # 0.56 insn per cycle 9,306,984,820 branches # 111.856 M/sec 452,310,830 branch-misses # 4.86% of all branches 107.261390647 seconds time elapsed After: 37608.420764 task-clock (msec) # 0.350 CPUs utilized 27,243 context-switches # 0.724 K/sec 2,032 cpu-migrations # 0.054 K/sec 3,261 page-faults # 0.087 K/sec 17,073,590,870 cycles # 0.454 GHz 12,015,172,856 instructions # 0.70 insn per cycle 2,428,621,990 branches # 64.577 M/sec 64,394,486 branch-misses # 2.65% of all branches 107.449499919 seconds time elapsed Given `head -c 1G </dev/urandom`: Before: 18344.168358 task-clock (msec) # 1.284 CPUs utilized 248,097 context-switches # 0.014 M/sec 3,901 cpu-migrations # 0.213 K/sec 5,285 page-faults # 0.288 K/sec 62,863,094,352 cycles # 3.427 GHz 42,953,043,093 instructions # 0.68 insn per cycle 9,069,974,709 branches # 494.434 M/sec 308,754,921 branch-misses # 3.40% of all branches 14.290214331 seconds time elapsed After: 4913.930543 task-clock (msec) # 0.737 CPUs utilized 74,337 context-switches # 0.015 M/sec 1,105 cpu-migrations # 0.225 K/sec 3,256 page-faults # 0.663 K/sec 16,824,387,362 cycles # 3.424 GHz 12,426,816,219 instructions # 0.74 insn per cycle 2,545,396,441 branches # 517.996 M/sec 46,043,534 branch-misses # 1.81% of all branches 6.666760699 seconds time elapsed
- Loading branch information