aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Pages: [1] 2 3

Author Topic: High CPU usage during procedure of final file hashing  (Read 17719 times)

p.r.

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
High CPU usage during procedure of final file hashing
« on: January 25, 2009, 12:01:43 AM »

I run both rtorrent and amuled at my home NAS (ppc603e 200Mhz/32MB/uClibc Linux), and I've noticed a strange behavior of Amule.

When rtorrent performs procedure of final file hashing it does NOT slow down itself (speed of downloading/uploading) or other applications, such as amule.

When amule performs procedure of final file hashing it DOES very slow down itself and other applications, such as rtorrent.

I think that this difference may be due to different libraries: openssl 0.9.7m (libcrypto.so.0.9.7) and crypto++ 5.5.2 (built into Amule 2.2.3).

Therefore, I want to know:
1. is it possible to compile amule with openssl?
2. is it possible to make amule (by changing the settings, or source code) NOT to use more than 50% of cpu time?
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: High CPU usage during procedure of final file hashing
« Reply #1 on: January 25, 2009, 06:25:45 PM »

1. is it possible to compile amule with openssl?
No.

2. is it possible to make amule (by changing the settings, or source code) NOT to use more than 50% of cpu time?
Most likely, yes.
Logged
concordia cum veritate

p.r.

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
Re: High CPU usage during procedure of final file hashing
« Reply #2 on: January 25, 2009, 06:51:57 PM »

2. is it possible to make amule (by changing the settings, or source code) NOT to use more than 50% of cpu time?
Most likely, yes.
But how ?

Could some kind of  "hash strategies switcher" be implemented, so
user could choose, for example, between different options:
1. as fast as possible
2. don't exceed certain data rate (xx MB/s)
3. don't use more than xx% of cpu time ?

Sorry if I've written something stupid, but it looks like amule by default try to hash files as fast as possible.
« Last Edit: January 25, 2009, 07:13:40 PM by p.r. »
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: High CPU usage during procedure of final file hashing
« Reply #3 on: January 25, 2009, 07:15:53 PM »

Sorry if I've written something stupid, but it looks like amule by default try to hash files as fast as possible.
When the final rehash happens the file is (yet) a partfile, so the hasher thread gets high priority. That's what causing the general slow-down.
Logged
concordia cum veritate

p.r.

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
Re: High CPU usage during procedure of final file hashing
« Reply #4 on: January 25, 2009, 07:20:34 PM »

Sorry if I've written something stupid, but it looks like amule by default try to hash files as fast as possible.
When the final rehash happens the file is (yet) a partfile, so the hasher thread gets high priority. That's what causing the general slow-down.
And how to reduce priority of   hasher thread ?

So I found a solution.
Check ThreadTasks.cpp:50

CHashingTask::CHashingTask(const CPath& path, const CPath& filename, const CPartFile* part)
   // GetPrintable is used to improve the readability of the log.
   : CThreadTask(wxT("Hashing"), path.JoinPaths(filename).GetPrintable(), (part ? ETP_High : ETP_Normal)),

You can change ETP_High to ETP_Low if you want, even the ETP_Normal, but it will make hashing way slower in your system. OTOH it should prevent CPU starvation.
Let's see how it will work.
« Last Edit: January 25, 2009, 10:14:26 PM by p.r. »
Logged

Archmage

  • Full Member
  • ***
  • Karma: 5
  • Offline Offline
  • Posts: 119
Re: High CPU usage during procedure of final file hashing
« Reply #5 on: January 29, 2009, 09:32:33 AM »

Will amuled also slow down?
Logged

p.r.

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
Re: High CPU usage during procedure of final file hashing
« Reply #6 on: January 29, 2009, 05:55:19 PM »

No luck with reducing priority of  hasher thread:
" : CThreadTask(wxT("Hashing"), path.JoinPaths(filename).GetPrintable(), (part ? ETP_Low : ETP_Low))"
No changes in amuled behaviour,  got the same slow down.
Logged

freddy77

  • Developer
  • Full Member
  • *****
  • Karma: 20
  • Offline Offline
  • Posts: 113
Re: High CPU usage during procedure of final file hashing
« Reply #7 on: January 29, 2009, 06:48:26 PM »

This priority affect only the order in which tasks are executed in aMule. Probably hashing take too much time.
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: High CPU usage during procedure of final file hashing
« Reply #8 on: January 29, 2009, 10:43:31 PM »

Code: (src/ThreadScheduler.cpp:156) [Select]
                // Try to avoid reducing the latency of the main thread
                m_thread->SetPriority(WXTHREAD_MIN_PRIORITY);

There seems to be no easy way to reduce CPU load.
Logged
concordia cum veritate

p.r.

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
Re: High CPU usage during procedure of final file hashing
« Reply #9 on: January 30, 2009, 12:10:14 AM »

Final file hashing speed:
rtorrent   ~150 MB/minute  and    NO        system slow down
amuled      ~50 MB/minute   and    FULL   system slow down

What could be a cause of such awful inefficiency?
Logged

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: High CPU usage during procedure of final file hashing
« Reply #10 on: January 30, 2009, 12:28:37 AM »

Are you sure it is the hashing? Are your incoming and temp in the same partition/disk?
Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: High CPU usage during procedure of final file hashing
« Reply #11 on: January 30, 2009, 01:27:10 AM »

Well, torrent uses sha1 on small subsets (64kB to 4MB according to a large online encyclopaedia). ed2k (i.e. aMule) uses bigger chunks of 9500 kB which are hashed using MD4. aMule uses additionally AICH which uses sha1 to hash small parts of 180 kB, i.e. it creates 52+1 hashes per chunk. (Furthermore aMule copies the whole file after verification whereas torrent usually does not. That's what Kry's question is targetting.)

Therefore it's safe to assume that aMule is doing more work when hashing. This does, however not explain the slowdown. If, however, your computer is low on RAM this might be caused by the higher RAM usage of aMule when hashing. (It does currently load the whole 9.28 MB chunk into RAM, iirc.) This might cause swapping which is always a lot slower. freddy77 is working on patches to lower the RAM usage, so this might be improved in the future.
Logged

p.r.

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
Re: High CPU usage during procedure of final file hashing
« Reply #12 on: January 30, 2009, 01:32:29 PM »

Are you sure it is the hashing? Are your incoming and temp in the same partition/disk?
Yes, these directories are in same disk /partition, and the disk is internal ata133, not external usb.
All directories locations are default:
Quote
# ls -la1 /mnt/HD_a2/home/p2p/.aMule
.
..
ED2KLinks_lock
Incoming
Queue
Temp

amule.conf
clients.met
clients.met.BAK
cryptkey.dat
emfriends.met
ipfilter.dat
ipfilter_static.dat
key_index.dat
known.met
known2_64.met
last_version_check
lastversion
load_index.dat
logfile
logfile.bak
muleLock
nodes.dat
preferences.dat
preferencesKad.dat
server.met
server_met.old
shareddir.dat
src_index.dat

wuischke
Thank you for comprehensive explanation of difference between torrent and mule hashing.

AICH was disabled by default:
Code: [Select]
ICH=1
AICHTrust=0
Should I disable ICH too?


I'll hope that freddy77 will make this patch.

Thank you all for understanding.

Logged

wuischke

  • Developer
  • Hero Member
  • *****
  • Karma: 183
  • Offline Offline
  • Posts: 4292
Re: High CPU usage during procedure of final file hashing
« Reply #13 on: January 30, 2009, 02:12:39 PM »

These options do not what you think. AICHTrust means that you trust every hash you receive by someone else. If you disable this (which is the right thing to do™), you only trust a hash if more than 10 clients have sent you the hash and at least 92% of all clients had this hash.
ICH is an old way to recover data, but a lot less efficient than AICH. You can savely disable it, but it will not improve hashing speed.

Please have a look at the available RAM during hashing and see if it's really caused by swapping. Seeing your machine has 32 MB RAM, it's very well possible.
Logged

p.r.

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 50
Re: High CPU usage during procedure of final file hashing
« Reply #14 on: January 30, 2009, 02:56:40 PM »

wuischke
So there is no way to disable AICH?

Swapping...  yes,  it present  but  it'snt so heavy.
When I run both rtorrent and amuled  free MEM  is almost constant:  500...700 KB,
 used SWAP is variable: 16000 ... 29000 KB.
Logged
Pages: [1] 2 3