<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2767637963813047764</id><updated>2011-12-13T19:16:00.931+01:00</updated><category term='cl-cluster'/><category term='ffi'/><category term='bloatware'/><category term='cl-v4l2'/><category term='cl-gtk2'/><category term='sbcl'/><category term='restas'/><category term='cl-zmq'/><category term='qpidc'/><category term='lisp'/><category term='hugepages'/><category term='memory'/><category term='wl'/><title type='text'>Few words about Lisp</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>22</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-4978945739252607736</id><published>2010-12-05T17:52:00.000+01:00</published><updated>2010-12-05T17:52:37.185+01:00</updated><title type='text'>Status update</title><content type='html'>Not much news to the moment. Except I joined Lisp startup (NovaSparks) and moved to Boston, MA in the middle of November.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-4978945739252607736?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/4978945739252607736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=4978945739252607736' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/4978945739252607736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/4978945739252607736'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2010/12/status-update.html' title='Status update'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-535953687532885157</id><published>2010-06-18T17:20:00.002+02:00</published><updated>2010-06-19T09:50:38.448+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='ffi'/><category scheme='http://www.blogger.com/atom/ns#' term='cl-zmq'/><title type='text'>Why zero-copy is missing in CL-ZMQ</title><content type='html'>ZeroMQ can utilize zero-copy technique, which may save a lot of cpu ticks when using large messages. Unfortunately, it's not possible to get this feature to work with supported Common Lisp implementations due to a couple of reasons:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;ZeroMQ uses threads for asynchronous I/O operations on messages. When it finishes all the work with message's data, it calls back Lisp to let it know that data can be safely ripped out.&lt;/li&gt;&lt;/ul&gt;Unfortunately, not all Lisps can distinguish and handle callback from non-lisp thread. For example, Clozure CL feels good here, but SBCL crashes and LispWorks just hangs.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Garbage collector may move lisp objects, which are currently used in I/O threads. This leads to image corruption or segmentation fault.&lt;/li&gt;&lt;/ul&gt;Widely used with-pinned-object technique is not working here, because ZeroMQ operates asynchronously and pinned body can't protect data from GC when it needs to. It's possible to turn off garbage collecting completely or design system in such way, that it won't do gc'ing when it shouldn't. But that's a hard way.&lt;br /&gt;&lt;br /&gt;Other possibility is to allocate objects in static area, where garbage collector doesn't move live objects. Some Lisps support this feature, for example AllegroCL, LispWorks and GCL.&lt;br /&gt;&lt;br /&gt;If both features (callback from non-lisp thread, objects in static area) are supported by certain Lisp implementation, it's possible then to use zero-copy in CL-ZMQ. Unfortunately, all four Lisps that I use for development and testing (SBCL, Clozure, CLISP and LispWorks) miss this combination.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-535953687532885157?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/535953687532885157/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=535953687532885157' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/535953687532885157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/535953687532885157'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2010/06/why-zero-copy-is-missing-in-cl-zmq.html' title='Why zero-copy is missing in CL-ZMQ'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-8669116181826686032</id><published>2010-06-13T11:06:00.000+02:00</published><updated>2010-06-13T11:06:26.079+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='cl-zmq'/><title type='text'>CL-ZMQ and LispWorks 6</title><content type='html'>Since yesterday I'm happy user of commercial version of LW.&lt;br /&gt;&lt;br /&gt;LW complains about unshadowed symbol `identity'. Yeah, that's strange it wasn't yet catched by 3 other lisps I tested with (sbcl, clisp, ccl). Other minor problem was with `trivial-garbage' library: it uses `hcl:mark-and-sweep', but this function exists only on 32-bit LWs. 64-bit uses `system:marking-gc'. Also `system::hash-table-weak-kind' has a bit different name: `system::hash-table-%weak-kind'.&lt;br /&gt;&lt;br /&gt;Otherwise everything works good. LW is officially supported by CL-ZMQ now :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-8669116181826686032?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/8669116181826686032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=8669116181826686032' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/8669116181826686032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/8669116181826686032'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2010/06/cl-zmq-and-lispworks-6.html' title='CL-ZMQ and LispWorks 6'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-1457986526426776452</id><published>2010-03-12T16:13:00.001+01:00</published><updated>2010-03-12T18:27:06.360+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sbcl'/><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><title type='text'>Hugepages patch</title><content type='html'>Got something working:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://paste.lisp.org/display/96287"&gt;http://paste.lisp.org/display/96287&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;How to run:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="paste-area" style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span class="paste"&gt;&lt;span class="diff-normal"&gt;# echo 200 &amp;gt; /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages&lt;/span&gt;&lt;span class="diff-normal"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="diff-normal"&gt;# mkdir /dev/huge&lt;/span&gt;&lt;span class="diff-normal"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="diff-normal"&gt;# mount -t hugetlbfs none /dev/huge -o size=800M,mode=777&lt;/span&gt;&lt;span class="diff-normal"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="diff-normal"&gt;$ sbcl --hugetlbfs-path /dev/huge --huge-pages-nr 200&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="paste-area" style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span class="paste"&gt;&lt;span class="diff-normal"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;Here 800 megabytes of memory is prepared for use as huge pages. SBCL has two new command line switches now. If there's something wrong with hugetlbfs, SBCL will fallback to "usual" memory.&lt;br /&gt;&lt;br /&gt;To extend feature for other OSes, where POSIX API for hugepages is available, you need to add only few bits:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;diff --git a/src/runtime/linux-os.c b/src/runtime/linux-os.c&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;index 9b2e3cf..386fc25 100644&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;--- a/src/runtime/linux-os.c&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+++ b/src/runtime/linux-os.c&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@@ -56,6 +56,8 @@&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;#include "cheneygc-internal.h"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;#endif&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+#include "hugepages.h"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;#ifdef LISP_FEATURE_X86&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;/* Prototype for personality(2). Done inline here since the header file&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; * for this isn't available on old versions of glibc. */&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@@ -313,7 +315,10 @@ os_validate(os_vm_address_t addr, os_vm_size_t len)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addr=under_2gb_free_pointer;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;#endif&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp; actual = mmap(addr, len, OS_VM_PROT_ALL, flags, -1, 0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp; actual = huge_page_validate(addr, len);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!actual)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; actual = mmap(addr, len, OS_VM_PROT_ALL, flags, -1, 0);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (actual == MAP_FAILED) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perror("mmap");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* caller should check this */&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@@ -337,6 +342,7 @@ os_validate(os_vm_address_t addr, os_vm_size_t len)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;void&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;os_invalidate(os_vm_address_t addr, os_vm_size_t len)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp; huge_page_invalidate(addr, len);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (munmap(addr,len) == -1) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perror("munmap");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In other words, only new header and small modification of &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;os_validate&lt;/span&gt; and &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;os_invalidate&lt;/span&gt; are required.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;UPD:&lt;/b&gt; Garbage collector works much slower with the patch and needs further investigation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-1457986526426776452?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/1457986526426776452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=1457986526426776452' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/1457986526426776452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/1457986526426776452'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2010/03/hugepages-patch.html' title='Hugepages patch'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-7175541319029070015</id><published>2010-03-12T08:59:00.000+01:00</published><updated>2010-03-12T08:59:39.766+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sbcl'/><title type='text'>SBCL and huge pages</title><content type='html'>Yesterday was a lucky day: I compiled SBCL with sb!vm:*backend-page-bytes* = 2097152. There were several problems preventing doing this, but, hopefully, all of them are solved. At least, I'm able to run new core and do everything, what comes in mind, for example, load ZeroMQ2 bindings.&lt;br /&gt;&lt;br /&gt;Next step is to teach memory allocator to mmap() pages from hugetlbfs. That will give SBCL real 2mb pages, not 2mb regions composed of 4kb chunks.&lt;br /&gt;&lt;br /&gt;Stay tuned!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-7175541319029070015?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/7175541319029070015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=7175541319029070015' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/7175541319029070015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/7175541319029070015'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2010/03/sbcl-and-huge-pages.html' title='SBCL and huge pages'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-4328390108645833461</id><published>2010-02-17T17:17:00.005+01:00</published><updated>2010-02-17T17:34:29.995+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='hugepages'/><category scheme='http://www.blogger.com/atom/ns#' term='memory'/><title type='text'>Hugepages save the kittens</title><content type='html'>Imagine, we need to read and eval code from some untrusted source. This code may change lisp environment in uncertain way as expected behaviour, but it may also contain error, which stops execution in the middle. This is not what we want: environment should be changed completely or rolled back to previous state.&lt;br /&gt;&lt;br /&gt;Naive approach to solve the problem is to fork() lisp image, execute untrusted code in the child (child will be the full clone of parent), return zero in the case of succes and non-zero value otherwise. Parent may check if it's safe to executes code in its environment this way . This is only few lines of code:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(defun rep (expr)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (eval (read-from-string expr)))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(defun safe-eval (expr)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (let ((pid (sb-posix:fork)))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (cond&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((plusp pid)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (multiple-value-bind (pid status)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (sb-posix:waitpid pid 0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (declare (ignore pid))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (when (zerop status)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (rep expr))))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((zerop pid)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (handler-case&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (rep expr)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (error ()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (sb-ext:quit :unix-status 1)))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (sb-ext:quit :unix-status 0))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (t&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (error "fork failed~%")))))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It doesn't even matter if child's image completely crashes due to uber-invalid code or compiler's bugs, parent will survive and understand that the code is bad. Next question is: how expensive fork() operation is?&lt;br /&gt;&lt;br /&gt;Linux kernel (I'm Linux-only guy) is enough smart not to copy all the process data one-to-one: it uses copy-on-write (COW) technique to separate memory pages of new process from respective pages of old process only at the moment of page changes. So, basically, kernel duplicates task structures for the new process, and that's all.&lt;br /&gt;&lt;br /&gt;Unfortunately, modern lisps (like SBCL) creates huge image up to tens megabytes, and it may grow up to gigabytes. In-kernel VMA chains, which describes how much memory the process has and how this memory is organized in address space of process, may grow significantly. The cost of fork operation grows respectively (not to mention, overall system slowdowns as well). One of accessible and acceptable solution is to use huge pages in those programs, which manipulate with a large memory portions.&lt;br /&gt;&lt;br /&gt;Normal page size is equal to 4 kilobytes on most of systems. However, modern hardware allows to set page size for part of memory to larger size. For example, x86-64 supports huge pages of size 2 megabytes.&lt;br /&gt;&lt;br /&gt;I wrote a small test, which allocates portions of memory with normal and huge page size, and does fork(). Let see the results:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_Uj9OQMNBuMg/S3wVAzaYhBI/AAAAAAAAAY0/x_lQkiHCFlY/s1600-h/mem.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="480" src="http://2.bp.blogspot.com/_Uj9OQMNBuMg/S3wVAzaYhBI/AAAAAAAAAY0/x_lQkiHCFlY/s640/mem.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Gosh!... Fork of a process with normal-sized pages is soooo slow! And huge pages definitely rocks!&lt;br /&gt;&lt;br /&gt;I wish SBCL built-in memory manager to work with hugepages...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-4328390108645833461?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/4328390108645833461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=4328390108645833461' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/4328390108645833461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/4328390108645833461'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2010/02/hugepages-save-kittens.html' title='Hugepages save the kittens'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Uj9OQMNBuMg/S3wVAzaYhBI/AAAAAAAAAY0/x_lQkiHCFlY/s72-c/mem.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-2066274219965602004</id><published>2010-01-24T18:07:00.001+01:00</published><updated>2010-01-24T19:55:51.191+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wl'/><title type='text'>New Gmail's COMPRESS=DEFLATE feature</title><content type='html'>Two days ago I noticed that Google implemented &lt;a href="http://www.faqs.org/rfcs/rfc4978.html"&gt;RFC4978&lt;/a&gt; for their mail service. In short, Gmail is able now to compress all traffic with &lt;a href="http://www.faqs.org/rfcs/rfc1951.html"&gt;deflate&lt;/a&gt; method. Wanderlust shall support this feature!&lt;br /&gt;&lt;br /&gt;Unfortunately, my attempts to find ready-to-use deflate/inflate code in Emacs Lisp have been failed. Even it is impossible to access zlib functions from Emacs Lisp (Emacs links with -lz) without hacking Emacs first. So I decided to write a wrapper, which will stay in between of Emacs and gnutls-cli, which I use for TLS. Gnutls-cli is fully text-oriented client, so it has problem with handling binary data from standard input. I did a small patch to fix it:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;--- src/cli.c.orig&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2009-06-02 20:59:32.000000000 +0200&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+++ src/cli.c&amp;nbsp;&amp;nbsp; 2010-01-24 17:48:05.636222100 +0100&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@@ -749,7 +749,8 @@ after_handshake:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (FD_ISSET (fileno (stdin), &amp;amp;rset))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fgets (buffer, MAX_BUF, stdin) == NULL)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int bytes;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((bytes = read (fileno(stdin), buffer, MAX_BUF)) &amp;lt; 0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (hd.secure == 0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;@@ -778,11 +779,13 @@ after_handshake:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (crlf != 0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; char *b = strchr (buffer, '\n');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (b != NULL)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (b != NULL) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy (b, "\r\n");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bytes++;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret = socket_send (&amp;amp;hd, buffer, strlen (buffer));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret = socket_send (&amp;amp;hd, buffer, bytes);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ret &amp;gt; 0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The wrapper is mostly functional now, but I need to beatify it first before releasing to public.&lt;br /&gt;&lt;br /&gt;As for results... Deflate is known for its ability to recognize similar patterns and replace them with only one pattern definition and references for the rest. I tried to do &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;uid search uid 1:* undeleted&lt;/span&gt; in my Inbox folder. At first, Gmail sent me 12401 byte of deflated text. For the same query, sent for 2nd time, it returned only 581 byte, which consisted mostly of the references to already received patterns. Usual uncompressed text is of 25993 bytes. That's pretty amazing!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-2066274219965602004?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/2066274219965602004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=2066274219965602004' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/2066274219965602004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/2066274219965602004'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2010/01/new-gmails-compressdeflate-feature.html' title='New Gmail&apos;s COMPRESS=DEFLATE feature'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-6394023762129076494</id><published>2010-01-24T14:58:00.000+01:00</published><updated>2010-01-24T14:58:26.628+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bloatware'/><title type='text'>Thunderbird 3</title><content type='html'>Do you know why modern desktop software is so huge? Because most of modern programmers simply do not care about size. For example, Thunderbird 3 sources goes with 2 zlibs: one is at &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;comm-1.9.1/mozilla/modules/zlib/src&lt;/span&gt; and another one is at &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;comm-1.9.1/mozilla/security/nss/cmd/zlib&lt;/span&gt;. Brilliant.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-6394023762129076494?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/6394023762129076494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=6394023762129076494' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/6394023762129076494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/6394023762129076494'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2010/01/thunderbird-3.html' title='Thunderbird 3'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-358944999699029019</id><published>2010-01-15T19:21:00.001+01:00</published><updated>2010-01-15T20:15:09.691+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='wl'/><title type='text'>Wanderlust</title><content type='html'>Almost all stuff from &lt;a href="http://repo.or.cz/w/more-wl.git"&gt;more-wl&lt;/a&gt; was committed in upstream today. Rest patches, which left in more-wl, weren't really needed, because I've reimplemented the wheel due to insufficient documentation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-358944999699029019?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/358944999699029019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=358944999699029019' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/358944999699029019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/358944999699029019'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2010/01/wanderlust.html' title='Wanderlust'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-3634978672232688053</id><published>2009-12-21T22:22:00.000+01:00</published><updated>2009-12-21T22:22:23.152+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='qpidc'/><title type='text'>Qpidc trampoline</title><content type='html'>I know what to do during long three weeks of my days off.  Earlier this day I &lt;a href="http://repo.or.cz/w/qpidc-trampoline.git"&gt;started&lt;/a&gt; to type C wrapper for libqpidclient -- the client part of AMQP from Qpidc project. To type, exactly. There's so much copy-and-paste boring work, no room for brains. I suspect, it will take quite a lot of time to implement every class from Qpidc horde...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;At the end I want to have something ready to bind in Lisp. May be, other languages also can benefit from this work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-3634978672232688053?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/3634978672232688053/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=3634978672232688053' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/3634978672232688053'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/3634978672232688053'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/12/qpidc-trampoline.html' title='Qpidc trampoline'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-2443048608056624349</id><published>2009-12-10T18:08:00.001+01:00</published><updated>2009-12-14T13:06:52.152+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cl-zmq'/><title type='text'>Throughput test using small messages</title><content type='html'>Previously I found Lisp bindings performance in throughput test is not good enough when message size is small. This performance drawback can be explained be overhead, introduced by high-level wrappers for libzmq functions. At the very top of bindings there are more o less lispish functions, which works with C data structures wrapped in CLOS instances, checks low-level functions for return values and raises error conditions, when needed. Also, CFFI adds one more wrapping level itself. So, bindings contain up to 4 levels of dummy calls from high- to low-level.&lt;br /&gt;&lt;br /&gt;Obviously, under certain conditions throughput peformance is literally equal to how many times code can execute zmq_send(). If you need to break through tons of wrappings, throughput will sufffer a lot due to wrappers.&lt;br /&gt;&lt;br /&gt;Fortunately, such behaviour (many calls to zmq_send() in blocking mode, small message size) is not typical. But even in this situation it is possible to use low level libzmq functions and manage all the stuff by hands.&lt;br /&gt;&lt;br /&gt;I did another test for message sizes of 1, 2, 4, 8, 16, 32 and 64 bytes. Messages with sizes below 30 are Very Small Messages (VSM), and zeromq library embedds VSM space directly into message header. Result of testing wasn't stable, so all tests were run 10 times.&lt;br /&gt;&lt;br /&gt;Here's difference between "normal" and "optimized" versions of bindings and test sources. "Optimized" means there's &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(declaim (optimize speed (safety 1)))&lt;/span&gt; in cl-zmq sources, also both local-thr.lisp and remote-thr.lisp use CFFIized functions directly.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;ERRATA:&lt;/b&gt; There's bug in pictures 1 and 3, second "Optimized Lisp ranges" should be "Normal Lisp ranges". Unfortunately, I lost original data and can't regenerate pictures easily.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_Uj9OQMNBuMg/SyEoWu_hQ3I/AAAAAAAAANs/Y1wovVJ5PXE/s1600-h/thr2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_Uj9OQMNBuMg/SyEoWu_hQ3I/AAAAAAAAANs/Y1wovVJ5PXE/s640/thr2.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;If you use VSM messages (30 bytes or less) in your software, which requires maximum throughput, it makes sense to write your software in low-level C-style... Perhaps, it's better to redesign software to use large messages, but it's up to you ;)&lt;br /&gt;&lt;br /&gt;To compare C and optimized version of Lisp:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_Uj9OQMNBuMg/SyEo3KAfcWI/AAAAAAAAAN0/DnVgevLk22w/s1600-h/thr.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_Uj9OQMNBuMg/SyEo3KAfcWI/AAAAAAAAAN0/DnVgevLk22w/s640/thr.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;As you see, throughput is almost equal with message size of 16+ bytes.&lt;br /&gt;&lt;br /&gt;Finally, all the mess: "normal", "optimized" Lisp and C in one place.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_Uj9OQMNBuMg/SyEpQ9F5l6I/AAAAAAAAAN8/9C-Bfzv9zgU/s1600-h/thr3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_Uj9OQMNBuMg/SyEpQ9F5l6I/AAAAAAAAAN8/9C-Bfzv9zgU/s640/thr3.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-2443048608056624349?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/2443048608056624349/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=2443048608056624349' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/2443048608056624349'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/2443048608056624349'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/12/throughput-test-using-small-messages.html' title='Throughput test using small messages'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Uj9OQMNBuMg/SyEoWu_hQ3I/AAAAAAAAANs/Y1wovVJ5PXE/s72-c/thr2.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-7450323191613932143</id><published>2009-12-04T17:03:00.001+01:00</published><updated>2009-12-04T17:04:07.201+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cl-zmq'/><title type='text'>Performance.... Performance...</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Just did some brief latency and throughput testing.&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;I've used two 64-bit machines, connected by 1Gb switchless network. Machines are:&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;1. Core2Duo T9600 2.8GHz running Fedora 12 &lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;2. Core2Duo T9400 2.53GHz running RHEL-5.4 with realtime kernel.&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Here's latencies compared to C:&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://2.bp.blogspot.com/_Uj9OQMNBuMg/SxksI6UjA_I/AAAAAAAAAMk/QmaLMGoiocI/s1600-h/lat.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_Uj9OQMNBuMg/SxksI6UjA_I/AAAAAAAAAMk/QmaLMGoiocI/s640/lat.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Latencies are fine. The throughput in term of messages per second:&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://1.bp.blogspot.com/_Uj9OQMNBuMg/SxksQy--zJI/AAAAAAAAAMs/wCLCc7biRLA/s1600-h/thr.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_Uj9OQMNBuMg/SxksQy--zJI/AAAAAAAAAMs/wCLCc7biRLA/s640/thr.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Not bad also, except small messages. Throughput in megabits per second:&lt;br /&gt;&lt;/div&gt;&lt;a href="http://3.bp.blogspot.com/_Uj9OQMNBuMg/SxksTDOP0RI/AAAAAAAAAM0/vbveZWCAlxc/s1600-h/thr-band.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_Uj9OQMNBuMg/SxksTDOP0RI/AAAAAAAAAM0/vbveZWCAlxc/s640/thr-band.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Small messages is problem. Network latency and context switches cost can't compensate overhead added by bindings. Fortunately, I haven't even thought about optimization yet, so there's large field to improve :)&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-7450323191613932143?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/7450323191613932143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=7450323191613932143' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/7450323191613932143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/7450323191613932143'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/12/performance-performance.html' title='Performance.... Performance...'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Uj9OQMNBuMg/SxksI6UjA_I/AAAAAAAAAMk/QmaLMGoiocI/s72-c/lat.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-9170078692842631722</id><published>2009-12-03T11:10:00.000+01:00</published><updated>2009-12-03T11:10:43.086+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cl-zmq'/><title type='text'>ØMQ/2.0 can boost your Lisp application. Lisp can boost your financial application.</title><content type='html'>I'm pleased to &lt;a href="http://lists.zeromq.org/pipermail/zeromq-dev/2009-December/001467.html"&gt;announce&lt;/a&gt; inclusion of CL-ZMQ into &lt;span style="font-size: small;"&gt;&lt;span&gt;ØMQ/2.0 mainline tree.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-9170078692842631722?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/9170078692842631722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=9170078692842631722' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/9170078692842631722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/9170078692842631722'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/12/mq20-can-boost-your-lisp-application.html' title='ØMQ/2.0 can boost your Lisp application. Lisp can boost your financial application.'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-7588850923675852700</id><published>2009-12-02T14:34:00.000+01:00</published><updated>2009-12-02T14:34:46.910+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cl-zmq'/><title type='text'>Common Lisp is fast for real business.</title><content type='html'>I'm reading &lt;span style="font-size: small;"&gt;&lt;span&gt;ØMQ &lt;a href="http://www.zeromq.org/area:whitepapers"&gt;Whitepapers&lt;/a&gt;, especially bits related to performance measurements of Java and Python bindings. Java is something 20% slower comparing to C, and Python works almost 2.5x times slower (very expected).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;SBCL kicks asses, I got the same latencies over 1Gb network, like in C. Thanks to CFFI library and decent compiler in SBCL.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;Currently I have conversation with Martin Sustrik (FastMQ CEO and architector of &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;Ø&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;MQ) about merging Common Lisp support into main tree.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-7588850923675852700?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/7588850923675852700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=7588850923675852700' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/7588850923675852700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/7588850923675852700'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/12/common-lisp-is-fast-for-real-business.html' title='Common Lisp is fast for real business.'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-1124467874627453243</id><published>2009-11-22T14:28:00.000+01:00</published><updated>2009-11-22T14:28:50.847+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='cl-zmq'/><title type='text'>CL-ZMQ is almost ready to go</title><content type='html'>Just commited large patch to CL-ZMQ. Main change is elimination of MOP wrapper, which I took from my other project - CL-V4L2. Video4Linux2 API has quite a lot of complex structures, so automatic bindings generation was a must there. But ZeroMQ2 API has only 2 simple structures, so horrible macro `define-wrapper' was definitely an overkill. &lt;br /&gt;&lt;br /&gt;As a plus, sources are much simpler now, they started to work with CLISP. Also CLISP showed me a couple of bugs related to memory management and message object initialization. All tests in perf/ work both with SBCL and CLISP and their combination. I'm about to tag sources as version 0.1 in a couple of days.&lt;br /&gt;&lt;br /&gt;Btw, if you're going to try CL-ZMQ, you need to build latest zeromq2 without eventfd support (add --disable-eventfd to configure options). Eventfd feature is still buggy in ZeroMQ2.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-1124467874627453243?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/1124467874627453243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=1124467874627453243' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/1124467874627453243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/1124467874627453243'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/11/cl-zmq-is-almost-ready-to-go.html' title='CL-ZMQ is almost ready to go'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-7479009679349376853</id><published>2009-10-20T20:22:00.000+02:00</published><updated>2009-10-20T20:22:37.879+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='restas'/><title type='text'>RESTAS - new web framework from cold Russia</title><content type='html'>Well-known russian lisper &lt;a href="http://archimag-dev.blogspot.com/"&gt;Archimag&lt;/a&gt; aka Andrey Moskovitin just &lt;a href="http://archimag-dev.blogspot.com/2009/10/restas-web-common-lisp.html"&gt;announced&lt;/a&gt; his home brewed web framework, based on several interesting ideas. His blog is in Russian, but it is more or less google-translatable.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-7479009679349376853?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/7479009679349376853/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=7479009679349376853' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/7479009679349376853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/7479009679349376853'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/10/restas-new-web-framework-from-cold.html' title='RESTAS - new web framework from cold Russia'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-8401028090338377935</id><published>2009-09-26T02:05:00.000+02:00</published><updated>2009-09-26T02:05:40.849+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='cl-cluster'/><title type='text'>Distributed computing in Lisp. Again :)</title><content type='html'>Half year ago I've started a library for distributed computing. Yes, I know, there are many of them, but I wanted to write one more, just to have experience in that area.&lt;br /&gt;&lt;br /&gt;Library (called cl-cluster) uses SSH to get a remote shell, run some lisp and execute given code directly in it. SSH was chosen, because I didn't want to write some kind of tcp server/client. Also I didn't want to write fault tolerant remote objects broker with migration between hosts, etc, so transport level may be really simple.&lt;br /&gt;&lt;br /&gt;Besides not very interesting stuff like making connection, sending and receiving data, there were a few moments:&lt;br /&gt;&lt;br /&gt;One problem was how to prevent remote lisp from falling to debugger. There are 2 possibilities to trap: parse errors and execution errors. Later problem is relatively simple, I just need to wrap main request's body in (handler-case ...). Parse errors are different, they trigger before handler-case will be able to catch them. The best solution I found was to pass body as string and parsing it on remote side using read-from-string and eval it. Thus, making toplevel input form errors free and fully controlled by the library. Of course, handler-case and read-from-string ate some speed, but it's not important for my proof of concept :)&lt;br /&gt;&lt;br /&gt;Another problem is: not all lisp objects can be read back from their printed representation. Especially, I faced to problem of parsing remote exceptions on local side. I've ended up returning exceptions in the form of list with symbol "error" as first argument and error description as second. This is very unlikely that regular user-provided code will produce such result. On local side I rise exception with received description, noticing the node where this exception has really happened. In practice, it looks good.&lt;br /&gt;&lt;br /&gt;One more trap was spotted with passing packages names to remote: format specifier ~a just cuts package designators, producing (oos 'load-op :asdf) instead of (asdf:oos 'asdf:load-op :asdf). This is not so tricky for experienced lisper, but I've spent some time understanding what's going on and then switched format to ~s.&lt;br /&gt;&lt;br /&gt;At the end I wanted to have a let-like macro for parallel execution of bindings on remote machines, gathering results, and passing preprocessed bindings them to another machine. For example:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;; calculate some stuff on remote lisps and aggregate answers on another remote&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(rplet node3&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((a (with-remote node1&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (+ 1 2)))&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (b (with-remote node2&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (sqrt 7d0))))&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (* a b))&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;A and B will be computed in parallel on nodes node1 and node2 respectively, after that node3 will get request:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(let ((a someval)&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (b anotherval))&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (* a b))&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;For parallel tasks dispatching I've used the cl-pmap library, written by my friend Alexey Voznyuk a.k.a Swizard. It's not the best solution, because it uses thread per task, whereas I was needed simple i/o muxer to write data to several output streams and read results back from input. It'd be a good idea to use iolib instead.&lt;br /&gt;&lt;br /&gt;Recently I've tried to make the library portable across different popular Lisps, but, seems, there's no existing wrapper for asynchronous shell execution, allowing to communicate with it via streams. The most closest library, trivial-shell, hasn't this possibility. Quick overview of trivial-shell sources told me, there will be problems to do such thing on some implementation due to bugs or whatever else.&lt;br /&gt;&lt;br /&gt;The last idea is to get rid of SSH and use Zero MQ for transport :) Real life application will help to do good zmq bindings, and also zmq's subscriber model can help to cl-cluster with common changes propagation across all slave nodes. Not telling, zmq can use advanced networking techniques and save some microseconds ;)&lt;br /&gt;&lt;br /&gt;As usually, sources are hosted at repo.or.cz: &lt;a href="http://repo.or.cz/w/cl-cluster.git"&gt;http://repo.or.cz/w/cl-cluster.git&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-8401028090338377935?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/8401028090338377935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=8401028090338377935' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/8401028090338377935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/8401028090338377935'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/09/distributed-computing-in-lisp-again.html' title='Distributed computing in Lisp. Again :)'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-1448227960701052881</id><published>2009-09-18T15:09:00.001+02:00</published><updated>2009-09-26T02:16:25.144+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='cl-zmq'/><title type='text'>Zero MQ + Lisp</title><content type='html'>Last year I got interested in &lt;a href="http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol"&gt;AMQP&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The most advanced implementation was/is Qpid, because it's a flagship product of such famous companies like JPMorgan, Goldman Sachs, Cisco, RedHat and many others. That means the standard was bloated a lot, you can see it, for example, by looking at specs 0-9 and 0-10: first is relatively simple, later is not. I'm afraid, it will ends up like Corba did. Unfortunately, RedHat and other guys are not interested in Lisp, but I thought it might be useful to have such library in Lisp, so thick and rich customers can use "official AI language" in their projects, and Lisp can benefits from it.&lt;br /&gt;&lt;br /&gt;After a two weeks of dancing around Lisp client implementation, I gave up. It was too huge work for me, beginner... A year later I've returned back to that theme and found ready to use Qpid client, fully implemented in Python. Python is closer to Lisp, I thought, so it's possible to use Python codes as a guideline. Heh... Sources are more than 350k in tarball, and it's only a client... It's easy to imagine, how much time will it sweep away from my life doing the same way in Lisp. A lot of complicated code to write, a lot of bugs to fix. No, I didn't really want it. I've decided to wrap Lisp calls, minimally required by standard, into Qpidc calls via CFFI. However, Qpidc is written in scary C++ with a lot of Boost (scary for bindings), so it required me to to write a wrapper for calling C++ from C first.&lt;br /&gt;&lt;br /&gt;Next idea, which came to my head due to laziness, is to google if there're any good AMQP realizations with ready to use bindings in C. It can be less powerful and less bleeding edge, but I just needed simple, convenient messaging. I found &lt;a href="http://www.zeromq.org/"&gt;ØMQ&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Zero MQ is not AMQP messaging library, but can use AMQP as an underlying wire-level transport. Feature list said it also has support of OFED, like Qpidc has. But the most impression I got by looking at API. It darn pretty simple! And it is even more simpler in version 2.0, which is in alpha stage at the moment. It is so simple, that I was able to CFFI'ize the only required zmq.h in one hour, and it worked for me. Impressing!&lt;br /&gt;&lt;br /&gt;Latency measurement using server and client both written in Lisp showed me quite good results:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;message size: 1024 [B]&lt;br /&gt;roundtrip count: 1000&lt;br /&gt;average latency: 48.7915 [us]&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;It's even slightly better than in C (with asserts commented out) :)&lt;br /&gt;&lt;br /&gt;Current bindings are in the early stage and have ugly CFFI interface, but I'm gonna make it a bit nicer and easy to use.&lt;br /&gt;&lt;br /&gt;Sources are here: &lt;a href="http://repo.or.cz/w/cl-zmq.git"&gt;http://repo.or.cz/w/cl-zmq.git&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-1448227960701052881?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/1448227960701052881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=1448227960701052881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/1448227960701052881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/1448227960701052881'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/09/zero-mq-lisp.html' title='Zero MQ + Lisp'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-4222351796919440972</id><published>2009-09-17T13:42:00.003+02:00</published><updated>2009-09-17T18:23:03.192+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='cl-v4l2'/><category scheme='http://www.blogger.com/atom/ns#' term='cl-gtk2'/><title type='text'>Eyes region tracking in Common Lisp</title><content type='html'>I was going to implement eyes region recognition in Lisp, but seems I'm loosing interest in that area. So I've decided to publish what I already has and forget about it.&lt;br /&gt;&lt;br /&gt;I've used CL-V4L2 to capture images from two USB cameras and CL-GTK2 with GtkGlExt extension for rasterization. The main idea of how to detect eyes region was taken from [1]. I can also mention [2] and [3].&lt;br /&gt;&lt;br /&gt;The basic idea is to apply edge detection filter to gray scale image, this will stress regions with lots of details. More details, more edges, more visibility in filtered image. Region around eyes has a lot of details, btw. Next step is to compute vertical and horizontal derivatives of edges and find extremums at each axises. Ideally, this will give us one horizontal extremum at eye's level and two vertical extremums at the head borders. Or, if a very strong median filter was used, it may give you one vertical extremum near the center of the face.&lt;br /&gt;&lt;br /&gt;However, I didn't succeeded in finding of good filter. First filter I've used was Sobel's operator [4]. Basically it works well for edges detection, but... Too much well for my task... It also finds edges in background parts, like shelf,&amp;nbsp; window, wall corner, etc. All this edges were false positives for my purpose. I've started to play with different similar filters, like Scharr's operator, Robert's cross [5] and also my own modifications of Sobel. The intention was to stress horizontal derivatives of edges during energy computation at X axis and, contrary, vertical derivatives at Y axis. I found Sobel/Scharr filter works better if G (gradient magnitude) was computed separately for X and Y energies the way described below:&lt;br /&gt;&lt;br /&gt;Here's matrix for Sobel:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://upload.wikimedia.org/math/4/3/2/4324cd5daf7569063b9d18beb05d8e69.png" /&gt;&lt;br /&gt;&lt;br /&gt;and for Scharr:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://upload.wikimedia.org/math/c/6/e/c6ef9a31b827c0fe6bae53539d696bc1.png" /&gt;&lt;br /&gt;&lt;br /&gt;I've combined Gx from Scharr and Gy from Sobel to compute G for X energies and Gx/Sobel, Gy/Scharr for Y energies.&lt;br /&gt;&lt;br /&gt;So, filters output was slightly improved, but still not enough to reduce unneeded edges. Much better result was brought by simplest Robert's cross. It doesn't filter edges well, but edges itselves are not what we definitely want. We want to stress eyes region, and Robert's cross does it better than Sobel or Scharr. However, image processing became more sensitive to background light. The only good time during the day was at evening when artificial daylight lamps were turned on. Noise reduction filters (a bunch of different modifications of Gaussian filter) didn't help at any degree. Finally, all smart computational logic was swept away leaving plain Robert's cross alone, which gave me the best result. Most of problems were caused by my beard and mustache, but I'm not gonna sacrifice my True Siberian Beard(tm) for the glory of science :)&lt;br /&gt;&lt;br /&gt;In my best attempt, I got this:&lt;br /&gt;&lt;br /&gt;&lt;object height="353" width="470"&gt;&lt;param name="movie" value="http://video.rutube.ru/69369875dfc9d37597241f8384ba751a"&gt;&lt;/PARAM&gt;&lt;param name="wmode" value="window"&gt;&lt;/PARAM&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/PARAM&gt;&lt;param name="flashVars" value="uid=2423828"&gt;&lt;/PARAM&gt;&lt;embed src="http://video.rutube.ru/69369875dfc9d37597241f8384ba751a" type="application/x-shockwave-flash" wmode="window" width="470" height="353" allowFullScreen="true" flashVars="uid=2423828"&gt;&lt;/EMBED&gt;&lt;/OBJECT&gt;&lt;br /&gt;&lt;br /&gt;I really enjoyed to play with it in Lisp, because Lisp gives you very powerful constructions like LOOP macro, which, for example, allows you to implement digital filter very quickly with only small amount of syntactical garbage. I can't forget to mention about automatic memory management, it saved me a ton of time. Nevertheless, with all these high-level whistles and bells, my non-optimized program still worked quite fast. I'm happy.&lt;br /&gt;&lt;br /&gt;Source is available here: &lt;a href="http://paste.lisp.org/display/87221"&gt;http://paste.lisp.org/display/87221&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1. &lt;a href="http://journal.info.unlp.edu.ar/Journal/journal15/papers/JCST-Oct05-3.pdf"&gt;http://journal.info.unlp.edu.ar/Journal/journal15/papers/JCST-Oct05-3.pdf&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://www.montegen.com/Montegen/Nature_of_Business/The_Library/The_Pocket-Science/The_Pocket-Science_Vol__4/Security___Intrusion_2000/Eye_location.pdf"&gt;http://www.montegen.com/Montegen/Nature_of_Business/The_Library/The_Pocket-Science/The_Pocket-Science_Vol__4/Security___Intrusion_2000/Eye_location.pdf&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://www.ecse.rpi.edu/%7Eqji/Papers/frgc_eye.pdf"&gt;http://www.ecse.rpi.edu/~qji/Papers/frgc_eye.pdf&lt;/a&gt;&lt;br /&gt;4. &lt;a href="http://en.wikipedia.org/wiki/Sobel_operator"&gt;http://en.wikipedia.org/wiki/Sobel_operator&lt;/a&gt;&lt;br /&gt;5. &lt;a href="http://en.wikipedia.org/wiki/Roberts_Cross"&gt;http://en.wikipedia.org/wiki/Roberts_Cross&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-4222351796919440972?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/4222351796919440972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=4222351796919440972' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/4222351796919440972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/4222351796919440972'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/09/eye-region-tracking-in-common-lisp.html' title='Eyes region tracking in Common Lisp'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-2002456958640506417</id><published>2009-08-25T20:38:00.004+02:00</published><updated>2009-08-25T22:12:24.189+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='cl-v4l2'/><category scheme='http://www.blogger.com/atom/ns#' term='cl-gtk2'/><title type='text'>Video processing</title><content type='html'>At my previous job I was working on integrated security system (ISS). One of major task was to capture and process video from video cameras. Usually, it was looked like PC-box with 3-4 very cheap tv-tuners based on bt878 and connected to some kind of "intellectual" signal splitter. It was possible to connect up to 32 cameras using single high-frequency cable of length up to several kilometers (I don't remember maximal extents, sorry). VGA-signal from camera was modulated by special small box, so all three dozens were connected to PC using one cable. If that looks like drastically cheap solution for you, I can ensure you: actually, it is even cheaper than in your dreams! ;)&lt;br /&gt;&lt;br /&gt;Our PC boxes were powered by Red Hat Linux 9 and, later, Fedora 2 and 5. Software was written entirely in C++ plus a bunch of shell and perl scripts. For video capturing itself we used Video4Linux2. It was approximately 1.2 megabytes of source code, some parts of it with heavy usage of Boost library. I can say, it was PITA to do research job in project, because, nevertheless we had ability to do partial builds via autotools, project was building at least 2-3 minutes, even after one small change. I didn't know any other computer language at that time, except "must have" z80 and x86 assemblers, C/C++ and some shell/perl. Ok, assembler isn't "must" now, but is highly recommended and useful in video processing tasks, believe me :) Of course, as a normal mainstream programmer, I participated to flame wars at internet forums w.r.t "super high-level" languages, and heard, these new languages can speed up development several times. So, I had some thoughts how would it great to abandon C++ in our ISS at least in non-critical parts like GUI, setup tool, logic, etc.&lt;br /&gt;&lt;br /&gt;Later I've started to read Common Lisp books and use SBCL for dumb helloworlds. I found Common Lisp is pretty lovely and, in the case of SBCL, is enough fast tool. I wanted to give it a try in video processing, but have changed my employer and country :) Heh.&lt;br /&gt;&lt;br /&gt;2 years flew away, some weeks ago, being kinda more seasoned Lisp programmer, I started to dance around CFFI-bindings for Video4Linux2 - CL-V4L2 project, which, in future, should be a base for my small home &lt;s&gt;brewed&lt;/s&gt;made ISS. The project sources are at &lt;a href="http://repo.or.cz/w/cl-v4l2.git"&gt;public GIT repository repo.or.cz&lt;/a&gt;. Currently, it's possible to capture video from both my web-cameras. I don't have tv-tuner yet, but I'm almost sure it will work.&lt;br /&gt;&lt;br /&gt;Example in CL-V4L2 uses CL-GTK2 to draw a picture in GTK-window. I sent a patch to CL-GTK2's author, Dmitry Kalyanov, the patch adds ability to use GL-accelerated canvas in your application (via gtkglext library). Dmitry should prepare new sources for inclusion in CL-GTK2 shortly. I remember image scaling was one of the largest CPU consumer in ISS, and bulk GLDrawArea-prototype showed pretty good results: image scaling became as cheap, as a cost of cheapest modern graphic card you can buy in stores.&lt;br /&gt;&lt;br /&gt;So, basically, bindings are ready for work, but they are capture oriented only, no video output, no VBI, not all ioctls and structure are implemented. However, it is quite easy to extend its feature set now. Use it, enjoy it, report bugs :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-2002456958640506417?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/2002456958640506417/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=2002456958640506417' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/2002456958640506417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/2002456958640506417'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/08/video-processing.html' title='Video processing'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-3741352493857416072</id><published>2009-08-25T19:48:00.001+02:00</published><updated>2009-08-25T20:39:28.973+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><title type='text'>Here be dragons</title><content type='html'>Finally, I was pushed to start blog in English. Yeah, my wife told me it can be useful for other people who can't read my russian blog (with the same name at livejournal.com).&lt;br /&gt;&lt;br /&gt;Ok, I'm gonna write here about my openings in the world of Common Lisp. I've started to discover this great language about 2.5 years ago, and now able to put down a couple of lines of code in Emacs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-3741352493857416072?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/3741352493857416072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=3741352493857416072' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/3741352493857416072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/3741352493857416072'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2009/08/here-be-dragons.html' title='Here be dragons'/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2767637963813047764.post-5481785626557188216</id><published>2008-03-24T12:39:00.000+01:00</published><updated>2008-12-19T18:23:27.921+01:00</updated><title type='text'></title><content type='html'>Тест&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2767637963813047764-5481785626557188216?l=13-49.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://13-49.blogspot.com/feeds/5481785626557188216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2767637963813047764&amp;postID=5481785626557188216' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/5481785626557188216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2767637963813047764/posts/default/5481785626557188216'/><link rel='alternate' type='text/html' href='http://13-49.blogspot.com/2008/03/blog-post.html' title=''/><author><name>Vitaly Mayatskikh</name><uri>https://profiles.google.com/106882883940668249179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh5.googleusercontent.com/-ZKcxXhhp2Is/AAAAAAAAAAI/AAAAAAAABVQ/xjg_2QW78pg/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>
