# [Solved] Lags every few minutes

## FrostyX

Hi,

I have this strange problem. When I play some game online I have every few minutes ~10s lag. As well as I am on skype. I cant understand even one word for ~10s. I dont know if problem is when browsing sites. Sometimes I can see longer loading of some site, but i dont know if is it related. I have few windows laptops here and they have no problem. My internet connection is not so bad - http://www.speedtest.net/result/2387291327.png and all ports are opened. Where can be a problem please?

There is device information from ifconfig

```
$[FrostyX  ~]-> sudo ifconfig wlan0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.6  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::21c:bfff:fe68:be75  prefixlen 64  scopeid 0x20<link>

        ether 00:1c:bf:68:be:75  txqueuelen 1000  (Ethernet)

        RX packets 1145049  bytes 1041728822 (993.4 MiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 999212  bytes 130014182 (123.9 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
```

This is my wireless card

```
$[FrostyX  ~]-> sudo lspci|grep Wireless

03:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG [Golan] Network Connection (rev 02)
```

And there is last few lines from dmesg - http://pastebin.com/zeqNX8B9Last edited by FrostyX on Sun Jan 06, 2013 5:54 pm; edited 1 time in total

----------

## jpc22

Google tells us you are not the only one having problems with that card.lookin a them point either toward the router or the kernel

Can  you tell us more about your router and its  relative position to the computer  and your wireless signal strenght in % or dbm.

Did the problem show after a kernel update?

I would also check for kernel power management features that could affect the card.

if you happen to have a livedvd laying around i would boot it up and see if the card has the same problems, if not ,check kernel version and drivers.

----------

## FrostyX

At first I want say, thank you. I am glad you are interested about it.

 *Quote:*   

> Can  you tell us more about your router and its  relative position to the computer  and your wireless signal strenght in % or dbm.

 

My router is old Edimax BR-6204Wg. On my hostel is some better router but I don't know name. I'll tell you when I will know it. Network is: few laptops on wifi --> router --> LAN cable going out of our apartment. In both cases I have 100% signal strenght - router is 2 meters from laptop at most (no wall or something between them).

 *Quote:*   

> Did the problem show after a kernel update?

 

Maybe. I dont update periodically, but sometimes when I have time. So it should have to be longer time. Couple of months, maybe half year. I think it worked half year ago.

 *Quote:*   

> I would also check for kernel power management features that could affect the card.

 

I think it will be better when I show my .config http://pastebin.com/PTTBDdRT

 *Quote:*   

> if you happen to have a livedvd laying around i would boot it up and see if the card has the same problems, if not ,check kernel version and drivers.

 

I'll try few live cds and let you know

----------

## wcg

Big lags are sometimes cache flushes. Your kernel caches pages read from

files, either with read() or mmap(). Under memory pressure it will convert

those pages from buffer cache (and/or inode cache, directory cache, etc)

to allocable memory for a new process and/or new file.

If the pages have not been written to by any process, there is no need

to write them back to persistent file storage, and they can simply be

discarded, but if they are "dirty" (changed), then the kernel must write

flush the changes back to persistent file storage (like a hard drive).

Typically, kernels will write back changed file pages every so often

even if nothing else has asked for the memory that they occupy

yet, just to hold down the backlog of "need to be written to disk"

memory pages and protect whatever you are working on from

system crashes, etc.

If the backlog of unwritten dirty pages is big, this can cause a

noticeable pause in other processes when it happens. What

do you have for this value?

```

cat /proc/sys/vm/dirty_writeback_centisecs

```

(If you reduce that value substantially, kernel-scheduled writeback

will happen more often and have smaller numbers of pages to write

to disk when it does. 500 is default, I have read of people lowering

it to 100 or 200.)

I do not know if that will solve your problem, because I do not know

if that is the cause of the behavior you are seeing. One thing to

try, though.

----------

## Ant P.

It's unlikely that a hard disk cache flush would cause network lag.

----------

## FrostyX

 *Quote:*   

> If you reduce that value substantially, kernel-scheduled writeback 
> 
> will happen more often and have smaller numbers of pages to write 
> 
> to disk when it does. 500 is default, I have read of people lowering 
> ...

 

Its crazy but I think it helped. I looked into /proc/sys/vm/dirty_writeback_centisecs and there was 500. I set it to 100 and now I had lags but not that much. Instead of 10s I have 1-3s lags ... What else you think I should check or set?

[EDIT] It was some good aura, cause today it was bad again. So probably /proc/sys/vm/dirty_writeback_centisecs didnt help.

----------

## FrostyX

On IRC we have found I am using swap, so I have added

```
vm.dirty_writeback_centisecs = 200

vm.swappiness=20

```

 into /etc/sysctl.conf and did sudo sysctl -p

Then I did 

```
sudo swapoff -a

sudo swapon -a
```

I have checked it, no swap is used while lags

I have stopped cron and statusbars, looked into /var/log/messages and there is nothing (you can see it here http://pastebin.com/pemBnLkJ).

[Edit] Using LAN cable instead of wifi - no lags at all.

What now?

----------

## PaulBredbury

Are there any wireless options you can experiment with, especially e.g. disabling power-saving for the wireless card?

----------

## wcg

From your description, the problem is clearly periodic.

What else is periodic besides kernel buffer cache flushes?

Anything specifically in wifi networking that you can

turn off? (Like scanning for new ssids in the local environment?)

----------

## FrostyX

Three days I have been using wicd instead of networkmanager and I had no lags at all. No lags in games, no lags on skype, no lags in web browser.

Cause I used networkmanager only by habbit and now wicd suits me better, I'll stay with it.

I am changing title to [Solved]

----------

