Hi,
first: my english is poor,but i try to do this in english to reach more people.
After some discussions on #amule there are some enhancements to the source dropping systems which would IMO improve amule. source dropping as it is now is useless, because dropped sources, because of high QR or Full Queue, will reappear as soon as they appear again,so it could happen that a client asks the same source 10 times and finds out 10 times that it should be dropped. This is not much more than waste of upstream bandwidth.
The idea is to maintain a hashtable of client IDs and timestamps. when a client is dropped its ID and the time, when it is dropped, will be inserted into the hashtable. When a client now reappears it's ID is looked up in the hashtable. If the ID is found and the current time minus the stored timestamp is smaller than some value (20 minutes?) it will not be asked again and will have no entry in a file's source list. If the time difference is greater than some value the client's ID is removed from the hashtable and the client is asked again. When you upload to some client the ID of the client is also removed from the hashtable, because your QR can decrease because of uploading. After some time the complete hashtable is greped for too old entries,which would be removed if the client would appear. This prevents the hashtable from growing too big, because of useless entries.
Perhaps this sounds slow, but i think it's quite fast. hash table lookups aren't much slower, than array accesses. You compute a hash of a client ID (perhaps by XORing it up to a 32bit value?) and lookup the hashtable at the computed hash. There's some small overhead if 2 IDs have the same hash. Many (every?) C++ compilers offers ready-for-use hash table classes. The hashtable would map a client ID to an integer value. For every new source you whould to the following:
- Lookup the client's ID in the hashtable
- If it is found check the time difference
- drop the client (again) if time difference is small, remove from hashtable otherwise
IMO all 3 points don't consume much CPU power.
I hope all the others, who tought with me about this, will read this and add all the things i've forgotten. ;-)