Skip to content

Commit

Permalink
perf: optimize curl connection settings
Browse files Browse the repository at this point in the history
Improve performance of HTTP requests by:
- Enabling keepalive connections with 60s timeout
- Disabling compression since responses are already streamed
- Maintaining TCP nodelay and no-buffer settings for efficient streaming
- Adding explicit timeouts for better connection handling

The changes aim to reduce latency and improve overall request efficiency
while maintaining reliable streaming behavior.
  • Loading branch information
deathbeam committed Nov 26, 2024
1 parent 49edd2e commit d2a0623
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lua/CopilotChat/copilot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,19 @@ local Copilot = class(function(self, proxy, allow_insecure)
-- Wait 1 second between retries
'--retry-delay',
'1',
-- Maximum time for the request
-- Keep connections alive for better performance
'--keepalive-time',
'60',
-- Disable compression (since responses are already streamed efficiently)
'--no-compressed',
-- Important timeouts
'--max-time',
math.floor(TIMEOUT * 2 / 1000),
-- Timeout for initial connection
'--connect-timeout',
'10',
'--no-keepalive', -- Don't reuse connections
'--tcp-nodelay', -- Disable Nagle's algorithm for faster streaming
'--no-buffer', -- Disable output buffering for streaming
-- Streaming optimizations
'--tcp-nodelay',
'--no-buffer',
},
}
end)
Expand Down

0 comments on commit d2a0623

Please sign in to comment.