Skip to content

Commit

Permalink
chore: add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Jan 11, 2021
1 parent 212d754 commit b28edc8
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 25 deletions.
27 changes: 4 additions & 23 deletions .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
const Libp2p = require('libp2p')
const { MULTIADDRS_WEBSOCKETS } = require('./test/fixtures/browser')
const Peers = require('./test/fixtures/peers')
const docker = require('./mysql-local/docker')
const PeerId = require('peer-id')
const WebSockets = require('libp2p-websockets')
const Muxer = require('libp2p-mplex')
const { NOISE: Crypto } = require('libp2p-noise')

const delay = require('delay')
const execa = require('execa')
const pWaitFor = require('p-wait-for')
const isCI = require('is-ci')

let libp2p
Expand Down Expand Up @@ -50,34 +48,17 @@ const before = async () => {
return
}

const procResult = execa.commandSync('docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=test-secret-pw -e MYSQL_DATABASE=libp2p_rendezvous_db -d mysql:8 --default-authentication-plugin=mysql_native_password', {
all: true
})
containerId = procResult.stdout

console.log(`wait for docker container ${containerId} to be ready`)

await pWaitFor(() => {
const procCheck = execa.commandSync(`docker logs ${containerId}`)
const logs = procCheck.stdout + procCheck.stderr // Docker/MySQL sends to the stderr the ready for connections...

return logs.includes('ready for connections')
}, {
interval: 5000
})
// Some more time waiting to guarantee the container is really ready
await delay(12e3)
containerId = await docker.start()
}

const after = async () => {
await libp2p.stop()

if (isCI) {
if (isCI || !containerId) {
return
}

console.log('docker container is stopping')
execa.commandSync(`docker stop ${containerId}`)
docker.stop(containerId)
}

module.exports = {
Expand Down
108 changes: 108 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Rendezvous benchmarks

This benchmark contains a simulator to exercise a rendezvous server and gather performance metrics from it.

## Running

For running the benchmarks, it is required to install the dependencies of the `libp2p-rendezvous`, as well as Docker. With those installed, you only need to run the `index.js` file as follows:

```sh
$ npm install
$ cd benchmarks
$ node index.js
```

While default values exist for benchmarking, you can use CLI parameters to configure how to run the benchmark.

### Configuration

TODO

### Output

TODO

## Metrics

- Operations {Register, Discover}
- Average response time
- Maximum response time
- Median response time
- Server performance
- CPU
- Memory

## Scenarios

### Register

Measure adding n registrations. Each operation in the following table

| Type | Clients | Io registrations | Operations | Namespaces |
|------|---------|------------------|------------|------------|
| `Register` | 5 | 0 | 500 | 10 |
| `Register` | 5 | 1000 | 500 | 10 |
| `Register` | 10 | 1000 | 500 | 10 |
| `Register` | 100 | 1000 | 500 | 10 |
| `Register` | 100 | 1000 | 1000 | 10 |
| `Register` | 100 | 10000 | 500 | 10 |
| `Register` | 100 | 100000 | 1000 | 10 |
| `Register` | 100 | 100000 | 10000 | 10 |
| `Register` | 1000 | 100000 | 10000 | 10 |
| `Register` | 1000 | 100000 | 100000 | 10 |
| `Register` | 1000 | 1000000 | 10000 | 10 |
| `Register` | 1000 | 1000000 | 100000 | 10 |
| `Register` | 1000 | 10000000 | 10000 | 10 |
| `Register` | 1000 | 10000000 | 100000 | 10 |
| `Register` | 1000 | 100000000 | 10000 | 10 |
| `Register` | 1000 | 100000000 | 100000 | 10 |

### Discover

1. Measure discover 500 existing registrations in series with limit of 20

| Type | Io registrations | Io namespaces |
|------|------------------|------------------|
| `Discover` | 0 | 0 |
| `Discover` | 100 | 10 |
| `Discover` | 1000 | 10 |
| `Discover` | 1000 | 100 |
| `Discover` | 10000 | 10 |
| `Discover` | 10000 | 100 |
| `Discover` | 10000 | 1000 |
| `Discover` | 100000 | 10000 |
| `Discover` | 1000000 | 10 |
| `Discover` | 1000000 | 100 |
| `Discover` | 1000000 | 1000 |
| `Discover` | 1000000 | 10000 |
| `Discover` | 1000000 | 100000 |
| `Discover` | 10000000 | 100000 |
| `Discover` | 100000000 | 100000 |

2. Measure trying to discover 500 not existing registrations in series

| Type | Io registrations | Io namespaces |
|------|------------------|------------------|
| `Discover` | 0 | 0 |
| `Discover` | 100 | 10 |
| `Discover` | 1000 | 10 |
| `Discover` | 1000 | 100 |
| `Discover` | 10000 | 10 |
| `Discover` | 10000 | 100 |
| `Discover` | 10000 | 1000 |
| `Discover` | 100000 | 10000 |
| `Discover` | 1000000 | 10 |
| `Discover` | 1000000 | 100 |
| `Discover` | 1000000 | 1000 |
| `Discover` | 1000000 | 10000 |
| `Discover` | 1000000 | 100000 |
| `Discover` | 10000000 | 100000 |
| `Discover` | 100000000 | 100000 |

3. Cookies



| Type | Io Reg | Namespaces | Ops | Average RT (ms) | Median RT (ms) | Max RT (ms) | Min RT (ms) |
|----------|--------|------------|-----|-----------------|----------------|-------------|-------------|
| REGISTER | 100 | 500 | 5 | 1243 | 1228 | 2456 | 24 |
5 changes: 5 additions & 0 deletions benchmarks/id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "12D3KooWPCDhKA2NoJCnxUqKmBNLVg6ekNzcw9GVsncLgfdbN2pm",
"privKey": "CAESYDprk82zAJeNcIHxgj3seEWRLCOh+7e7yTBVx1IW38HnxsEgoQGbW5xJDd7GHml2Mb8LNxsdB+WgznkhDLYZL97GwSChAZtbnEkN3sYeaXYxvws3Gx0H5aDOeSEMthkv3g==",
"pubKey": "CAESIMbBIKEBm1ucSQ3exh5pdjG/CzcbHQfloM55IQy2GS/e"
}
Loading

0 comments on commit b28edc8

Please sign in to comment.