Skip to content

Instantly share code, notes, and snippets.

@kazuho
kazuho / procstat
Created Jun 19, 2020
script for collecting CPU and network usage
View procstat
#! /usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Scope::Guard;
my $nic;
GetOptions("nic=s" => \$nic);
View benchmark.md

Setup

*** sysctl

  • net.core.rmem_default=8MB
  • net.core.wmem_default=2MB

GSO size: Number of packets

@kazuho
kazuho / fusionbench.c
Last active Jun 14, 2020
Tiny benchmark program for picotls-fusion
View fusionbench.c
/*
* Copyright (c) 2020 Fastly, Kazuho Oku
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
View gist:37d860d8199fb69e0043f5dd2e92dca3
# コンパイル
gcc -fno-lto -march=native -O2 -fno-unroll-loops -I include lib/picotls.c lib/fusion.c t/fusionbench.c
# それぞれのパラメータで動かし、スループット(-bの値 x -nの値 / 所要時間)を計算
time ./a.out -b 1440 -n 10000000
time ./a.out -b 1440 -n 10000000 -s
time ./a.out -b 16384 -n 1000000
time ./a.out -b 16384 -n 1000000 -s
View fusionbench.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "picotls/fusion.h"
int main(int argc, char **argv)
{
static const uint8_t key[16] = {}, iv[12] = {}, aad[13] = {};
ptls_fusion_aesgcm_context_t ctx;
View fusionbench.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "picotls/fusion.h"
int main(int argc, char **argv)
{
static const uint8_t key[16] = {}, iv[12] = {}, aad[13] = {};
ptls_fusion_aesgcm_context_t ctx;
View gist:02c0d512ea9e10c6f45e0d0fad5de091
int main(int argc, char **argv)
{
static const uint8_t key[16] = {}, iv[12] = {}, aad[13] = {}, text[16384] = {};
ptls_fusion_aesgcm_context_t ctx;
uint8_t encrypted[sizeof(text) + 16];
size_t textlen = 16384;
// 以下のifを追加すると0.7秒遅くなる
if (sscanf(argv[1], "%zu", &textlen) != 1) {
fprintf(stderr, "failed to obtain text length from argument\n");
View gist:969166ece9d0ed1dffeab6fba46ba8f0
Features for enx8cae4ce93c4a:
rx-checksumming: on
tx-checksumming: on
tx-checksum-ipv4: on
tx-checksum-ip-generic: off [fixed]
tx-checksum-ipv6: on
tx-checksum-fcoe-crc: off [fixed]
tx-checksum-sctp: off [fixed]
scatter-gather: off
tx-scatter-gather: off [fixed]
View gist:bd413b9a333f03557256b031b95c4d86
recvmsg (1200 bytes):
cc ff 00 00 1b 14 d6 b0 09 2f f9 2b b4 e8 15 8d
9f 30 ad af 83 bf 9f eb 64 0f 04 64 9c 87 9e 00
44 8e 44 92 0c 7b c2 01 fc 33 91 0a 25 75 0f 1d
b4 9c 99 fe b8 fd c7 31 41 01 43 cb 31 88 90 ac
07 9b cd 44 e0 61 b8 a5 16 e4 38 56 b3 8b 02 3a
ff bf 11 47 8c b0 a2 cf 79 ab 33 68 fc 56 d6 6e
fb ca dc f1 dd b1 f6 c4 7c 27 2b 6a b0 7a cb e3
8b f3 1a b5 5b 6e 9c 2a eb 08 10 c3 e7 2b 0b 43
f1 17 92 3a d8 a1 f5 2d db fa a2 f4 ca 88 89 a0
@kazuho
kazuho / events.json
Created Feb 18, 2020
Excess gaps (>63) in stream receive buffer leading to connection close
View events.json
This file has been truncated, but you can view the full file.
{"type":"connect", "conn":0, "time":1581997843074, "version":4278190105}
{"type":"send", "conn":0, "time":1581997843074, "state":0, "dcid":"b1ca3df5b2c738ca"}
{"type":"packet-prepare", "conn":0, "time":1581997843074, "first-octet":192, "dcid":"b1ca3df5b2c738ca"}
{"type":"stream-send", "conn":0, "time":1581997843074, "stream-id":-1, "off":0, "len":256, "is-fin":0}
{"type":"quictrace-send-stream", "conn":0, "time":1581997843074, "stream-id":-1, "off":0, "len":256, "fin":0}
{"type":"packet-commit", "conn":0, "time":1581997843074, "pn":0, "len":1280, "ack-only":0}
{"type":"quictrace-sent", "conn":0, "time":1581997843074, "pn":0, "len":1280, "packet-type":0}
{"type":"receive", "conn":0, "time":1581997843080, "dcid":"", "name":"0x7ffee1e31770", "first-octet":205, "num-bytes":200}
{"type":"crypto-decrypt", "conn":0, "pn":0, "name":"0x7ffee1e31784", "decrypted-len":164}
You can’t perform that action at this time.