INI file are not efficient, you have no tool in mIRC to do efficient lookups. INI should in theory (and in your case, theory applies because you have a lot of entries) only be used to store data on the disk, lookups should be done from a better storage method, here, from a custom window:
on start: load the INI file into a custom window
on exit: save the custom window to the INI file
Right now, your script needs to get datas from the INI file, to nicely format them for /filter to work. Your script does that by looping on each section in the INI file and /aline the result to a window, to then /filter, the loop + aline is what takes 5 secs. What you need to do is to keep a window opened with the data, instead of creating the window each time.
Basically, whenever you are using /writeini to update the value of the "messages" item for a given section, you must also update the data in the custom window
When your script initializes (on start or whatever), create the custom window @., loop on the INI file like you are doing in the current top10 alias and aline the datas.
Now when you want to do a top10, you just use /filter on that window, you can remove the loop on the INI file. Of course you must update the @. window whenever you currently are going to update the "messages" item in the INI file. And to keep using theory, you should only write to the ini file when you are done (or periodically to avoid losing data if mIRC crash for example), basically in this example, you are done when you no longer have to do a top10. But if you update the ini file at the same time you update the custom @. window, it's still going to work, but that's less efficient (you don't need to update the INI file since the data is updated on the custom window)