Showing posts with label performance. Show all posts
Showing posts with label performance. Show all posts

Thursday, January 21, 2010

Git aliases

I found this very useful in day-to-day git work.
[alias]
    a = add

    s = status --short
    ss = status

    b = branch -a
    ba = branch -a -vv
    bs = !git-branch-status
    bsi = !git-branch-status -i

    c = commit
    cm = commit -m

    co = checkout

    d = diff --color
    ds = diff --color --stat
    dsp = diff --color --stat -p
    # files changed between commits
    dn = diff --color --name-only

    l = log --color --decorate
    ls = log --color --stat --decorate
    ln = log --name-status --color
    lsp = log --color --stat -p --decorate
    lg = log --graph '--pretty=tformat:%Cblue%h%Creset %Cgreen%ar%Creset %Cblue%d%Creset %s'
    lga = log --graph '--pretty=tformat:%Cblue%h%Creset %Cgreen%ar%Creset %Cblue%d%Creset %s' --all
    l10 = log --graph '--pretty=tformat:%Cblue%h%Creset %Cgreen%ar%Creset %Cblue%d%Creset %s' --all -10
    # for complicated branches
    lsd = log --graph '--pretty=tformat:%Cblue%h%Creset %Cgreen%ar%Creset %Cblue%d%Creset %s' --all --simplify-by-decoration

    ru = remote update
    sb = show-branch --sha1-name

    ls-del = ls-files -d
    ls-mod = ls-files -m # including remote files
    ls-new = ls-files --exclude-standard -o
    ls-ign = ls-files --exclude-standard -o -i

Update (2012-11-11)
https://gist.github.com/4056358

Monday, November 23, 2009

Skype HQ

По мотивам поста на хабре привожу примерные настройки для более качественного видео в скайпе.

Ищем конфиг скайпа (config.xml) и подправляем видео настройки на что-то подобное
<Video>
<CaptureHeight>480</CaptureHeight>
<CaptureWidth>640</CaptureWidth>
<Fps>25</Fps>
</Video>
Файл конфига Windows XP у меня был в C:\Documents and Settings\<WINDOWS-USER>\Application Data\Skype\<SKYPE-USER>\config.xml

Ссылки:
Skype video calls with high resolution and frame rate
High Quality Video
Хачу ищо!

Wednesday, November 11, 2009

Updates 2.0

The new way of software updates is update checkers (can use both)
And another cool service for installing software via checkboxes is Ninite - you select programs you want to install from the list and it do that with no pain! But be aware here about all programs will be installed with their defaults (usually suits for most people).

Wednesday, November 4, 2009

SPL - Standard PHP Library

Finally, I starting using this built-in magic.

And here some useful links

Saturday, March 15, 2008

ideal web environment structure tips

why to compile


i think, you should do this cause this way you can enable only required stuff for all your programs (such apache web server, mysql, php, etc).


for example, i don’t need all default modules in my apache that eat more memory than application can use. same thing — php.



configuration files


vi is good. i even know how to use it. but i prefer to make symbol links to my config files (httpd.conf, my.conf, etc) to some place where it automatically backup’d and i can access via windows editors to change, copy, share them. this files only read by daemons on startup. while windows still default os in many companies…



to be contunied…

Thursday, March 6, 2008

mysql performance tips

INSERT DELAYED ...

The DELAYED option is very useful if you have clients that cannot or need not wait for the INSERT to complete. This is a common situation when you use MySQL for logging and you also periodically run SELECT and UPDATE statements that take a long time to complete. It gets an okay from the server at once, and the row is queued to be inserted when the table is not in use by any other thread. Also inserts from many clients are bundled together and written in one block.

Wednesday, March 5, 2008

mysql dba queries

this post is small refcard of useful queries to understand your database and find some problems. list will be updated constantly with new ones.

--- mysql-dba-queries.sql --------------------------------

SHOW DATABASES;

SHOW PROCESSLIST;
SHOW FULL PROCESSLIST;
SELECT VERSION();

/* http://dev.mysql.com/doc/refman/5.0/en/mysqld-server.html */
SHOW VARIABLES;
SHOW VARIABLES LIKE '%innodb%';

/* http://dev.mysql.com/doc/refman/5.0/en/show.html */
SHOW STATUS;
SHOW GLOBAL STATUS;

SHOW GRANTS;
SHOW GRANTS FOR 'viewer';

SHOW ENGINES;
SHOW CHARSET;
SHOW COLLATION;

/* Find total number of tables, rows, total data in index size for given MySQL Instance */

SELECT
COUNT(*) `tables`
, CONCAT(ROUND(SUM(`table_rows`)/1024, 2), ' K') `rows`
, CONCAT(ROUND(SUM(`data_length`)/1048576, 2), ' M') `data`
, CONCAT(ROUND(SUM(`index_length`)/1048576,2), ' M') `idx`
, CONCAT(ROUND(SUM(`data_length`+`index_length`)/1048576, 2), ' M') `total_size`
, ROUND(SUM(`index_length`)/SUM(`data_length`), 2) `idx_frac`
FROM
`information_schema`.`TABLES`;


/* Find biggest databases */

SELECT
`table_schema`
, COUNT(*) `tables`
, CONCAT(ROUND(SUM(`table_rows`)/1024, 2), ' K') `rows`
, CONCAT(ROUND(SUM(`data_length`)/1048576, 2), ' M') `data`
, CONCAT(ROUND(SUM(`index_length`)/1048576, 2), ' M') `idx`
, CONCAT(ROUND(SUM(`data_length`+`index_length`)/1048576, 2), ' M') `total_size`
, ROUND(SUM(`index_length`)/SUM(`data_length`), 2) `idx_frac`
FROM
`information_schema`.`TABLES`
GROUP BY
`table_schema`
ORDER BY
SUM(`data_length`+`index_length`) DESC
LIMIT 10;


/* Data Distribution by Storage Engines */

SELECT
`engine`
, COUNT(*) `tables`
, CONCAT(ROUND(SUM(`table_rows`)/1024, 2), ' K') `rows`
, CONCAT(ROUND(SUM(`data_length`)/1048576, 2), ' M') `data`
, CONCAT(ROUND(SUM(`index_length`)/1048576, 2), ' M') `idx`
, CONCAT(ROUND(SUM(`data_length`+`index_length`)/1048576, 2), ' M') `total_size`
, ROUND(SUM(`index_length`)/SUM(`data_length`), 2) `idx_frac`
FROM
`information_schema`.`TABLES`
GROUP BY
`engine`
ORDER BY
SUM(`data_length`+`index_length`) DESC
LIMIT 10;


--- mysql-dba-queries.sql ----------------------------EOF-

Thanks to:
— Peter Zaitsev and his MySQL Performance Blog
MySQL Documentation

Friday, February 15, 2008

How to fold your t-shirt in seconds


I was looking for this video a lot of time, and here it is ;-)

p.s. just try, it's a lot of fun ;-)



Saturday, February 2, 2008

nginx 0.5.35

http://sysoev.ru/nginx/getting_started.html
http://sysoev.ru/nginx/docs/install.html

wget http://sysoev.ru/nginx/nginx-0.5.35.tar.gz
tar xzvf nginx-0.5.35.tar.gz

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.6.tar.bz2
wget http://heanet.dl.sourceforge.net/sourceforge/pcre/pcre-7.6.tar.bz2
tar xjvf pcre-7.6.tar.bz2

wget http://www.zlib.net/zlib-1.2.3.tar.bz2
tar xjvf zlib-1.2.3.tar.bz2

wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
tar xzvf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/local/httpd/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
cd ..

cd nginx-0.5.35
make clean
./configure --with-zlib=../zlib-1.2.3 --with-pcre=../pcre-7.6
make -j4
make install



/usr/local/nginx/sbin/nginx -V
/usr/local/nginx/sbin/nginx
ps ax -o pid,ppid,user,%cpu,vsz,wchan,command|egrep '(nginx|PID)'

cat /usr/local/nginx/conf/nginx.conf

Saturday, September 15, 2007

frontend + backend = nginx + apache

hi! this weekend was a bit hot for me, cause i decided to implement Front-end and back-end architecture on my home server (my home machine is, usually, platform for many tests about performance or new technology stuff, that i after use at work).

so i wanted it. and i decided that it will be nginx as front, and my old friend apache as back.

why nginx? i saw that many internet projects i track in my day job (especially at .ru zone) uses it. one thing that i want to mention, that it not so many docs in english, but you always can ask somebody.

very useful was getting started from nginx's author. but it's not always enough - Using Nginx As Reverse-Proxy Server On High-Loaded Sites (russian version) and Заметки о ipb, apache, nginx can solve you too.

after day and a half, i win ;-) and now i has tuned nginx+apache for my 4 virtual hosts. in next article, i will post about install process (and probably after tuning).

Thursday, May 24, 2007

mysql profiling

this is my first post about profiling, so we need to understand what is profiling (performance analysis)?

In software engineering, performance analysis (a field of dynamic program analysis) is the investigation of a program's behavior using information gathered as the program runs, as opposed to static code analysis. The usual goal of performance analysis is to determine which parts of a program to optimize for speed or memory usage.


full article you can find at mysql documentation, here i'll just overview it.

profiling gives us option to understand on timeline our queries, to see resource usage for executed statements. SHOW PROFILES and SHOW PROFILE were added in MySQL 5.0.37 (that's important!).

Profiling is controlled by the profiling session variable, which has a default value of 0 (OFF). Profiling is enabled by setting profiling to 1 or ON.
mysql> SELECT @@profiling;
+-------------+
| @@profiling |
+-------------+
| 0 |
+-------------+
1 row in set (0.00 sec)

mysql> SET profiling = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TABLE T1 (id INT);
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW PROFILES;
+----------+----------+--------------------------+
| Query_ID | Duration | Query |
+----------+----------+--------------------------+
| 0 | 0.000088 | SET PROFILING = 1 |
| 1 | 0.000136 | DROP TABLE IF EXISTS t1 |
| 2 | 0.011947 | CREATE TABLE t1 (id INT) |
+----------+----------+--------------------------+
3 rows in set (0.00 sec)

mysql> SHOW PROFILE;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| checking permissions | 0.000040 |
| creating table | 0.000056 |
| After create | 0.011363 |
| query end | 0.000375 |
| freeing items | 0.000089 |
| logging slow query | 0.000019 |
| cleaning up | 0.000005 |
+----------------------+----------+
7 rows in set (0.00 sec)

mysql> SHOW PROFILE FOR QUERY 1;
+--------------------+----------+
| Status | Duration |
+--------------------+----------+
| query end | 0.000107 |
| freeing items | 0.000008 |
| logging slow query | 0.000015 |
| cleaning up | 0.000006 |
+--------------------+----------+
4 rows in set (0.00 sec)

mysql> SHOW PROFILE CPU FOR QUERY 2;
+----------------------+----------+----------+------------+
| Status | Duration | CPU_user | CPU_system |
+----------------------+----------+----------+------------+
| checking permissions | 0.000040 | 0.000038 | 0.000002 |
| creating table | 0.000056 | 0.000028 | 0.000028 |
| After create | 0.011363 | 0.000217 | 0.001571 |
| query end | 0.000375 | 0.000013 | 0.000028 |
| freeing items | 0.000089 | 0.000010 | 0.000014 |
| logging slow query | 0.000019 | 0.000009 | 0.000010 |
| cleaning up | 0.000005 | 0.000003 | 0.000002 |
+----------------------+----------+----------+------------+
7 rows in set (0.00 sec)



Here is SQL queries that you need to know:

SELECT @@profiling;

SET profiling = 1;
SET profiling = 0;

SHOW PROFILES;
SHOW PROFILE;
SHOW PROFILE FOR QUERY 1;

/* displays all information */
SHOW PROFILE ALL FOR QUERY 1;
/* displays counts for block input and output operations */
SHOW PROFILE BLOCK IO FOR QUERY 1;
/* displays counts for voluntary and involuntary context switches */
SHOW PROFILE CONTEXT SWITCHES FOR QUERY 1;
/* displays user and system CPU usage times */
SHOW PROFILE CPU FOR QUERY 1;
/* displays counts for messages sent and received */
SHOW PROFILE IPC FOR QUERY 1;
/* displays counts for major and minor page faults */
SHOW PROFILE PAGE FAULTS FOR QUERY 1;
/* displays the names of functions from the source code, together with the name and line number of the file in which the function occurs */
SHOW PROFILE SOURCE FOR QUERY 1;
/* displays swap counts */
SHOW PROFILE SWAPS FOR QUERY 1;

Wednesday, May 23, 2007

SELECT *

i found this haha img on mysql webinars.


this post not about sql error on img but about post subject.
it's ok when your table is

CREATE TABLE `your_table` (
`id` tinyint(3) unsigned NOT NULL auto_increment,
`smthing` tinyint(3) NOT NULL unsigned,
PRIMARY KEY (`id`)
) ENGINE=MyISAM

only two columns and you can use SELECT * and even you can put subj in 10 places, ok? after month, you alter table, add text field. usually, you not remember all places with this code, so in 10 places it overload resource usage with useless traffic between MySQL and application, isn't it? it mean that is always better to do SELECT `id`, `smthing` FROM... - only needed fields.
so, forget to select all!

Monday, May 21, 2007

want to learn mysql?

if you really want to understand how mysql stuff works, start read webinars instructions at MySQL AB On Demand Web Seminars.

Sunday, May 20, 2007

php performance (code)

require_once "./a.php";
require_once "a.php";

php_version() = PHP_VERSION constant
php_uname(‘s’) = PHP_OS constant
php_sapi_name() = PHP_SAPI constant

// Slow
if (preg_match("!^foo_!i", "FoO_")) { }
// Much faster
if (!strncasecmp("foo_", "FoO_", 4)) { }

// Slow
if (preg_match("![a8f9]!", "sometext")) { }
// Faster
if (strpbrk("a8f9", "sometext")) { }

// Slow
if (preg_match("!string!i", "text")) {}
// Faster
if (stripos("text", "string") !== false) {}

$text = preg_replace( "/\n/", "\\n", $text);
In this case it would be simpler and to mention faster to use a regular str_replace()
$text = str_replace( "/\n/", "\\n", $text);

$rep = array( '-' => '*', '.' => '*' );
if ( sizeof( $globArr ) > 1 ) {
$glob = "-" . strtr( $globArr[1], $rep );
} else {
$glob = strtr( $globArr[0], $rep );
}
if ( sizeof( $globArr ) > 1 ) {
$glob = "-" . strtr( $globArr[1], '-.', '**' );
} else {
$glob = strtr( $globArr[0], '-.', '**' );
}

// The Good
if (!strncmp(PHP_OS, 'WIN', 3)) {
if (!strncasecmp(PHP_OS, 'WIN', 3)) {
// The Bad
if (substr(PHP_OS, 0, 3) == 'WIN') {
if (strtolower(substr(PHP_OS, 0, 3))) == 'win') {
// And The Ugly
if (preg_match('!^WIN!', PHP_OS)) {
if (preg_match('!^WIN!i', PHP_OS)) {

if (substr($class, -15) != 'text')
/* == */
if (substr_compare($class, 'text', -15))


References can be used to simply & accelerate access
to multi-dimensional arrays.
$a['b']['c'] = array();
// slow 2 extra hash lookups per access
for($i = 0; $i < 5; $i++)
$a['b']['c'][$i] = $i;
// much faster reference based approach
$ref =& $a['b']['c'];
for($i = 0; $i < 5; $i++)
$ref[$i] = $i;

all info from slides and other sources Ilia Alshanetsky

Saturday, May 19, 2007

php performance (environment)

with this article i start post useful tips for optimize your LAMP applications. all info i grab on net from sites, blogs, etc. be sure, that you check all of this variables what they do to avoid problems.

this can be done in php.ini, inside your scripts or in .htaccess

<IfModule mod_php5.c>
php_value expose_php 0
</IfModule>


register_globals = Off
magic_quotes_gpc = Off
expose_php = Off
register_argc_argv = Off
always_populate_raw_post_data = Off
session.use_trans_sid = Off
session.auto_start = Off
session.gc_divisor = 1000 or 10000