diff --git a/pkg/codec/raptorq.go b/pkg/codec/raptorq.go index 86efbd79..8e0c1c6c 100644 --- a/pkg/codec/raptorq.go +++ b/pkg/codec/raptorq.go @@ -15,7 +15,7 @@ const ( rqSymbolSize uint16 = 65535 rqRedundancyFactor uint8 = 6 // Limit RaptorQ processor memory usage to ~2 GiB - rqMaxMemoryMB uint64 = 16 * 1024 // MB + rqMaxMemoryMB uint64 = 2 * 1024 // MB // Concurrency tuned for 2 GiB limit and typical 8+ core CPUs rqConcurrency uint64 = 6 // Target single-block output for up to 1 GiB files with padding headroom (~1.25 GiB) diff --git a/supernode/node/supernode/server/server.go b/supernode/node/supernode/server/server.go index 5796ced6..7ded8eb7 100644 --- a/supernode/node/supernode/server/server.go +++ b/supernode/node/supernode/server/server.go @@ -58,16 +58,16 @@ func (server *Server) Run(ctx context.Context) error { logtrace.Fatal(ctx, "Failed to setup gRPC server", logtrace.Fields{logtrace.FieldModule: "server", logtrace.FieldError: err.Error()}) } - // Optimized for streaming 1GB files with 4MB chunks (10 concurrent streams) + // Tuned for 1GB max files with 4MB chunks. Reduce in-flight memory. opts := grpcserver.DefaultServerOptions() - opts.MaxRecvMsgSize = (16 * 1024 * 1024) // 16MB (supports 4MB chunks + overhead) - opts.MaxSendMsgSize = (16 * 1024 * 1024) // 16MB for download streaming - opts.InitialWindowSize = (16 * 1024 * 1024) // 16MB per stream (4x chunk size) - opts.InitialConnWindowSize = (160 * 1024 * 1024) // 160MB (16MB x 10 streams) - opts.MaxConcurrentStreams = 20 // Limit to prevent resource exhaustion - opts.ReadBufferSize = (8 * 1024 * 1024) // 8MB TCP buffer - opts.WriteBufferSize = (8 * 1024 * 1024) // 8MB TCP buffer + opts.MaxRecvMsgSize = (8 * 1024 * 1024) // 8MB supports 4MB chunks + overhead + opts.MaxSendMsgSize = (8 * 1024 * 1024) // 8MB for download streaming + opts.InitialWindowSize = (4 * 1024 * 1024) // 4MB per-stream window ~ chunk size + opts.InitialConnWindowSize = (64 * 1024 * 1024) // 64MB per-connection window + opts.MaxConcurrentStreams = 20 // Prevent resource exhaustion + opts.ReadBufferSize = (1 * 1024 * 1024) // 1MB TCP buffer + opts.WriteBufferSize = (1 * 1024 * 1024) // 1MB TCP buffer for _, address := range addresses { addr := net.JoinHostPort(strings.TrimSpace(address), strconv.Itoa(server.config.Port))