Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fileget: allocate a slice with enough capacity #343

Merged
merged 5 commits into from
Mar 10, 2020

Commits on Mar 9, 2020

  1. fileget: allocate a slice with enough capacity

    so a new allocation is not needed in MarshalBinary and sendPacket.
    
    Here are some profiling results while downloading a file (file size is about 1GB),
    
    before this patch:
    
    1254.24MB 55.18% 55.18%  1254.24MB 55.18%  github.com/pkg/sftp.sshFxpDataPacket.MarshalBinary
      991.81MB 43.63% 98.81%   991.81MB 43.63%  github.com/pkg/sftp.fileget
           1MB 0.044% 98.86%  1255.24MB 55.22%  github.com/pkg/sftp.(*packetManager).maybeSendPackets
        0.50MB 0.022% 98.88%  1260.24MB 55.44%  github.com/pkg/sftp.(*packetManager).controller
             0     0% 98.88%   991.81MB 43.63%  github.com/pkg/sftp.(*Request).call
             0     0% 98.88%   993.31MB 43.70%  github.com/pkg/sftp.(*RequestServer).Serve.func1.1
             0     0% 98.88%   993.31MB 43.70%  github.com/pkg/sftp.(*RequestServer).packetWorker
             0     0% 98.88%  1254.24MB 55.18%  github.com/pkg/sftp.(*conn).sendPacket
             0     0% 98.88%  1254.24MB 55.18%  github.com/pkg/sftp.sendPacket
    
    with this patch:
    
    1209.48MB 98.46% 98.46%  1209.48MB 98.46%  github.com/pkg/sftp.fileget
           2MB  0.16% 98.63%     7.50MB  0.61%  github.com/pkg/sftp.recvPacket
             0     0% 98.63%        8MB  0.65%  github.com/drakkan/sftpgo/sftpd.Configuration.handleSftpConnection
             0     0% 98.63%  1209.48MB 98.46%  github.com/pkg/sftp.(*Request).call
             0     0% 98.63%        8MB  0.65%  github.com/pkg/sftp.(*RequestServer).Serve
             0     0% 98.63%  1209.98MB 98.50%  github.com/pkg/sftp.(*RequestServer).Serve.func1.1
             0     0% 98.63%  1209.98MB 98.50%  github.com/pkg/sftp.(*RequestServer).packetWorker
             0     0% 98.63%     7.50MB  0.61%  github.com/pkg/sftp.(*conn).recvPacket (inline)
    drakkan committed Mar 9, 2020
    Configuration menu
    Copy the full SHA
    44e44d7 View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2020

  1. FxpReadPacket: add an helper method for slice allocation

    This way we can use the same method in both server and request-server
    drakkan committed Mar 10, 2020
    Configuration menu
    Copy the full SHA
    eeafeef View commit details
    Browse the repository at this point in the history
  2. server: remove now unused maxTxPacket

    maxTxPacket was only used to get the size for the read packet it is not
    needed anymore
    drakkan committed Mar 10, 2020
    Configuration menu
    Copy the full SHA
    3ea9f24 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0f0e40a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0a45bc4 View commit details
    Browse the repository at this point in the history