# FreeBSD desktop performance- Am I using Shared Memory?



## scratchmo (Jan 7, 2011)

Hello. In my office, my main workstation is an AMD 64 x2 PC w/ 8GB ram and nVidia twinview. It usually runs Linux but since FreeBSD has nVidia AMD64 drivers again, I've decided to give it a go.

My configuration is pretty spartan, Developer + Kernel Developer + Xorg, nvidia-driver, Fluxbox, enlightenment, Firefox and mplayer from ports.

Performance doesn't seem to be all that it could be so I'm afraid. Often Firefox hangs for awhile, unresponsive, though it will after many seconds get around to fullfilling all the requests I clicked on (like changing between tabs, closing a tab, scrolling). Perhaps nswrapper+linuxflash10 is the problem?

All this performance makes me think I may have omitted some configuration some where. 

For instance, a few programs are complaining about "Shared memory":
If I enable the "Composite" module in enlightenment it promptly SEGV's (E17 catches it and offers me recovery). At the command line I see many lines 

```
Currently unimplemented ecore_x_image_get without shm
```

Now, I see when playing mplayer 

```
VO: [xv] 320x240 => 320x240 Planar YV12 
[VO_XV] Shared memory not supported
Reverting to normal Xv.
[VO_XV] Shared memory not supported
Reverting to normal Xv.
```

I've noodled a bit with my sysctl (after I experienced these) but I generally trust the more experienced developers that set them.

```
fiery# sysctl -a | grep shm
kern.ipc.shm_allow_removed: 1
kern.ipc.shm_use_phys: 0
kern.ipc.shmall: 8192
kern.ipc.shmseg: 128
kern.ipc.shmmni: 192
kern.ipc.shmmin: 1
kern.ipc.shmmax: 33554432
kern.features.posix_shm: 1
```

Am I somehow missing this magical shared-memory thing? 

Thanks in advance.


----------



## rusty (Jan 8, 2011)

I have these in /etc/sysctl.conf


```
# Enhance shared memory X11 interface
kern.ipc.shmmax=67108864
kern.ipc.shmall=32768
#
# Enhance desktop responsiveness under high CPU use (200/224)
kern.sched.preempt_thresh=224
```


----------



## wblock@ (Jan 8, 2011)

scratchmo said:
			
		

> Performance doesn't seem to be all that it could be so I'm afraid. Often Firefox hangs for awhile, unresponsive, though it will after many seconds get around to fullfilling all the requests I clicked on (like changing between tabs, closing a tab, scrolling). Perhaps nswrapper+linuxflash10 is the problem?



Maybe, although I don't see that.  Look for an AllowEmptyInput setting in your xorg.conf.  It may not be the cause of this problem, but check the easy stuff first.


----------



## scratchmo (Jan 9, 2011)

wblock said:
			
		

> Maybe, although I don't see that.  Look for an AllowEmptyInput setting in your xorg.conf.  It may not be the cause of this problem, but check the easy stuff first.



`$ man xorg.conf`


```
Option "AllowEmptyInput" "boolean"
              If  enabled,  don't add the standard keyboard and mouse drivers,
              if there are no input devices in the config  file.   Enabled  by
              default if AutoAddDevices and AutoEnableDevices is enabled, oth-
              erwise disabled.  If AllowEmptyInput is on,  devices  using  the
              kbd, mouse or vmmouse driver are ignored.

       Option "AutoAddDevices" "boolean"
              If  this  option is disabled, then no devices will be added from
              HAL events.  Enabled by default.

       Option "AutoEnableDevices" "boolean"
              If this option is disabled, then the devices will be added  (and
              the  DevicePresenceNotify  event  sent),  but  not enabled, thus
              leaving policy up to the client.  Enabled by default.
```

None of these is set in xorg.conf so I must be at defaults. Which setting are you recommending for this knob?


----------



## scratchmo (Jan 9, 2011)

rusty said:
			
		

> I have these in /etc/sysctl.conf
> 
> 
> ```
> ...


I will try your recommended sysctl's tomorrow. Do they require a reboot?


----------



## wblock@ (Jan 9, 2011)

scratchmo said:
			
		

> None of these is set in xorg.conf so I must be at defaults. Which setting are you recommending for this knob?



Leaving it out, i.e., at the default.  See AllowEmptyInput, FreeBSD, and Xorg Input.


----------



## rusty (Jan 9, 2011)

scratchmo said:
			
		

> I will try your recommended sysctl's tomorrow. Do they require a reboot?



As far as I know you can set them on the fly.


----------



## scratchmo (Jan 11, 2011)

rusty said:
			
		

> I have these in /etc/sysctl.conf
> 
> 
> ```
> ...



On your advice I set my system as follows:


```
kern.ipc.shmmax: 33554432 -> 67108864
kern.ipc.shmall: 8192 -> 32768
kern.sched.preempt_thresh: 64 -> 224
```

I now no longer get the shared memory messages from mplayer and composited started working from E17. How weird!

While there is still some weirdness with Firefox, I think it is a separate issue and am marking this thread solved. Thank you for your responses!


----------

