* Buffer reads in FdSource. Together with write buffering, this
significantly cuts down the number of syscalls (e.g., for "nix-store -qR /var/run/current-system" via the daemon, it reduced the number of syscalls in the client from 29134 to 4766 and in the daemon from 44266 to 20666).
This commit is contained in:
		
							parent
							
								
									3a48282b06
								
							
						
					
					
						commit
						a3e0656cbb
					
				
					 2 changed files with 32 additions and 10 deletions
				
			
		|  | @ -38,9 +38,7 @@ struct FdSink : Sink | |||
|     FdSink() : fd(-1), bufSize(32 * 1024), bufPos(0), buffer(0) { } | ||||
|      | ||||
|     FdSink(int fd, unsigned int bufSize = 32 * 1024) | ||||
|         : fd(fd), bufSize(bufSize), bufPos(0), buffer(0) | ||||
|     { | ||||
|     } | ||||
|         : fd(fd), bufSize(bufSize), bufPos(0), buffer(0) { } | ||||
| 
 | ||||
|     ~FdSink() | ||||
|     { | ||||
|  | @ -58,15 +56,17 @@ struct FdSink : Sink | |||
| struct FdSource : Source | ||||
| { | ||||
|     int fd; | ||||
|     unsigned int bufSize, bufPosIn, bufPosOut; | ||||
|     unsigned char * buffer; | ||||
| 
 | ||||
|     FdSource() | ||||
|     { | ||||
|         fd = -1; | ||||
|     } | ||||
|     FdSource() : fd(-1), bufSize(32 * 1024), bufPosIn(0), bufPosOut(0), buffer(0) { } | ||||
|      | ||||
|     FdSource(int fd)  | ||||
|     FdSource(int fd, unsigned int bufSize = 32 * 1024) | ||||
|         : fd(fd), bufSize(bufSize), bufPosIn(0), bufPosOut(0), buffer(0) { } | ||||
|      | ||||
|     ~FdSource() | ||||
|     { | ||||
|         this->fd = fd; | ||||
|         if (buffer) delete[] buffer; | ||||
|     } | ||||
|      | ||||
|     void operator () (unsigned char * data, unsigned int len); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue