Official eMule-Board: Optimization @csharedfilesctrl::oncommand & @cshareddirstreectrl:: - Official eMule-Board

Jump to content


Page 1 of 1

Optimization @csharedfilesctrl::oncommand & @cshareddirstreectrl:: upon change selected shared files UL priority

#1 User is offline   taz-me 

  • I'm taz (a modder)
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 587
  • Joined: 07-December 06

Posted 15 November 2010 - 06:31 AM

"old news" by WiZaRd :

@CSharedFilesCtrl::OnCommand (same goes for CSharedDirsTreeCtrl::OnCommand)

...
		switch (wParam){
...
			case MP_PRIOVERYLOW:
			case MP_PRIOLOW:
			case MP_PRIONORMAL:
			case MP_PRIOHIGH:
			case MP_PRIOVERYHIGH:
			case MP_PRIOAUTO:
				{
					POSITION pos = selectedList.GetHeadPosition();
					while (pos != NULL)
					{
						if (!selectedList.GetAt(pos)->IsKindOf(RUNTIME_CLASS(CKnownFile)))
							continue;
						CKnownFile* file = (CKnownFile*)selectedList.GetNext(pos);
						file->SetAutoUpPriority(wParam == MP_PRIOAUTO); //>>> WiZaRd::Optimization
						switch (wParam) 
						{
							case MP_PRIOVERYLOW:
//								file->SetAutoUpPriority(false); //>>> WiZaRd::Optimization
								file->SetUpPriority(PR_VERYLOW);
//								UpdateFile(file); //>>> WiZaRd::Optimization
								break;
							case MP_PRIOLOW:
//								file->SetAutoUpPriority(false); //>>> WiZaRd::Optimization
								file->SetUpPriority(PR_LOW);
//								UpdateFile(file); //>>> WiZaRd::Optimization
								break;
							case MP_PRIONORMAL:
//								file->SetAutoUpPriority(false); //>>> WiZaRd::Optimization
								file->SetUpPriority(PR_NORMAL);
//								UpdateFile(file); //>>> WiZaRd::Optimization
								break;
							case MP_PRIOHIGH:
//								file->SetAutoUpPriority(false); //>>> WiZaRd::Optimization
								file->SetUpPriority(PR_HIGH);
//								UpdateFile(file); //>>> WiZaRd::Optimization
								break;
							case MP_PRIOVERYHIGH:
//								file->SetAutoUpPriority(false); //>>> WiZaRd::Optimization
								file->SetUpPriority(PR_VERYHIGH);
//								UpdateFile(file); //>>> WiZaRd::Optimization
								break;	
							case MP_PRIOAUTO:
//								file->SetAutoUpPriority(true); //>>> WiZaRd::Optimization
								file->UpdateAutoUpPriority();
//								UpdateFile(file); //>>> WiZaRd::Optimization
								break;
						}
						UpdateFile(file); //>>> WiZaRd::Optimization
					}
					break;
				}
...


my 2 cents replacing :

...
						UpdateFile(file); //>>> WiZaRd::Optimization
					}
					break;
...


with :

...
						UpdateFile(file, false); //>>> WiZaRd::Optimization //>>> taz::optimization
					}
					theApp.emuledlg->sharedfileswnd->ShowSelectedFilesDetails(); //>>> taz::optimization
...


- so that changed priority for all selected files will be "drawn" only once (and not all selected files "drawn" for each file)

:)
P2P is about sharing, ed2k is my choice !
0

#2 User is offline   Stulle 

  • [Enter Mod] Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5738
  • Joined: 07-April 04

Posted 15 November 2010 - 07:00 AM

the code changes by wizard are not actually optimizing anything but readability. your change is actually saving a few calls to ShowSelectedFilesDetails() but since this is a user command which is processed i wouldn't even start to bother. if somebody is stupid enough to select thousands of files and keeps changing their priority it's his business if the CPU load goes through the roof. ;)
I am an emule-web.de member and fan! Hate me or people will get suspicious about you! Ever wondered if it's all worth the trouble?

Posted Image

No, there will not be a new version of my mods. No, I do not want your PM. No, I am certain, use the board and quit sending PMs. No, I am not kidding, there will not be a new version of my mods just because of YOU asking for it!
0

#3 User is offline   pier4r 

  • Ex falso quodlibet ; Kad is the major concept behind emule.
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 564
  • Joined: 31-March 09

Posted 15 November 2010 - 01:01 PM

View PostStulle, on 15 November 2010 - 08:00 AM, said:

the code changes by wizard are not actually optimizing anything but readability. your change is actually saving a few calls to ShowSelectedFilesDetails() but since this is a user command which is processed i wouldn't even start to bother. if somebody is stupid enough to select thousands of files and keeps changing their priority it's his business if the CPU load goes through the roof. ;)


-.-

Ehi, why we should use mergesort instead of bubble sort? If someone is stupid enough to select thousands of elements to sort, it's his business if the CPU load goes through the roof for ages.
;)

PS: i often (when i load a new emule version) change priority of a lot of files (about 200-300).

This post has been edited by pier4r: 15 November 2010 - 01:04 PM

>>> My wiki (ITA) on emule >>>Feature Request (ICS) or SOTN, ClientAnalyzer(fixing fastXs and reask punishment),, EmuleCollectionV2 >>> Emule on old hardware (intel pentium 2 or 3 - via c3 - and so on) with good OS settings and enough ram (256+ mb): great >>>user of: eMule - Xtreme - ZZUL bastard - SharX - SharkX 1.8b5 pierQR - ZZUL-Tra - ZZUL-Tra-TL - kMule - Beba

Extended signature: click.
0

#4 User is offline   Stulle 

  • [Enter Mod] Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5738
  • Joined: 07-April 04

Posted 15 November 2010 - 08:29 PM

and you do that all the time, i take it. well, then this optimization is vital. because you, just like any other user except for me, keep changing priorities for large number of files all the time which will ultimately freeze the entire desktop... no wait, freezing desktop will cause you to slow down on your need-to-change-priority-all-the-time-because-no-brain-for-dinner-rant... what a terrible scenario... i'd go as far as calling it post-apocalyptic!

on a more serious note, again, this is a user command and while there probably is room for some improvement this is far from being a performance killer, especially because we will rarely even encounter this user command, compared to - say - the run function in the UploadBandwidthThrottler, unless some lunatic is sitting in front of the screen.

This post has been edited by Stulle: 15 November 2010 - 08:31 PM

I am an emule-web.de member and fan! Hate me or people will get suspicious about you! Ever wondered if it's all worth the trouble?

Posted Image

No, there will not be a new version of my mods. No, I do not want your PM. No, I am certain, use the board and quit sending PMs. No, I am not kidding, there will not be a new version of my mods just because of YOU asking for it!
0

#5 User is offline   taz-me 

  • I'm taz (a modder)
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 587
  • Joined: 07-December 06

Posted 15 November 2010 - 08:44 PM

Since the scenario is due to user action (interactive) and not "of it's own" (batch) it is not about a performance killer,

however :respect: reducing loop from no. of selected files * no. of selected files to only no. of selected files is worthy (or in other words I'm sure "optimizations", with or without quotes, of a lower magnitude found their way into mods code probably to official as well).

BTW: about the "no-brain-for-dinner" user, ... well I guess it makes one wonders why it is enabled to change the priority of all the files within "shared directories" in a single click (regardless of the no. of files).
P2P is about sharing, ed2k is my choice !
0

#6 User is offline   Stulle 

  • [Enter Mod] Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5738
  • Joined: 07-April 04

Posted 15 November 2010 - 09:54 PM

i just watched "The Walking Dead"... that was my inspiration for the no-brain-for-dinner part. :-D

but you are right about your calculation. :)
I am an emule-web.de member and fan! Hate me or people will get suspicious about you! Ever wondered if it's all worth the trouble?

Posted Image

No, there will not be a new version of my mods. No, I do not want your PM. No, I am certain, use the board and quit sending PMs. No, I am not kidding, there will not be a new version of my mods just because of YOU asking for it!
0

#7 User is offline   taz-me 

  • I'm taz (a modder)
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 587
  • Joined: 07-December 06

Posted 21 November 2010 - 12:43 PM

After long tests it appears that @CSharedDirsTreeCtrl::OnCommand

theApp.emuledlg->sharedfileswnd->ShowSelectedFilesDetails()

shouldn't be called since no files are selected (calling m_pSharedFilesCtrl->UpdateFile(file, false) still saves needless check for files being selected).

It's true that one can add a call m_pSharedFilesCtrl->AutoSelectItem() before calling theApp.emuledlg->sharedfileswnd->ShowSelectedFilesDetails(), however that would mean a change from current official behavior.

:)
P2P is about sharing, ed2k is my choice !
0

#8 User is offline   Stulle 

  • [Enter Mod] Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5738
  • Joined: 07-April 04

Posted 21 November 2010 - 03:10 PM

huh? how can you change the priority of a file without selecting a file? there should be a file selected and the according information should be displayed in the information tab.
I am an emule-web.de member and fan! Hate me or people will get suspicious about you! Ever wondered if it's all worth the trouble?

Posted Image

No, there will not be a new version of my mods. No, I do not want your PM. No, I am certain, use the board and quit sending PMs. No, I am not kidding, there will not be a new version of my mods just because of YOU asking for it!
0

#9 User is offline   Stulle 

  • [Enter Mod] Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5738
  • Joined: 07-April 04

Posted 21 November 2010 - 04:18 PM

ah, didn't read careful enough to realize you were in fact talking about the tree. my bad. :)
I am an emule-web.de member and fan! Hate me or people will get suspicious about you! Ever wondered if it's all worth the trouble?

Posted Image

No, there will not be a new version of my mods. No, I do not want your PM. No, I am certain, use the board and quit sending PMs. No, I am not kidding, there will not be a new version of my mods just because of YOU asking for it!
0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users