Archive

Archive for February, 2009

Текстове на песни в dirimp3.com

February 23rd, 2009 No comments

Добавени са нови екстри към търсачката за музика вече е и търсачка за текстове на песни :D Базата данни се състои от 415 хиляди уникални текстове на песни

MySQL table crash

February 16th, 2009 No comments

Днес имаше crash на основната mysql таблицата на dirimp3.com около час борба и check-ване и пускане на разни tools, сайта отново е на лице.

Част от лога:

# ./myisamchk -c dirimp3/music.MYI
Checking MyISAM file: dirimp3/music.MYI
myisamchk: warning: 1 client is using or hasn’t closed the table properly
- check file-size
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
- check data record references index: 2
- check data record references index: 3
- check data record references index: 4
myisamchk: error: Found key at page 32574464 that points to record outside datafile
- check record links
myisamchk: error: Keypointers and record positions doesn’t match
MyISAM-table ‘dirimp3/music.MYI’ is corrupted

# ./myisamchk -r dirimp3/music.MYI
- recovering (with sort) MyISAM-table ‘dirimp3/music.MYI’
- Fixing index 1
- Fixing index 2
- Fixing index 3
- Fixing index 4

# ./myisamchk -o dirimp3/music.MYI
- recovering (with keycache) MyISAM-table ‘dirimp3/music.MYI’
Duplicate key 4 for record at 1726560 against new record at 423740
Duplicate key 4 for record at 46808668 against new record at 6501208
Killed

Това е крайния резултат:

MyISAM file: xxxx/dirimp3/music.MYI
Record format: Packed
Character set: utf8_general_ci (45)
File-version: 1
Creation time: 2009-01-25 15:32:44
Recover time: 2009-02-15 18:47:35
Status: open,changed
Datafile length: 142761600 Keyfile length: 153101312
Max datafile length: 281474976710654 Max keyfile length: 288230376151710719
Recordlength: 101

PHP тестове за опитимизация

February 10th, 2009 No comments

Вчера от някъде ми попаднаха 40 съвета за оптимизране на PHP код, реших да направя някои тестове и да проверя дали това което казват е вярно :D

1. Не използвайте @ пред функция, резултати от тестовете:
създадох един малък масив и пред print_r добавих @:

със @:

Array
(
[3] => 1
[4] => 4
[5] => 1
[6] => 8
[7] => 9
[1] => 14
)
Exec Time: 0.0355
Memory Usage: 1044

без @:

Array
(
[3] => 1
[4] => 4
[5] => 1
[6] => 8
[7] => 9
[1] => 14
)
Exec Time: 0.0282
Memory Usage: 952

II. Номер 2 е проверка дължината на стринг, изпълнението на strlen забавя изпълнението на кода:

if (strlen($foo) < 5) { echo "Foo is too short"; }

Foo is too short
Exec Time: 0.0521
Memory Usage: 932

if (!isset($foo{5})) { echo “Foo is too short”; }

Foo is too short
Exec Time: 0.0009
Memory Usage: 816