Skip to content

Commit

Permalink
chore: try turning off nagle
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Nov 18, 2023
1 parent 4026fe9 commit 3c20727
Show file tree
Hide file tree
Showing 29 changed files with 1,972 additions and 2 deletions.
11 changes: 9 additions & 2 deletions perf/impl/js-libp2p/next/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { tcp } from './tcp/index.js'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perfService } from '@libp2p/perf'
Expand Down Expand Up @@ -41,7 +41,14 @@ export async function main (runServer, serverIpAddress, transport, uploadBytes,
const { host, port } = splitHostPort(serverIpAddress)

const config = {
transports: [tcp()],
transports: [tcp({
socket: {
noDelay: true
},
server: {
noDelay: true
}
})],
streamMuxers: [yamux()],
connectionEncryption: [
noise()
Expand Down
3 changes: 3 additions & 0 deletions perf/impl/js-libp2p/next/tcp/dist/index.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions perf/impl/js-libp2p/next/tcp/dist/src/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export declare const CODE_P2P = 421;
export declare const CODE_CIRCUIT = 290;
export declare const CODE_UNIX = 400;
export declare const CLOSE_TIMEOUT = 500;
export declare const SOCKET_TIMEOUT: number;
//# sourceMappingURL=constants.d.ts.map
1 change: 1 addition & 0 deletions perf/impl/js-libp2p/next/tcp/dist/src/constants.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions perf/impl/js-libp2p/next/tcp/dist/src/constants.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions perf/impl/js-libp2p/next/tcp/dist/src/constants.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 119 additions & 0 deletions perf/impl/js-libp2p/next/tcp/dist/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/**
* @packageDocumentation
*
* A [libp2p transport](https://docs.libp2p.io/concepts/transports/overview/) based on the TCP networking stack.
*
* @example
*
* ```js
* import { tcp } from '@libp2p/tcp'
* import { multiaddr } from '@multiformats/multiaddr'
* import { pipe } from 'it-pipe'
* import all from 'it-all'
*
* // A simple upgrader that just returns the MultiaddrConnection
* const upgrader = {
* upgradeInbound: async maConn => maConn,
* upgradeOutbound: async maConn => maConn
* }
*
* const transport = tcp()()
*
* const listener = transport.createListener({
* upgrader,
* handler: (socket) => {
* console.this.log('new connection opened')
* pipe(
* ['hello', ' ', 'World!'],
* socket
* )
* }
* })
*
* const addr = multiaddr('/ip4/127.0.0.1/tcp/9090')
* await listener.listen(addr)
* console.this.log('listening')
*
* const socket = await transport.dial(addr, { upgrader })
* const values = await pipe(
* socket,
* all
* )
* console.this.log(`Value: ${values.toString()}`)
*
* // Close connection after reading
* await listener.close()
* ```
*
* Outputs:
*
* ```sh
* listening
* new connection opened
* Value: hello World!
* ```
*/
import { type CreateListenerOptions, type DialOptions, type Transport } from '@libp2p/interface/transport';
import { type CloseServerOnMaxConnectionsOpts } from './listener.js';
import type { ComponentLogger } from '@libp2p/interface';
import type { CounterGroup, Metrics } from '@libp2p/interface/metrics';
import type { AbortOptions } from '@multiformats/multiaddr';
export interface TCPOptions {
/**
* An optional number in ms that is used as an inactivity timeout after which the socket will be closed
*/
inboundSocketInactivityTimeout?: number;
/**
* An optional number in ms that is used as an inactivity timeout after which the socket will be closed
*/
outboundSocketInactivityTimeout?: number;
/**
* When closing a socket, wait this long for it to close gracefully before it is closed more forcibly
*/
socketCloseTimeout?: number;
/**
* Set this property to reject connections when the server's connection count gets high.
* https://nodejs.org/api/net.html#servermaxconnections
*/
maxConnections?: number;
/**
* Parameter to specify the maximum length of the queue of pending connections
* https://nodejs.org/dist/latest-v18.x/docs/api/net.html#serverlisten
*/
backlog?: number;
/**
* Close server (stop listening for new connections) if connections exceed a limit.
* Open server (start listening for new connections) if connections fall below a limit.
*/
closeServerOnMaxConnections?: CloseServerOnMaxConnectionsOpts;
/**
* Options passed to `net.connect` for every opened TCP socket
*/
socket?: TCPSocketOptions;
/**
* Options passed to every `net.createServer` for every TCP server
*/
server?: TCPSocketOptions;
}
/**
* Expose a subset of net.connect options
*/
export interface TCPSocketOptions extends AbortOptions {
noDelay?: boolean;
keepAlive?: boolean;
keepAliveInitialDelay?: number;
allowHalfOpen?: boolean;
}
export interface TCPDialOptions extends DialOptions, TCPSocketOptions {
}
export interface TCPCreateListenerOptions extends CreateListenerOptions, TCPSocketOptions {
}
export interface TCPComponents {
metrics?: Metrics;
logger: ComponentLogger;
}
export interface TCPMetrics {
dialerEvents: CounterGroup;
}
export declare function tcp(init?: TCPOptions): (components: TCPComponents) => Transport;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions perf/impl/js-libp2p/next/tcp/dist/src/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

213 changes: 213 additions & 0 deletions perf/impl/js-libp2p/next/tcp/dist/src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3c20727

Please sign in to comment.