mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	have an actor manage the crypto worker pool instead of each session trying to use it directly, this should result in a fairer round-robin behavior in cases where crypto congestion is the bottleneck
This commit is contained in:
		
							parent
							
								
									3845f81357
								
							
						
					
					
						commit
						a8b323acdd
					
				
					 1 changed files with 14 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -482,6 +482,18 @@ func (ss *sessions) reset() {
 | 
			
		|||
//////////////////////////// Worker Functions Below ////////////////////////////
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
type sessionCryptoManager struct {
 | 
			
		||||
	phony.Inbox
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *sessionCryptoManager) workerGo(from phony.Actor, f func()) {
 | 
			
		||||
	m.Act(from, func() {
 | 
			
		||||
		util.WorkerGo(f)
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var manager = sessionCryptoManager{}
 | 
			
		||||
 | 
			
		||||
type FlowKeyMessage struct {
 | 
			
		||||
	FlowKey uint64
 | 
			
		||||
	Message []byte
 | 
			
		||||
| 
						 | 
				
			
			@ -527,7 +539,7 @@ func (sinfo *sessionInfo) _recvPacket(p *wire_trafficPacket) {
 | 
			
		|||
		sinfo.checkCallbacks()
 | 
			
		||||
	}
 | 
			
		||||
	sinfo.callbacks = append(sinfo.callbacks, ch)
 | 
			
		||||
	util.WorkerGo(poolFunc)
 | 
			
		||||
	manager.workerGo(sinfo, poolFunc)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sinfo *sessionInfo) _send(msg FlowKeyMessage) {
 | 
			
		||||
| 
						 | 
				
			
			@ -570,7 +582,7 @@ func (sinfo *sessionInfo) _send(msg FlowKeyMessage) {
 | 
			
		|||
		sinfo.checkCallbacks()
 | 
			
		||||
	}
 | 
			
		||||
	sinfo.callbacks = append(sinfo.callbacks, ch)
 | 
			
		||||
	util.WorkerGo(poolFunc)
 | 
			
		||||
	manager.workerGo(sinfo, poolFunc)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sinfo *sessionInfo) checkCallbacks() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue