mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 06:01:28 +00:00
doAnyOutstandingProbes performance improvements. Here is the log message from r7914 in nmap-fixed-rate. Keep a cache of the most recently processed probe for each host in doAnyOutstandingRetransmits. This greatly reduces the amount of CPU used by that function when the lists of outstanding probes grow long, such as when a high scan rate is specified with --min-rate. This is not most efficient possible way this could be done, but it is a pretty big win, and it's very non-invasive. The changes are limited entirely to doAnyOutstandingRetransmits, with no new global state in ultra_scan. # nmap -d --min-rate 50000 -n -PN -p1-65535 --max-rtt-timeout 500 --max-retries 1 scanme.nmap.org gprof before: % cumulative self self total time seconds seconds calls s/call s/call name 49.74 30.96 30.96 2709 0.01 0.02 doAnyOutstandingRetransmits(UltraScanInfo*) 10.51 37.50 6.54 127256413 0.00 0.00 std::_List_iterator<UltraProbe*>::operator--(int) gprof after: % cumulative self self total time seconds seconds calls s/call s/call name 20.48 3.36 3.36 2667 0.00 0.00 doAnyOutstandingRetransmits(UltraScanInfo*) 16.21 6.02 2.66 2667 0.00 0.00 processData(UltraScanInfo*) Note that 50000 packets per second is way excessive. I really only get about 6000 in practice. But the point is there is no huge CPU penalty for giving an excessive rate.
194 KiB
194 KiB