[Xastir-Dev] Surprise awaiting you in CVS...

Curt Mills hacker at tc.fluke.com
Fri Aug 8 21:25:24 EDT 2003


Well, I couldn't get "gprof" to function properly, what with all of
our fork() and pthread_create() calls (yea, you were right Ken!).
It wanted to show me startup and that was it.

I did however manage to get a version of "oprofile" running, which
allows me to profile Xastir nicely (and anything else on the system,
including the kernel!).

That done, I figured out that we were spending 97%+ of Xastir's time
in the search_station_name() function.  We were doing a linear
search through a linked list by name.  When we get 10,000 stations
or more in there, things slow down.

I've gone through two iterations of changes to fix this.  The first
involved creating an array of length 128 that was a pointer into the
station list based on the first character of the callsign.  Once I
had that working, tweaking it into an array of 16384 (14 bits) based
on the lower 7 bits of the callsign's first two characters was
pretty easy.

The end result is that we now use a hash table lookup for callsigns,
and my Xastir here is hanging around 0.0% CPU while on a full
firenet feed plus a filtered firenet feed (2 feeds total).  We're
doing a direct jump into the linked list based on the first two
callsign chars, then doing a linear search from there.  Much faster!

The heavy hitters _now_ within the Xastir program according to
oprofile are:


0806b060 58       0.882801    decode_ax25_line
080c5640 66       1.00457     index_retrieve
08059730 67       1.01979     display_file
08069a10 67       1.01979     decode_info_field
080e3940 69       1.05023     valid_path
08066e90 75       1.14155     packet_data_add
0804fa00 79       1.20244     normal_title
080e4cc0 84       1.27854     begin_critical_section
08050040 123      1.87215     alert_match
080cf2d0 127      1.93303     draw_shapefile_map
080773f0 128      1.94825     channel_data
0807deb0 131      1.99391     port_write
08056d00 153      2.32877     mscan_file
08071120 154      2.34399     draw_symbol
080d9c20 155      2.35921     check_and_transmit_messages
080a6df0 177      2.69406     UpdateTime
08090640 179      2.72451     langcode
08057c40 193      2.9376      display_station
080c17d0 199      3.02892     convert_to_xastir_coordinates
08064400 201      3.05936     data_add
08070e10 272      4.14003     symbol
0807d160 424      6.45358     port_read
08061870 845      12.8615     search_station_name
08061800 1101     16.758      station_shortcuts_update_function


The third column is percent (out of Xastir's 100%, not the CPU's
100%).

Before I started, search_station_name was at the bottom of the list
at 97% or higher.  We were spinning our wheels trying to find the
stations to update/display.

Please note that the codebase might be unstable for a bit while we
work out the bugs in the new scheme, but check out your "top"
listing for a feel-good while we're doing it!

Hopefully the new stuff will appear on the anon CVS server tomorrow.

-- 
Curt Mills, WE7U                    hacker_NO_SPAM_ at tc.fluke.com
Senior Methods Engineer/SysAdmin
"Lotto:    A tax on people who are bad at math!"
"Windows:  Microsoft's tax on computer illiterates!" -- WE7U
"The world DOES revolve around me:  I picked the coordinate system!"



More information about the Xastir-dev mailing list