Skip to content

Commit b905304

Browse files
Merge pull request #1426 from pdsouza01/main
Scaling Snort3 - How To Leverage Multithreading For Better Performance : Fix review comments
2 parents 517dd0c + da2f3e9 commit b905304

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

content/learning-paths/servers-and-cloud-computing/snort3-multithreading/build-and-install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ buildInstall()
158158
#------ Execution Start ----------#
159159
# provide nproc count to the scripts , it will be used as -j for make
160160
if [[ $# -ne 2 ]]; then
161-
echo "Usage: $0 <current_working_directory> <nprc>"
161+
echo "Usage: $0 <current_working_directory> <nproc>"
162162
exit 1
163163
fi
164164

content/learning-paths/servers-and-cloud-computing/snort3-multithreading/usecase.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ Before testing multithreading performance, perform the following steps to config
1717

1818
To enable Transparent HugePages (THP) and configure CPU isolation and affinity, append the following line to the /etc/default/grub file:
1919

20+
For the total available online CPUs ranging from 0 to 95, with CPUs 0 to 9 pinned to Snort, the grubfile configuration is shown below.
21+
22+
Feel free to modify the CPU numbers as needed.
2023
```bash
2124
CMDLINE="cma=128"
2225
HUGEPAGES="default_hugepagesz=1G hugepagesz=1G hugepages=300"
2326
MAXCPUS=""
24-
ISOLCPUS="isolcpus=nohz,domain,2-12"
25-
IRQAFFINITY="irqaffinity=2-12"
26-
NOHZ="nohz_full=2-12"
27-
RCU="rcu_nocbs=2-12"
27+
ISOLCPUS="isolcpus=nohz,domain,0-9"
28+
IRQAFFINITY="irqaffinity=10-95"
29+
NOHZ="nohz_full=0-9"
30+
RCU="rcu_nocbs=0-9"
2831
IOMMU="iommu.passthrough=1"
2932
THP="transparent_hugepage=madvise"
3033
GRUB_CMDLINE_LINUX="${CMDLINE} ${HUGEPAGES} ${ISOLCPUS} ${IRQAFFINITY} ${NOHZ} ${RCU} ${MAXCPUS} ${IOMMU} ${THP}"
@@ -53,7 +56,7 @@ The output shows the additions to the kernel command line.
5356
It is similar to:
5457

5558
```output
56-
BOOT_IMAGE=/boot/vmlinuz-6.8.0-1019-aws root=PARTUUID=20d0887f-2302-4e77-9c05-b78f1f0ad30e ro default_hugepagesz=1G hugepagesz=1G hugepages=300 isolcpus=nohz,domain,2-12 irqaffinity=2-12 nohz_full=2-12 rcu_nocbs=2-12 iommu.passthrough=1 transparent_hugepage=madvise console=tty1 console=ttyS0 nvme_core.io_timeout=4294967295 panic=-1
59+
BOOT_IMAGE=/boot/vmlinuz-6.5.0-1020-aws root=PARTUUID=2ca5cb77-b92b-4112-a3e0-eb8bd3cee2a2 ro cma=128 default_hugepagesz=1G hugepagesz=1G hugepages=300 isolcpus=nohz,domain,0-9 irqaffinity=10-95 nohz_full=0-9 rcu_nocbs=0-9 iommu.passthrough=1 transparent_hugepage=madvise console=tty1 console=ttyS0 nvme_core.io_timeout=4294967295 panic=-1
5760
```
5861

5962
You can also confirm the isolated processors:
@@ -65,7 +68,7 @@ cat /sys/devices/system/cpu/isolated
6568
The output shows the isolated processors:
6669

6770
```output
68-
2-12
71+
0-9
6972
```
7073

7174
## Set up the Snort3 rule set
@@ -132,17 +135,16 @@ Use an editor to create a file named `common.lua` with the contents below.
132135
---- change these mappings so that the first N tests use unique cores
133136
threads =
134137
{
135-
{ thread = 0, cpuset = '2' },
136-
{ thread = 1, cpuset = '3' },
137-
{ thread = 2, cpuset = '4' },
138-
{ thread = 3, cpuset = '5' },
139-
{ thread = 4, cpuset = '6' },
140-
{ thread = 5, cpuset = '7' },
141-
{ thread = 6, cpuset = '8' },
142-
{ thread = 7, cpuset = '9' },
143-
{ thread = 8, cpuset = '10' },
144-
{ thread = 9, cpuset = '11' },
145-
{ thread = 10, cpuset = '12' }
138+
{ thread = 0, cpuset = '0' },
139+
{ thread = 1, cpuset = '1' },
140+
{ thread = 2, cpuset = '2' },
141+
{ thread = 3, cpuset = '3' },
142+
{ thread = 4, cpuset = '4' },
143+
{ thread = 5, cpuset = '5' },
144+
{ thread = 6, cpuset = '6' },
145+
{ thread = 7, cpuset = '7' },
146+
{ thread = 8, cpuset = '8' },
147+
{ thread = 9, cpuset = '9' }
146148
}
147149
process = { threads = threads }
148150
search_engine = { }
@@ -164,7 +166,7 @@ Enable all the rules by uncommenting the `enable_builtin_rules` line and adding
164166
```bash
165167
enable_builtin_rules = true,
166168
rules = [[
167-
include ../rules/includes.rules
169+
include ../snort3-community-rules/snort3-community.rules
168170
]],
169171
```
170172
@@ -269,26 +271,23 @@ Use `--max-packet-threads` to specify the number of threads, 10 in this example.
269271
To confirm that the Snort process spans many threads, use the `mpstat` command to evaluate the CPU utilization.
270272
271273
```bash
272-
mpstat -P 2-14 1
274+
mpstat -P 0-9 1
273275
```
274276
275277
The output is similar to:
276278
277279
```output
278280
22:52:26 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
281+
22:52:28 0 98.50 0.00 1.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00
282+
22:52:28 1 98.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
279283
22:52:28 2 98.50 0.00 1.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00
280284
22:52:28 3 98.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
281-
22:52:28 4 98.50 0.00 1.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00
282-
22:52:28 5 98.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
283-
22:52:28 6 98.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
285+
22:52:28 4 98.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
286+
22:52:28 5 99.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
287+
22:52:28 6 99.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
284288
22:52:28 7 99.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
285-
22:52:28 8 99.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
286-
22:52:28 9 99.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
287-
22:52:28 10 98.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
288-
22:52:28 11 97.50 0.00 2.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00
289-
22:52:28 12 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
290-
22:52:28 13 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
291-
22:52:28 14 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
289+
22:52:28 8 98.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
290+
22:52:28 9 97.50 0.00 2.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00
292291
```
293292
294293
## Test Snort3 multi-threading to process single pcap file

0 commit comments

Comments
 (0)