# DTrace unable to resize buffers



## tuto2 (Dec 18, 2020)

Hi all, I've spent about a week learning and using the DTrace framework and it has worked fantastic. I have also become increasingly familiar with FreeBSD (specifically the kernel) over the last couple of months, but I realize I might still be unaware about a lot of things, so forgive any ignorance.

With that out of the way, let me describe the context of the problem I'm facing:
I'm currently performance-testing a new AMD 10Gb Ethernet driver which has recently made it's way into the kernel (https://reviews.freebsd.org/D25793) using DTrace. When testing, I get a lot of messages stating that dynamic variables have been dropped:


```
dtrace: buffer size lowered to 1m
dtrace: aggregation size lowered to 1m
dtrace: 1 dynamic variable drop
dtrace: 16 dynamic variable drops
dtrace: 5 dynamic variable drops
dtrace: 63 dynamic variable drops
dtrace: 26 dynamic variable drops
```
Under full load these numbers are significantly higher. I am also aware that optimizations in the script could be performed, as described by Brendan Gregg in http://dtrace.org/blogs/brendan/2011/11/25/dtrace-variable-types/. 

Besides the possible optimizations, another solution would be to tune the buffer policy, like setting it to a ringbuffer, or increasing the buffer size in the relevant D script like so:


```
#pragma D option bufpolicy=ring
#pragma D option bufresize=manual
#pragma D option bufsize=16m
#pragma D option dynvarsize=16m
#pragma D option aggsize=16m
```
When setting the bufresize option to 'manual', with a bufsize of ANYTHING higher than '1m'; DTrace always responds with 

```
dtrace: could not enable tracing: Cannot allocate memory
```
 As such, setting the 'bufresize' policy to 'auto' will always decrease the buffer size to 1m, as described by the DTrace documentation: 


> You can configure the policy for buffer allocation failure using bufresize option, which defaults to auto. Under the auto buffer resize policy, the size of a buffer is halved until a successful allocation occurs. dtrace(1M) generates a message if a buffer as allocated is smaller than the requested size:
> 
> ```
> # dtrace -P syscall -b 4g
> ...


Why am I not able to set a higher bufsize? I am unsure of how to debug this issue.

Thanks in advance for any help


----------

