

{"id":938,"date":"2012-11-04T11:30:48","date_gmt":"2012-11-04T10:30:48","guid":{"rendered":"http:\/\/fabsk.eu\/blog\/?p=938"},"modified":"2012-11-07T22:28:21","modified_gmt":"2012-11-07T21:28:21","slug":"go-xml-sax-like-parsing-is-slow","status":"publish","type":"post","link":"https:\/\/fabsk.eu\/blog\/2012\/11\/04\/go-xml-sax-like-parsing-is-slow\/","title":{"rendered":"Go XML sax-like parsing is slow"},"content":{"rendered":"<p>I wanted to write a Openstreetmap XML processor in Go language, hoping that I would get a performance boost from my Python implementation. And it ended being slower. Python is using Expat (written in C) and maybe the Go module \u00abencoding\/xml\u00bb is not the state of the art of optimization.<\/p>\n<p>In wrote simple programs handling the event \u00abstart element\u00bb. In 10 seconds, I could parse the following amount of XML data (Athlon II X4 620):<\/p>\n<ul>\n<li>PyPy: did not run because of a <a title=\"Issue1314:\u00a0expat parser should read file by chunks\" href=\"https:\/\/bugs.pypy.org\/issue1314\">bug<\/a> (no progressive parsing)<\/li>\n<li>Go: 70Mo<\/li>\n<li>Python 2.7: 210Mo<\/li>\n<li>Python 3.2: 215Mo<\/li>\n<li>Java 7: 460Mo<\/li>\n<li>C++ \/ libxml: 675Mo<\/li>\n<\/ul>\n<p>I tried to use Expat or Libxml in Go, but for the moment it is just too complicated. In Go code, It&rsquo;s easy to call C functions located in shared libraries, but if you need to pass callback functions written in Go to a library written in C, you will have to do dirty things (create wrappers in a Go module having C code).<\/p>\n<p>That&rsquo;s a pity because the Go compiler automatically generates C wrappers for your exported Go functions, but you can not get an raw pointer to these wrappers (this way I would have been able to pass my callbacks to LibXML or Expat)\u2026 See you later, Go.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to write a Openstreetmap XML processor in Go language, hoping that I would get a performance boost from my Python implementation. And it ended being slower. Python is using Expat (written in C) and maybe the Go module \u00abencoding\/xml\u00bb is not the state of the art of optimization. In wrote simple programs handling [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,25],"tags":[],"class_list":["post-938","post","type-post","status-publish","format-standard","hentry","category-dev","category-golang"],"_links":{"self":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts\/938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/comments?post=938"}],"version-history":[{"count":11,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts\/938\/revisions"}],"predecessor-version":[{"id":961,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts\/938\/revisions\/961"}],"wp:attachment":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/media?parent=938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/categories?post=938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/tags?post=938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}