{"id":111334,"date":"2017-04-13T11:52:45","date_gmt":"2017-04-13T11:52:45","guid":{"rendered":"http:\/\/www.timestored.com\/b\/?p=111334"},"modified":"2017-04-13T13:15:11","modified_gmt":"2017-04-13T13:15:11","slug":"kdb-3-5-stack-trace","status":"publish","type":"post","link":"https:\/\/www.timestored.com\/b\/kdb-3-5-stack-trace\/","title":{"rendered":"kdb 3.5 Released with Stack Trace"},"content":{"rendered":"<p>kdb+ 3.5 had a significant number of changes:<\/p>\n<ul>\n<li><b>Debugger<\/b> &#8211; At long last we can finally get stack traces when errors occur.<\/li>\n<li><b>Concurrent Memory Allocator<\/b> &#8211; Supposedly better performance when returning large results from peach<\/li>\n<li><b>Port Reuse<\/b> &#8211; Allow multiple processes to listen on same port. Assuming <a href=\"https:\/\/lwn.net\/Articles\/542629\/\">Linux Support<\/a><\/li>\n<li><b>Improved Performance<\/b> &#8211; of Sorting and Searching<\/li>\n<li><b>Additional ujf function<\/b> &#8211; Similar to uj from v2.x fills from left hand side<\/li>\n<\/ul>\n<h2>kdb Debugger<\/h2>\n<p>The feature that most interests us right now is the Debugging functionality. If you are not familiar with how basic errors, exceptions and stack movement is handled in kdb see our first article on <a href=\"http:\/\/www.timestored.com\/kdb-guides\/debugging-kdb\">kdb debugging here<\/a>. In this short post we will only look at the new stack trace functionality.<\/p>\n<p>Now when you run a function that causes an error at the terminal you will get the stack trace. Here&#8217;s a simple example where the function f fails:<\/p>\n\r\n<textarea cols='80' rows='9' id='debugger-simple'>\r\nq)f:{x+1}\r\nq)f 2\r\n3\r\nq)f `a\r\n'type\r\n  [1]  f:{x+1}\r\n           ^\r\n<\/textarea><script type='text\/javascript'>var myCodeMirror = CodeMirror.fromTextArea(document.getElementById('debugger-simple'), {lineNumbers: true, matchBrackets: true, indentUnit: 4, tabMode: 'default', mode: 'text\/x-plsql', readOnly:true });<\/script>\r\n\n<p>Whatever depth the error occurs at we get the full depth stack trace, showing every function that was called to get there using .Q.bt[]:<\/p>\n\r\n<textarea cols='80' rows='20' id='debugger-full'>\r\nq)f:{x+1}\r\nq)g:{100*f x}\r\nq)h:{13+g x}\r\nq)h 9\r\n1013\r\nq)h `beep\r\n'type\r\n  [3]  f:{x+1}\r\n           ^\r\nq)).Q.bt[]\r\n  [5]  .Q.bt[]\r\n       ^\r\n  [4]  (.Q.dbg)\r\n\r\n  [3]  f:{x+1}\r\n           ^\r\n  [2]  g:{100*f x}\r\n              ^\r\n  [1]  h:{13+g x}\r\n             ^\r\n  [0]  h `beep\r\n       ^\r\n<\/textarea><script type='text\/javascript'>var myCodeMirror = CodeMirror.fromTextArea(document.getElementById('debugger-full'), {lineNumbers: true, matchBrackets: true, indentUnit: 4, tabMode: 'default', mode: 'text\/x-plsql', readOnly:true });<\/script>\r\n\n<p><img loading=\"lazy\" src=\"https:\/\/www.timestored.com\/b\/wp-content\/uploads\/2017\/04\/qstudio-stack-trace-error.png\" alt=\"qstudio-stack-trace-error\" width=\"198\" height=\"347\" class=\"alignleft size-full wp-image-111339 dropshadow\" style=\"margin:5px 10px\" srcset=\"https:\/\/www.timestored.com\/b\/wp-content\/uploads\/2017\/04\/qstudio-stack-trace-error.png 198w, https:\/\/www.timestored.com\/b\/wp-content\/uploads\/2017\/04\/qstudio-stack-trace-error-171x300.png 171w\" sizes=\"(max-width: 198px) 100vw, 198px\" \/><\/p>\n<p>The good news is that this same functionality is availabe in qStudio 1.43. Give it a try: <a href=\"http:\/\/www.timestored.com\/qstudio\/download\">qStudio<\/a>.<\/p>\n<p>Note: the ability to show stack traces relies on qStudio wrapping every query you send to the server with its own code to perform some analysis and return those values. By default wrapping is on as seen in <a href=\"http:\/\/www.timestored.com\/qstudio\/help\/preferences\">preferences<\/a>. If you are accessing a kdb server ran by someone else you may have to turn wrapping off as that server may limit which queries are allowed. Unfortunately stack tracing those queries won&#8217;t be easily possible.<\/p>\n<p>That&#8217;s just the basics, there are other new exposed functions and variables, such as .Q.trp &#8211; for trapping calls and accessing traces that we are going to look at in more detail in future. <\/p>\n<p><br style=\"clear:both\"\/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>kdb+ 3.5 had a significant number of changes: Debugger &#8211; At long last we can finally get stack traces when errors occur. Concurrent Memory Allocator &#8211; Supposedly better performance when returning large results from peach Port Reuse &#8211; Allow multiple processes to listen on same port. Assuming Linux Support Improved Performance &#8211; of Sorting and [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[2,92],"tags":[],"_links":{"self":[{"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/posts\/111334"}],"collection":[{"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/comments?post=111334"}],"version-history":[{"count":14,"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/posts\/111334\/revisions"}],"predecessor-version":[{"id":111353,"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/posts\/111334\/revisions\/111353"}],"wp:attachment":[{"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/media?parent=111334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/categories?post=111334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.timestored.com\/b\/wp-json\/wp\/v2\/tags?post=111334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}