<commit_before># BPF and Node.js

## Slow DNS version

```sh
tomgco@magellanic $ node dns_slow.js &
```

```sh
tomgco@magellanic $ sudo python3 ./gethostlatency.py
[sudo] password for tomgco: 
TIME      PID    COMM          LATms HOST
16:14:56  12054  node           5.05 google.com
16:14:56  12055  node           0.74 google.com
16:14:56  12056  node           1.13 google.com
16:14:57  12057  node           1.04 google.com
16:14:57  12054  node           1.04 google.com
16:14:57  12055  node           0.91 google.com
16:14:57  12056  node           0.68 google.com
16:14:57  12057  node           1.01 google.com
16:14:57  12054  node           1.02 google.com
16:14:57  12055  node           0.85 google.com
16:14:57  12056  node           0.69 google.com
16:14:57  12057  node           0.84 google.com
16:14:57  12054  node           0.88 google.com
16:14:58  12055  node           0.89 google.com
16:14:58  12056  node           0.87 google.com
16:14:58  12057  node           0.85 google.com
```

### Results

What we can see is that by default NodeJS does not cache DNS requests, so for every `http.get` we are making a DNS request (shown by each line printed out from the BPF python script), slowing our requestsby 1-5ms. (even slower if the dns server has a problem).

## "Fast" DNS Version

```sh
tomgco@magellanic $ node dns_fast.js &
```

```sh
tomgco@magellanic $ sudo python3 ./gethostlatency.py
[sudo] password for tomgco: <commit_msg>Update README (#1)<commit_after># BPF and Node.js

## Slow DNS version

Does not use any DNS cacheing. 

```sh
tomgco@magellanic $ node dns_slow.js &
```

```sh
tomgco@magellanic $ sudo python3 ./gethostlatency.py
[sudo] password for tomgco: 
TIME      PID    COMM          LATms HOST
16:14:56  12054  node           5.05 google.com
16:14:56  12055  node           0.74 google.com
16:14:56  12056  node           1.13 google.com
16:14:57  12057  node           1.04 google.com
16:14:57  12054  node           1.04 google.com
16:14:57  12055  node           0.91 google.com
16:14:57  12056  node           0.68 google.com
16:14:57  12057  node           1.01 google.com
16:14:57  12054  node           1.02 google.com
16:14:57  12055  node           0.85 google.com
16:14:57  12056  node           0.69 google.com
16:14:57  12057  node           0.84 google.com
16:14:57  12054  node           0.88 google.com
16:14:58  12055  node           0.89 google.com
16:14:58  12056  node           0.87 google.com
16:14:58  12057  node           0.85 google.com
```

### Results

What we can see is that by default NodeJS does not cache DNS requests, so for every `http.get` we are making a DNS request (shown by each line printed out from the BPF python script), slowing our requests by 1-5ms (and even slower if the dns server has a problem).

## "Fast" DNS Version

Using an in-processes [DNS cache](https://www.npmjs.com/package/dnscache).

```sh
tomgco@magellanic $ node dns_fast.js &
```

```sh
tomgco@magellanic $ sudo python3 ./gethostlatency.py
[sudo] password for tomgco: 
{'fraction_non_alphanumeric': 0.09445178335535007, 'fraction_numerical': 0.15092470277410833, 'mean_word_length': 2.3031624863685933, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3170627', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1076, 'n_words': 355}