{"id":197,"date":"2014-05-10T13:41:58","date_gmt":"2014-05-10T18:41:58","guid":{"rendered":"http:\/\/codezen.org\/canto-ng\/?p=197"},"modified":"2014-05-10T13:41:58","modified_gmt":"2014-05-10T18:41:58","slug":"whats-on-the-horizon","status":"publish","type":"post","link":"https:\/\/codezen.org\/canto-ng\/2014\/05\/10\/whats-on-the-horizon\/","title":{"rendered":"What&#8217;s on the horizon?"},"content":{"rendered":"<p>It&#8217;s been almost a year since I&#8217;ve had the energy to seriously look at canto. Between a job that was soul-crushing with layoffs of a lot of people I consider friends, subsequent unsuccessful job hunting, a five-day two-man startup, and the usual stress of being a husband and father, I needed a hiatus.<\/p>\n<p>&#8230; Until a week or two ago &#8230;<\/p>\n<h3 id='Whats-in-tree-now'>What&#8217;s in tree now<\/h3>\n<p>Over the past few days I&#8217;ve pushed a couple of nice commits to the canto trees.<\/p>\n<ul>\n<li>Much faster Reddit plugin for the daemon<\/li>\n<li>Much faster config stuff, so doing stuff like <code>:browser<\/code> or any other configuration from <code>canto-curses<\/code> or <code>canto-remote<\/code> is instantaneous instead of lagging for a second or two.<\/li>\n<li>A coarse grain multi-threading implementation for the daemon.<\/li>\n<\/ul>\n<h3 id='Multithreading'>Multi-threading<\/h3>\n<p>Multi-threading is something that I&#8217;ve avoided for a long time in the daemon. Here&#8217;s why:<\/p>\n<ul>\n<li>The daemon was designed to be a logical abstraction of the feed database that could function over a socket. That is, it&#8217;s meant to be a server like <code>screen<\/code>, not Apache.<\/li>\n<li>The daemon already took advantage of threading for fetching feeds to avoid long IO timeouts by necessity, and that&#8217;s easily separated.<\/li>\n<li>Multi-threading introduces subtle bugs<\/li>\n<\/ul>\n<p>You can see why I was reticent. However, here&#8217;s why I&#8217;ve started to implement it.<\/p>\n<ul>\n<li>It makes the daemon marginally more responsive.<\/li>\n<li>It will allow better and faster client behavior.<\/li>\n<li>The daemon is relatively mature.<\/li>\n<\/ul>\n<p>The big thing here is that it will allow clients to have better behavior. For example, currently in <code>canto-curses<\/code> if you, say, start it up and then immediately switch a setting (like <code>:filter<\/code>), you will clear the items&#8230; and then proceed to get a bunch more that don&#8217;t follow that filter setting. That&#8217;s shit, but there are only three ways to handle this. Either you teach the client to ignore the subsequent responses from the daemon (which with a single thread means the daemon is still generating output, and the client is still reading it, just not acting on it), you close the socket which discards the information but also all of your connection state (like events you&#8217;re watching), <em>or<\/em> you bite the bullet and make multiple daemon connections not suck which lets you keep your state on one connection and start a fresh connection to get data with your new settings.<\/p>\n<p>The yields other benefits, like being able to get data out of line. For example, opening the reader requires information that 99% of the time you don&#8217;t need hanging around (i.e. 8k of text when all you care about is the 100 byte title &#8212; over 10k items that adds up quite quickly). In the current system, the reader has to wait in line until it gets the information it needs. Crappy. If the client and daemon are threaded, the reader makes its request and, even if the daemon&#8217;s in the middle of fulfilling a big request for another connection, the reader will get it&#8217;s information immediately.<\/p>\n<p>I also mentioned maturity. Canto, as a whole, isn&#8217;t even close to perfect. However, the daemon itself is pretty stable and polished and ready for an undertaking like threading.<\/p>\n<p>The interface part that you actually use? Not so much. The command line sucks, there&#8217;s no completion, bad or non-existent error handling. There&#8217;s also an ultra-powerful text rendering system built into that&#8217;s basically impossible to use if you&#8217;re not me or at least decent at Python.<\/p>\n<p>This multi-threading change is going to lead to a revamp of the curses interface. I&#8217;ll get into that a little later (after I&#8217;ve actually coded a lot of it), but the threaded daemon is an important part of it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s been almost a year since I&#8217;ve had the energy to seriously look at canto. Between a job that was soul-crushing with layoffs of a lot of people I consider friends, subsequent unsuccessful job hunting, a five-day two-man startup, and the usual stress of being a husband and father, I needed a hiatus. &#8230; Until <a class=\"read-more\" href=\"https:\/\/codezen.org\/canto-ng\/2014\/05\/10\/whats-on-the-horizon\/\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/posts\/197"}],"collection":[{"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":5,"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"predecessor-version":[{"id":203,"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/posts\/197\/revisions\/203"}],"wp:attachment":[{"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codezen.org\/canto-ng\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}