Aller au contenu | Aller au menu | Aller à la recherche

/var/log/iksaif

lundi, août 2 2010

QEMU: adaptive Tight, ZRLE and ZYWRLE

Adaptive Tight

I recently added an infrastructure allowing to know the average update frequency for a given region on the screen. Basically, I store last 10 updates times for each 64x64 regions, and only count updates times that happened in the lasts 5 seconds.

Then, I plugged this infrastructure with tight, and adaptive tight is born. The main difference with a normal tight encoding, is that all updates are lossless by default, but if a region is updated a lot, then it'll switch to jpeg encoding.

ZRLE and ZYWRLE

ZRLE and ZYRLE are now supported by QEMU ! ZRLE is a basic run length encoding compressed with zlib, so it's lossless. ZYWRLE is a little more complex, and is well described here: http://micro-vnc.jp/research/remote_desktop_ng/ZYWRLE/publications/ . ZYWRLE is a lossy encoding.

Bandwidth Charts

Here are some results comparing ZRLE, ZYWRLE, and adaptive tight, while playing the big buck bunny trailler.

tight-zrle-zywrle.png

tight5-zywrle5.png

ZYWRLE have very good results, but the main issue is that it's a lossy encoding, and all the screen is lossy if you use zywrle. But that won't be an issue for long with the new adaptive infrastructure :).

Bellow are some screenshots of the different encodings.

Tight

Tight 5, Tight 8, Tight NoJpeg

bunny-tight5.png bunny-tight8.png bunny-tight.png

ZYWRLE

ZYWRLE 2, ZYWRLE 5, ZYWRLE 8

bunny-zywrle2.png bunny-zywrle5.png bunny-zywrle8.png

Static Images

Tight 5, ZYWRLE 5, ZYWRLE 8

kde-tight5.png kde-zywrle5.png kde-zywrle8.png

lundi, juin 14 2010

QEMU: Tight PNG and some profiling

http://github.com/kanaka/noVNC/ developer kanaka recently contacted me. noVNC is a HTML-5 VNC client, that means it's (almost) all in javascript, and only runs in a web browser. He needed an encoding that could be lossless and would allow a fast render in a web browser. We decided to try to add PNG to tight encoding.

Patchs can be found in my git tree, but nothing is standardized, nor merged in upstream QEMU,

Here was the first results with the non-threaded VNC server:

tight-png-sync.png

As we can see, PNG really slows down the guest, and the bandwidth is low only because a lot of frames are skipped and/or delayed.

So, I tried with the threaded VNC server.

tight-png-async.png

And already way better, but a lot of frames were skipped, again.

Then, kanaka tried to disable png fitlers, and here is the result:

tight-png-filters.png

Without filters, the video was a lot smoother, and it's mainly why the bandwidth is higher: more frames were sent !

During these tests, I also wanted to profile QEMU. I tried callgrind, oprofile, gprof, but none of them did what I want (callgrind is actually a great tool, but it was really too slow with QEMU). I finally tried perf (/usr/src/linux/tools/perf/), and it's really great ! No overhead, and really simple to use :

 perf record -f -g -p <pid of vnc thread>
 perf report

jeudi, juin 3 2010

QEMU: Tight JPEG compression

I finished adding Tight JPEG subencoding to QEMU (patchs are comming soon). Here are the first results:

Kubuntu boot

tight-jpeg-boot.png

Big buck bunny 33sec trailer

tight-jpeg-bigbuck.png

I used the non-threaded VNC server for these graph, and I cheated a little with the charts to make them overlap correctly,

I'll try to benchmark the thread and non-threaded server with jpeg as soon as I can get another machine to test that.

vendredi, mai 28 2010

QEMU: Threaded VNC Server results

Another subject of the GSoC was:

VNC server coroutine

Our builtin VNC server is implemented as a combination of a pure state machine to allow scalability. The VNC protocol is very complex though and this implementation is difficult to follow as a result. This project would convert to the existing server to be implemented as a cooperatively scheduled thread in the style of a coroutine. Time permitting, a pure coroutine implementation using ucontext could be implemented. Also, given sufficient progress, one could pursue running the VNC server thread in parallel with the QEMU IO thread in order to achieve better overall scalability.

Last week I decided to try to do that. My implementation use a worker thread and a queue of encoding jobs. The main thread produce encoding jobs and queue them, then the worker thread consume them as soon as possible. Resize (vnc_dpy_resize) and Copy (vnc_dpy_cpy) are still synchroneous at the moment. There is also a lock to block encoding process while updating the display to avoid screen corruptions.

The code can be found on my git tree and will be cleaned and sent soon to qemu-dev mailing list.

Here are some preliminary results. I created a simple image with Suse Studio which just boot and halt.

VNC Sync VS Async

I also made some test while playing the Big Buck Bunny Trailer, the 33sec video takes between 37 and 40 sec to play with vnc ! With the threaded vnc server, it takes between 34 and 35 seconds. But videos are something ticky, and I've got another project for them: adding some kind of mpeg subencoding to VNC :)

mardi, mai 18 2010

QEMU: some charts on tight zlib and hextile

Again, some charts to show some tight results.

I recorded the Kubuntu boot process (showing kpackagekit and a notification at the end). I used tcpdump to record the data and a small python script to convert tcpdump output into .csv files. You can find this small script here: tcpstat.py

zlib-tight-hextile.png

zlib-tight.png

You can see that tight is slightly better than zlib for this workload, but remember that it currently doesn't support gradient filter and jpeg encoding. There is just one thing to remenber: don't use hextile !

mardi, mai 11 2010

GsoC 2010 QEMU: First (dumb) tight benchmarks

For my first (and probably last) summer of code, I've been selected to work on QEMU VNC server encodings. QEMU's built-in VNC server only supports the Hextile encoding. Hextile only uses tile-based compression. Other encodings are more popular such as Tight and ZRLE that use zlib-based compression. These encodings significantly reduce the bandwidth required by VNC.

I started a basic tight implementation (mostly stolen from tightvnc/tigervnc/libvncserver, which all share the same tight.c). But the code have been rewritten to match QEMU coding style, and I'll continue to clean it and improve it.

So, QEMU tight encoding currently support full color rectangles (compressed with zlib), and solid color rectangles (a rectangle with only one color). And here is some preliminary results. I used kubuntu livecd splashscreen, keeping the vnc client open from seconds 29 to 22.

vnc.png

hextile

  • initial rectangle 16384 bytes
  • following rectangles (avg) 139 bytes
  • total 17323 bytes

zlib

  • initial rectangle 13247 bytes
  • following rectangles (avg) 130 bytes
  • total 13247 bytes

tight

  • initial rectangle 10150 bytes
  • following rectangles (avg) 90 bytes
  • total 11345 bytes

Keep in mind that this is not a real benchmark, but tight appears to be the winner for this workload, but zlib is not far and probably eats less cpu.

vendredi, janvier 22 2010

lighttpd configuration: variables and includes

A good way to factorise lighttpd configuration files is to use variables and includes. For example, let's say that you have a lot of vhost, each need specific php configuration.

First, create a _php.conf file:

var.phpconf += " -d session.save_path=" + var.statedir + "/sessions"
 
fastcgi.server = (
        ".php" =>(
                "localhost" =>(
                        "bin-path" => "/usr/bin/php-cgi " + var.phpconf,
                        "socket" => var.rundir + "/php.socket"
                        )
                )
)

Then in your main configuration file:

var.statedir = "/var/lib/lighttpd/"
 
$HTTP["host"] =~ "a.foo.com" {
 var.phpconf = " -d magic_quotes_gpc=Off "
 var.rundir = "/var/run/lighttpd/a.foo.com" 
 include "_php.conf"
}
$HTTP["host"] =~ "b.foo.com" {
 var.phpconf = " -d magic_quotes_gpc=On "
 var.rundir = "/var/run/lighttpd/b.foo.com"
 include "_php.conf"
}

Using that trick, you can do a lot more. For example, here is my configuration file for xf.iksaif.net:

# {{{ variables
var.name     =  "iksaif"
var.basedir  = "/home/iksaif/public_html"
var.logdir   = "/var/log/lighttpd/" + var.name
var.statedir = "/var/lib/lighttpd/" + var.name
var.rundir   = "/var/run/lighttpd/" + var.name
var.username = "iksaif"
var.groupname= "iksaif"
var.docroot  = var.basedir
var.port     = 8081
# }}}
 
include "_base.conf"
include "_php.conf"

iksaif.net migration to lighttp

This week I migrated iksaif.net (and zordania.com, finestown.com, etc...) from apache to lighttpd !

It used to be like described in my previous post: http://xf.iksaif.net/blog/index.php?post/2009/05/08/Securing-a-shared-Web-Server

Now, the architecture is more like that:

lighttpd-misc --- git
                    \- redmine
                    \- lighttpd-iksaif - xf.iksaif.net
                    \- apache          - svn
                                           \- trac
                                           \- finestown
                   \- lighttpd-zordania
                   \- lighttpd-zorddev
                   \- lighttpd-uffs    - blog
                                           \- git
                                           \- redmine

Is not as performant, but it's a lot more flexible. I had to keep apache for some svn repository, because there is no dav-svn module for lighttpd.

I learned a lot, so I'll post some lighttpd configuration examples that could help you one day.

jeudi, octobre 8 2009

Let's Work

Voila maintenant deux semaines que je bosse sur Virtual Browser à commonIT et tout ce passe bien, je suis sur des projs sympa.

A côté de ça, j'ai quand même trouvé un peu de temps pour bosser sur acpi4asus et en particulier pour android-x86. Android-x86, c'est un port d'android pour les "netbooks" et en particulier les EeePC.

J'ai donc backporté eeepc-laptop pour le kernel utilisé par android (un 2.6.29), et là je fais quelques tests avant d'envoyer ça upstream (cwhuang m'ayant gentillement donné un accès en écriture à git.android-x86.org). Pour l'instant, j'ai juste ajouté un patch pour régler la keymap.

Mais bon, le projet en est à ses débuts, alors il y'a vraiment de quoi faire =)

dimanche, septembre 13 2009

Le code et ses raisons : goto en C

Just un post bookmark vers le blog d'rz0 et en particulier un article sur les goto

lundi, août 10 2009

Playing with my EOS400D

Chasse

Chasse

Floc

Floc

Gallery

samedi, juin 13 2009

Poke-a-hole, let's align structs

Just readed . That's a cool tool !

You can find pahole here: http://git.kernel.org/?p=linux/kernel/git/acme/pahole.git :

git clone git://git.kernel.org/pub/scm/linux/kernel/git/acme/pahole.git
cd pahole
mkdir build
cmake ..
make

I tested it on ikmalloc

$ pahole libikmalloc.so
 
struct chunk {
        struct chunk *             main_next;            /*     0     8 */
        struct chunk *             main_prev;            /*     8     8 */
        struct chunk *             free_next;            /*    16     8 */
        struct chunk *             free_prev;            /*    24     8 */
        size_t                     size;                 /*    32     8 */
        size_t                     type;                 /*    40     8 */
        size_t                     asked_size;           /*    48     8 */
        size_t                     alignment;            /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
 
        /* size: 64, cachelines: 1, members: 8 */
};

Ok, everything is aligned =).

$ pahole fs/nandfs/nandfs.o --reorganize --show_reorg_steps -C nandfs_io_ops
struct nandfs_io_ops {
        struct nandfs_object *     obj;                  /*     0     8 */
        uint8_t *                  buf;                  /*     8     8 */
        uint32_t                   ofs;                  /*    16     4 */
 
        /* XXX 4 bytes hole, try to pack */
 
        size_t                     len;                  /*    24     8 */
        size_t                     retlen;               /*    32     8 */
        bool                       direct;               /*    40     1 */
 
        /* size: 48, cachelines: 1, members: 6 */
        /* sum members: 37, holes: 1, sum holes: 4 */
        /* padding: 7 */
        /* last cacheline: 48 bytes */
};
 
/* Moving 'direct' from after 'retlen' to after 'ofs' */
struct nandfs_io_ops {
        struct nandfs_object *     obj;                  /*     0     8 */
        uint8_t *                  buf;                  /*     8     8 */
        uint32_t                   ofs;                  /*    16     4 */
        bool                       direct;               /*    20     1 */
 
        /* XXX 3 bytes hole, try to pack */
 
        size_t                     len;                  /*    24     8 */
        size_t                     retlen;               /*    32     8 */
 
        /* size: 40, cachelines: 1, members: 6 */
        /* sum members: 37, holes: 1, sum holes: 3 */
        /* last cacheline: 40 bytes */
}
 
/* Final reorganized struct: */
struct nandfs_io_ops {
        struct nandfs_object *     obj;                  /*     0     8 */
        uint8_t *                  buf;                  /*     8     8 */
        uint32_t                   ofs;                  /*    16     4 */
        bool                       direct;               /*    20     1 */
 
        /* XXX 3 bytes hole, try to pack */
 
        size_t                     len;                  /*    24     8 */
        size_t                     retlen;               /*    32     8 */
 
        /* size: 40, cachelines: 1, members: 6 */
        /* sum members: 37, holes: 1, sum holes: 3 */
        /* last cacheline: 40 bytes */
};   /* saved 8 bytes! */

Wow, cool, 8 byte saved :P

vendredi, mai 8 2009

Securing a shared Web Server

Typical users use shared hosting for their blog, etc ... On this kind of offer, the hoster have multiple clients on the same hardware. As it is impossible to be sure that clients applications are not vulnerable, we should at least be sure that if one is vulnerable, it won't bother the others. We will show you how a bad web server configuration could lead to disaster, and how to secure such a server.

The pdf version can be found at http://xf.iksaif.net/papers/securin....

Lire la suite...

dimanche, mai 3 2009

C Hacks

Some Links:

mercredi, mars 18 2009

Coccinelle: Patchs sémantiques

Je viens de découvrir coccinelle, et c'est vraiment un outil sympa.

Imaginez que vous voulez remplacer tout les expr ? 1 : 0 par des !!expr. Et bah avec coccinelle rien de plus simple :

test.cocci

@@ expression cond; @@
 
- cond ? 1 : 0
+ !!cond
 
@@ expression cond; @@
 
- (!!cond)
+ !!cond

test.c

int main(void)
{
  int val;
 
  val = val ? 1 : 0;
  printf("%d", val);
  printf("%d", val ? 1 : 0);
  printf("%d", (val ? 1 : 0));
}

$ spatch -sp_file test.cocci test.c

--- test.c      2009-03-18 11:06:17.000000000 +0100
+++ /tmp/cocci-output-14620-bafaae-test.c       2009-03-18 11:21:17.000000000 +0100
@@ -2,8 +2,8 @@ int main(void)
 {
   int val;
 
-  val = val ? 1 : 0;
+  val = !!val;
   printf("%d", val);
-  printf("%d", val ? 1 : 0);
-  printf("%d", (val ? 1 : 0));
+  printf("%d", !!val);
+  printf("%d", !!val);
 }

Donc vachement pratique pour changer des trucs quand un search&replace ne suffit pas ! Plus d'informations:

dimanche, février 1 2009

UFFS Website

UFFS Website is now open at http://uffs.org/. You'll find news, documentation, etc ...

NandFS git tree will also probably be opened this week at git.iksaif.net. I'll post some mails on linux mailing-lists.

lundi, janvier 19 2009

En cours ...

acpi4asus

Pas mal de travail sur acpi4asus cette dernière semaine. En particulier le support des touches spéciales comme si elles venaient d'un clavier normal (enfin !). En plus projet dispose enfin d'un arbre git, et le site web à été refait.

acpi4asus.sf.net git.iksaif.net

nandfs

Le code devrait être publié sous GPLv3 bientôt, le temps de vérifier que ça marche. Mais c'est en bonne voie.

uffs

Ici encore on avance. Le site devrais bientôt être finit (merci jl) ce qui permettra de donner une meilleure visibilité au projet. Pour l'instant le gros du travail à surtout été fait sur ebm. Mais maintenant qu'on à quelque chose qui marche on va pouvoir passer aux trucs chiants.

lundi, janvier 12 2009

ikmalloc quelques améliorations

J'ai fait quelques modifications à mon malloc, qui s'appelle d'ailleurs maintenant ikmalloc. Les sources sont disponibles sur git.iksaif.net

Pour les récuperer: git clone git://git.iksaif.net//ikmalloc.git

Améliorations:

  • Support de mmap
  • Redéfinition de memalign, valloc, posix_memalign
  • Les tailles allouées ne sont plus uniquement des puissances de sizeof (struct chunk)

Les prochaines versions apporterons les modifications suivantes:

  • Utilisation de mmap ou brk suivant la taille à allouer
  • Support de munmap et mremap
  • Amélioration de la compatibilité avec ptmalloc
  • Malloc thread-safe (il y'a actuellement des problèmes avec les programmes multi-threadés).

samedi, décembre 27 2008

Sphinx: Indexation basique

Base de donnée à indexer

Au début, nous avons donc notre base de donnée, par exemple:

CREATE TABLE items (                                                                                                    
    item_id integer NOT NULL,                                                                                           
    item_title character varying(255) NOT NULL,                                                                         
    item_description text NOT NULL,                                                                                     
    item_date timestamp without time zone NOT NULL,                                                                     
    item_link character varying(255) NOT NULL,                                                                          
    cat_id integer NOT NULL,                                                                                            
);

Et nous voulons faire des recherches dans le titre (item_link), dans le contenu (item_description) ou dans l'url (item_link). En plus, il faudrais pouvoir trier par date (cat_date) ou par catégorie (cat_id)

La première étape est de créer le fichier de configuration de sphinx

Fichier de conf de base

Voila de quoi créer un sphinx.conf pour notre base de donnée

# nom de l'index : "main"
source main              
{                        
        type            = pgsql
 
        sql_host        = localhost
        sql_user        = utilisateur
        sql_pass        = motdepasse 
# nom de la base de donnée           
        sql_db          = database   
 
 
         sql_query      = \
               SELECT item_id, cat_id, item_title, item_description, item_date, ROUND(EXTRACT( EPOCH FROM ABSTIME(item_date) ))::int4 AS item_ts \                                                                                              
               FROM items                                                                                               
 
       sql_attr_uint                   = cat_id
       sql_attr_timestamp              = item_ts 
}                                                
 
index main
{         
        source                  = main
        path                    = /home/foo/var/lib/sphinx/main
        docinfo                 = extern                       
        morphology              = none                         
        # Cette conf de base marche bien en général
        # Pour l'adapter à vos besoins voir l'exemple de fichier de configuration complet
        enable_star             = 0
        min_word_len            = 2
        min_prefix_len          = 0
        min_infix_len           = 3
        charset_type            = utf-8
        html_strip              = 1
}

Pour indexer la base, il faut taper la commande suivante: indexer -c sphinx.conf main (rajouter --rotate si searchdest en train d'utiliser l'index)

Suivant la taille des données à indexer cela peut prendre un peu de temps. Par exemple :

Sphinx 0.9.8.1-release (r1533)
Copyright (c) 2001-2008, Andrew Aksyonoff
 
using config file '/home/foo/var/sphinx.conf'...
indexing index 'main'...
collected 20786 docs, 6.8 MB
sorted 17.4 Mhits, 100.0% done
total 20786 docs, 6829246 bytes
total 9.729 sec, 701969.94 bytes/sec, 2136.57 docs/sec
rotating indices: succesfully sent SIGHUP to searchd (pid=11367).

Sphinx: Faire un moteur de recherche en PHP/(MySQL|PostgreSQL)

Cet article s'adresse à ceux qui auraient une (grosse) base de donnée, et qui aimeraient disposer d'un moteur de recherche rapide et performant. Une première solution est d'utiliser les index full text et de chercher directement dans la base en faisant des requêtes SQL. Cette solutions présente des avantages certains, mais aussi les désavantages suivants:

  • La taille de l'index peut rapidement devenir très importante
  • L'index peut ralentir les insertions (les insertions lockent la table sous MySQL !)
  • Les fonctions mises à dispositions par MySQL (ou PostgreSQL) en matìere de recherche full-text sont assez limitées.
  • Il faut refaire soit même le moteur de recherche qui va créer les requètes SQL

Sphinx

Sphinx

A Propos

Sphinx est un moteur de recherche full-text, distribué sous GPL v2. (Une licence commerciale est disponible)

En gros, c'est un moteur de recherche à part entière, crée pour fournir des fonctions de recherches rapides et pertinentes pour d'autres applications. Sphinx a été fait en particulier pour s'intégrer facilement avec des base de données SQL et des languages de scripts (typiquement, le couple PHP/MySQL). Pour l'instant les sources de données peuvent être des bases de donnée MySQL ou PostgreSQL, mais aussi des flux XML.

Sphinx signifie SQL Phrase Inde_x__

Programmes

  • indexer: un utilitiaire pour créer les index
  • search: a simple utilitaire (de test) pour rechercher en ligne de commandes
  • searchd: un service pour faire des recherches en utilisant sphinxapi
  • sphinxapi: un ensemple d'acpi pour les languages les plus utilisés PHP, Python, Java, Perl et Ruby.

Avantages

  • Indexation assez rapide (sur mes machines, à peu près 2000 docs/sec)
  • Support de plusieurs langues, y compris CJK
  • Il est facile de mettre le moteur de recherche sur une (voir plusieurs) machine différente et ainsi mieux répartir la charge
  • API PHP, Python, Java, Perl, et Ruby

Articles

Les articles en italique ne sont pas encore publiés

  • Configuration de base
  • Indexation
    • Indexation basique
    • Utilisation des range queries
    • Diminuer la charge du processus d'indexation: utilisation d'un index "delta"
    • Gestion de plusieurs langues
  • Tests avec l'utilitaire search
  • Utilisation de l'API PHP
  • Utilisation de l'API Python

- page 1 de 2