性能调优
利用在线系统的数据,运行2小时,得到的结果如下(gprof):
intercept:
% cumulative self self total time seconds seconds calls s/call s/call name 30.06 26.17 26.17 70919324 0.00 0.00 tc_select_polling 8.18 33.29 7.12 pcap_read_linux_mmap 7.41 39.75 6.46 54991298 0.00 0.00 router_get 6.47 45.38 5.63 54991298 0.00 0.00 router_update 5.20 49.91 4.53 55903872 0.00 0.00 buffer_and_send 4.68 53.98 4.08 10642991 0.00 0.00 router_add 4.25 57.68 3.70 1 3.70 50.57 tc_event_process_cycle 3.96 61.13 3.45 54991298 0.00 0.00 resp_dispose 3.51 64.19 3.06 54991298 0.00 0.00 get_l2_len 3.46 67.20 3.01 70919324 0.00 0.00 tc_event_timer_find 2.95 69.77 2.57 70919323 0.00 0.00 tc_event_timer_run 2.10 71.60 1.83 101320562 0.00 0.00 link_list_tail 1.87 73.23 1.63 54991298 0.00 0.00 pcap_packet_callback 1.64 74.66 1.43 10426065 0.00 0.00 router_add_adjust 1.59 76.04 1.38 1546 0.00 0.00 delay_table_delete_obsolete 1.49 77.34 1.30 10710433 0.00 0.00 link_list_first 1.37 78.53 1.19 10645850 0.00 0.00 get_link_list 1.36 79.71 1.18 54991298 0.00 0.00 get_ip_data 1.36 80.89 1.18 54991298 0.00 0.00 tc_process_resp_packet 1.34 82.05 1.17 65634289 0.00 0.00 get_route_key 1.30 83.18 1.13 11069406 0.00 0.00 retrieve_wscale 0.47 83.59 0.41 10642997 0.00 0.00 tc_socket_recv 0.46 83.99 0.40 10642997 0.00 0.00 tc_msg_event_process 0.40 84.34 0.35 28237742 0.00 0.00 tc_socket_send
tcpcopy: 在线机器1: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name 22.43 106.38 106.38 81490687 0.00 0.00 hash_find_node 7.14 140.25 33.87 51096208 0.00 0.00 tc_select_polling 6.90 173.00 32.75 87556366 0.00 0.00 csum 5.34 198.35 25.35 327269019 0.00 0.00 link_list_first 4.73 220.77 22.42 pcap_read_linux_mmap 4.27 241.01 20.24 43778183 0.00 0.00 tcpcsum 3.72 258.67 17.65 92270359 0.00 0.00 get_link_list 3.65 275.99 17.33 32672889 0.00 0.00 process_client_packet 2.96 290.05 14.06 12521665 0.00 0.00 cp_fr_ip_pack 2.92 303.92 13.87 1 13.87 244.51 tc_event_process_cycle 2.66 316.54 12.62 43778169 0.00 0.00 wrap_send_ip_packet 1.81 325.13 8.59 27856332 0.00 0.00 process_backend_packet 1.79 333.64 8.51 1540 0.01 0.01 activate_dead_sessions 1.71 341.73 8.10 42846239 0.00 0.00 process_in 1.69 349.74 8.01 352341888 0.00 0.00 link_list_get_next 1.31 355.97 6.23 27854642 0.00 0.00 update_retransmission_packets 1.18 361.55 5.59 14513588 0.00 0.00 check_session_obsolete 1.17 367.11 5.56 1540 0.00 0.01 clear_timeout_sessions 1.14 372.54 5.43 42846319 0.00 0.00 dispose_packet 1.09 377.70 5.16 42846319 0.00 0.00 is_packet_needed 0.98 382.36 4.66 42846319 0.00 0.00 pcap_retrieve 0.96 386.94 4.58 27860554 0.00 0.00 process_out 0.92 391.30 4.36 77495458 0.00 0.00 link_list_remove 0.81 395.12 3.82 42846319 0.00 0.00 tc_process_pcap_socket_packet 0.76 398.72 3.60 51096208 0.00 0.00 tc_event_timer_find 0.69 402.01 3.30 14297353 0.00 0.00 tc_socket_cmb_recv
142: 在线机器2: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name 21.63 96.99 96.99 79109011 0.00 0.00 hash_find_node 7.28 129.62 32.63 85276626 0.00 0.00 csum 7.20 161.90 32.27 49577185 0.00 0.00 tc_select_polling 5.58 186.93 25.03 318761257 0.00 0.00 link_list_first 4.81 208.50 21.57 pcap_read_linux_mmap 4.47 228.56 20.06 42638313 0.00 0.00 tcpcsum 3.47 244.10 15.54 89609855 0.00 0.00 get_link_list 3.23 258.58 14.48 31767539 0.00 0.00 process_client_packet 3.14 272.66 14.08 12094789 0.00 0.00 cp_fr_ip_pack 2.78 285.13 12.47 42638285 0.00 0.00 wrap_send_ip_packet 2.78 297.57 12.44 1 12.44 235.62 tc_event_process_cycle 2.01 306.57 9.01 27124647 0.00 0.00 process_backend_packet 1.85 314.87 8.30 1502 0.01 0.01 activate_dead_sessions 1.71 322.55 7.68 294318648 0.00 0.00 link_list_get_next 1.67 330.03 7.49 41473958 0.00 0.00 process_in 1.35 336.08 6.05 27122965 0.00 0.00 update_retransmission_packets 1.30 341.93 5.85 1502 0.00 0.01 clear_timeout_sessions 1.20 347.33 5.40 14111113 0.00 0.00 check_session_obsolete 1.13 352.41 5.08 41474022 0.00 0.00 is_packet_needed