Api Calls Are Slower On 1.3.xx Up To Factor 10 - 20


tuxpoldo

Recommended Posts

Can anybody confirm this?

My first impression by testing 1.3.67 with the btsync-gui is that the API is really slower. With 1.2.67 the GUI is really fast and the adaptive query interval was never changed on a local system. The timings of the API calls are now sooooo slooooow that on the local system the adaptive query interval of the btsync-gui is raised to 4000 msec...
 
Any explanation for this?

Some more info on timings.

This is the normal indicator refresh cycle of btsync-gui with 1.3.67
 

WARNING:root:Cycle duration was 112 msec - Adaptive timeout changed to 4000 msec to avoid API floodingWARNING:root:Cycle duration was 85 msec - Adaptive timeout changed to 2000 msec to avoid API floodingWARNING:root:Cycle duration was 113 msec - Adaptive timeout changed to 4000 msec to avoid API floodingWARNING:root:Cycle duration was 84 msec - Adaptive timeout changed to 2000 msec to avoid API floodingWARNING:root:Cycle duration was 112 msec - Adaptive timeout changed to 4000 msec to avoid API floodingWARNING:root:Cycle duration was 83 msec - Adaptive timeout changed to 2000 msec to avoid API flooding

With 1.2.92 I had to add an additional log message in order to display the timing, since this never happened:
 

WARNING:root:Cycle duration was 7 msecWARNING:root:Cycle duration was 6 msecWARNING:root:Cycle duration was 5 msecWARNING:root:Cycle duration was 7 msecWARNING:root:Cycle duration was 7 msecWARNING:root:Cycle duration was 8 msecWARNING:root:Cycle duration was 7 msec

As you can see, the API is more than 10 times faster!

This is basically the code that is executed:
 

	def btsync_refresh_status(self):		if self.connection is not BtSyncStatus.CONNECTED:			logging.info('Interrupting refresh sequence...')			return False		logging.info('Refresh status...')		indexing = False		transferring = False		try:			folders = self.agent.get_folders()			for fIndex, fValue in enumerate(folders):				if fValue['indexing'] > 0:					indexing = True# this takes too much resources...#				peers = self.agent.get_folder_peers(fValue['secret'])#				for pIndex, pValue in enumerate(peers):#					if long(pValue['upload']) + long(pValue['download']) > 0:#						transferring = True#####			speed = self.agent.get_speed()			if transferring or speed['upload'] > 0 or speed['download'] > 0:				# there are active transfers...				self.set_status(BtSyncStatus.CONNECTED,True)				self.menustatus.set_label(_('{0:.1f} kB/s up, {1:.1f} kB/s down').format(speed['upload'] / 1000, speed['download'] / 1000))			elif indexing:				self.set_status(BtSyncStatus.CONNECTED)				self.menustatus.set_label(_('Indexing...'))			else:				self.set_status(BtSyncStatus.CONNECTED)				self.menustatus.set_label(_('Idle'))			return True

The API calls are one self.agent.get_folders(), one self.agent.get_speed() and one self.agent.get_folder_peers(fValue['secret']) for every folder. The system has only 4 folders.

Link to comment
Share on other sites

Hi Roman,

 

sorry, but I think that 100msec is not very fast if previously it took 7 msec. I get these values with only 4 shared folders. Imagine a system with 100 or 1000 folders... The 100msec with 4 folders are visible (it takes a small moment to update) but not really disturbing. I have still not tested it with many folders, but I'm afraid it will make a huge difference. And you would see it, since currently the GUI is not multithreaded. During API calls, the GUI is unresponsive...

 

In any case the question is: what is taking so much longer? The processing of the call, or only the session setup? I'm not totally sure, but it is my suspicion, that the requests library currently sets up a new connection for every call. This is not totally clear for me, since the documentation of the requests-library is somehow confusing on that. But I will make a test with a slightly different implementation.

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.