Skip to content

Commit d5b9686

Browse files
committed
test
1 parent e5ed50e commit d5b9686

File tree

8 files changed

+51
-13
lines changed

8 files changed

+51
-13
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ RUN git config --global http.sslVerify false
99
RUN nim c \
1010
-d:chronicles_sinks=json \
1111
--threads:on \
12+
--passL:"./libtcmalloc.so" \
13+
--gc:orc -d:useMalloc \
1214
-d:metrics -d:libp2p_network_protocols_metrics -d:release \
1315
quic.nim
1416

15-
FROM debian:bookworm-slim
17+
FROM nimlang/nim:2.2.6-ubuntu-regular
1618

1719
RUN apt-get update && \
1820
apt-get install -y --no-install-recommends \
@@ -29,6 +31,8 @@ WORKDIR /node
2931

3032
COPY --from=build /node/quic /node/quic
3133

34+
COPY ./libtcmalloc.so .
35+
3236
COPY ./entrypoint.sh .
3337

3438
RUN chmod +x quic

build-docker.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
docker build -t nim-libp2p/quic .

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ services:
7676
- target: 8008 # prometheus
7777
published: 0
7878
protocol: tcp
79+
volumes:
80+
- ./vg-logs:/node/vg-logs
7981
depends_on:
8082
redis:
8183
condition: service_healthy

entrypoint.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
#!/bin/sh
2-
set -eu
1+
#!/usr/bin/env bash
32

4-
if [ -n "${NETEM:-}" ]; then
5-
tc qdisc add dev eth0 root netem $NETEM
6-
fi
3+
LOG_DIR=${VALGRIND_LOG_DIR:-/node/vg-logs}
4+
mkdir -p "$LOG_DIR"
75

8-
./quic
6+
ls -la
7+
8+
LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" HEAPPROFILE="$LOG_DIR/vg-${HOSTNAME:-node}.log" ./quic
9+
10+
cp ./quic $LOG_DIR/quic-${HOSTNAME:-node}

quic.nim

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ proc createMessageHandler(): proc(topic: string, data: seq[byte]) {.async, gcsaf
1717
var messagesChunks: CountTable[uint64]
1818

1919
return proc(topic: string, data: seq[byte]) {.async, gcsafe.} =
20+
echo "RECV: ", data.len
21+
#[
2022
let sentUint = uint64.fromBytesLE(data)
2123
# warm-up
2224
if sentUint < 1000000:
@@ -30,6 +32,7 @@ proc createMessageHandler(): proc(topic: string, data: seq[byte]) {.async, gcsaf
3032
sentNanosecs = nanoseconds(sentMoment - seconds(sentMoment.seconds))
3133
sentDate = initTime(sentMoment.seconds, sentNanosecs)
3234
diff = getTime() - sentDate
35+
]#
3336

3437
proc messageValidator(topic: string, msg: Message): Future[ValidationResult] {.async.} =
3538
return ValidationResult.Accept
@@ -89,8 +92,6 @@ proc connectGossipsubPeers(
8992
return ok(connected)
9093

9194
proc subscribGossipsubTopic(gossipSub: GossipSub, topic: string) =
92-
93-
9495
gossipSub.subscribe(topic, createMessageHandler())
9596
gossipSub.addValidator([topic], messageValidator)
9697

@@ -179,11 +180,13 @@ proc main() {.async.} =
179180

180181
info "Starting listening endpoint for publish controller"
181182

182-
while true:
183-
discard await gossipSub.publishNewMessage(50 * 1024, "test")
184-
await sleepAsync(5.seconds)
183+
let x = proc() {.async.} =
184+
while true:
185+
discard await gossipSub.publishNewMessage(50 * 1024, "test")
186+
await sleepAsync(5.seconds)
185187

188+
asyncSpawn x()
186189

187-
await sleepAsync(2.days)
190+
await sleepAsync(10.minutes)
188191

189192
waitFor(main())

start.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
docker compose down -v
3+
rm -Rf vg-logs/*.heap
4+
rm -Rf vg-logs/quic*
5+
TRANSPORT=TCP NUM_LIBP2P_NODES=10 docker compose up -d

stop.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
docker compose down -v

valgrind.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
LOG_DIR=${VALGRIND_LOG_DIR:-/node/vg-logs}
4+
mkdir -p "$LOG_DIR"
5+
LOG_FILE="$LOG_DIR/vg-${HOSTNAME:-node}.log"
6+
7+
for i in $(seq 1 2000); do
8+
echo "run $i (logging to $LOG_FILE)"
9+
valgrind \
10+
--tool=memcheck \
11+
--leak-check=full \
12+
--show-leak-kinds=all \
13+
--track-origins=yes \
14+
--num-callers=40 \
15+
--error-exitcode=99 \
16+
./quic 2>"$LOG_FILE" && echo "ok" || break
17+
done
18+
#./quic

0 commit comments

Comments
 (0)