th the er e error or of ou f our r ways ys
play

Th The Er e Error or of Ou f Our r Ways ys @KevlinHenney - PowerPoint PPT Presentation

Th The Er e Error or of Ou f Our r Ways ys @KevlinHenney https://twitter.com/tackline/status/757562488363843584 Knight Capital Group realized a $460 million loss in 45 minutes. Doug Seven


  1. Th The Er e Error or of Ou f Our r Ways ys @KevlinHenney

  2. https://twitter.com/tackline/status/757562488363843584

  3. Knight Capital Group realized a $460 million loss in 45 minutes. Doug Seven https://dougseven.com/2014/04/17/knightmare-a-devops-cautionary-tale/

  4. The update to SMARS was intended to replace old, unused code referred to as “Power Peg” — functionality that Knight hadn’t used in 8-years. Doug Seven https://dougseven.com/2014/04/17/knightmare-a-devops-cautionary-tale/

  5. Why code that had been dead for 8 years was still present in the code base is a mystery, but that’s not the point. Doug Seven https://dougseven.com/2014/04/17/knightmare-a-devops-cautionary-tale/

  6. The code that that was updated repurposed an old flag that was used to activate the Power Peg functionality. Doug Seven https://dougseven.com/2014/04/17/knightmare-a-devops-cautionary-tale/

  7. In the first 45 minutes the market was open the Power Peg code received and processed 212 parent orders. As a result SMARS sent millions of child orders into the market resulting in 4 million transactions against 154 stocks for more than 397 million shares. Doug Seven https://dougseven.com/2014/04/17/knightmare-a-devops-cautionary-tale/

  8. The failure resulted in a loss of more than US$370 million. http://en.wikipedia.org/wiki/Cluster_(spacecraft)

  9. Simple Testing Can Prevent Most Critical Failures An Analysis of Production Failures in Distributed Data-Intensive Systems https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-yuan.pdf

  10. Almost all catastrophic failures are the result of incorrect handling of non-fatal errors explicitly signalled in software. https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-yuan.pdf

  11. A majority of the production failures (77%) can be reproduced by a unit test. https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-yuan.pdf

  12. S-Programs P-Programs E-Programs Meir M Lehman "Programs, Life Cycles, and Laws of Software Evolution"

  13. S-Programs Programs whose function is formally defined by and derivable from a specification. Meir M Lehman "Programs, Life Cycles, and Laws of Software Evolution"

  14. P-Programs Despite the fact that the problem to be solved can be precisely defined, the acceptability of a solution is determined by the environment in which it is embedded. Meir M Lehman "Programs, Life Cycles, and Laws of Software Evolution"

  15. E-Programs Programs that mechanize a human or societal activity. The program has become a part of the world it models, it is embedded in it. Meir M Lehman "Programs, Life Cycles, and Laws of Software Evolution"

  16. Always design a thing by considering it in its next larger context. Eliel Saarinen

  17. http://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/

  18. function leftpad (str, len, ch) { str = String(str); var i = -1; if (!ch && ch !== 0) ch = ' '; len = len - str.length; while (++i < len) { str = ch + str; } return str; }

  19. var cache = [ '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ]; function leftPad (str, len, ch) { // convert `str` to `string` str = str + ''; // `len` is the `pad`'s length now len = len - str.length; // doesn't need to pad if (len <= 0) return str; // `ch` defaults to `' '` if (!ch && ch !== 0) ch = ' '; // convert `ch` to `string` ch = ch + ''; // cache common use cases if (ch === ' ' && len < 10) return cache[len] + str; // `pad` starts with an empty string var pad = ''; // loop while (true) { // add `ch` to `pad` if `len` is odd if (len & 1) pad += ch; // divide `len` by 2, ditch the remainder len >>= 1; // "double" the `ch` so this operation count grows logarithmically on `len` // each time `ch` is "doubled", the `len` would need to be "doubled" too // similar to finding a value in binary search tree, hence O(log(n)) if (len) ch += ch; // `len` is 0, exit the loop else break; } // pad `str`! return pad + str; }

  20. function leftpad(content, length, pad) { content = String(content) pad = String(pad || pad === 0 ? pad : ' ')[0] var left = Math.max(length - content.length, 0) return pad.repeat(left) + content }

  21. test({ "Padding an empty string to a length of 0 results in an empty string": () => assert(leftpad("", 0, "X") === ""), "Padding a non-empty string to a shorter length results in the same string": () => assert(leftpad("foobar", 3, "X") === "foobar"), "Padding a non-empty string to a negative length results in the same string": () => assert(leftpad("foobar", -3, "X") === "foobar"), "Padding a non-empty string to its length results in the same string": () => assert(leftpad("foobar", 6, "X") === "foobar"), "Padding to a longer length with a single character fills to the left": () => assert(leftpad("foobar", 8, "X") === "XXfoobar"), "Padding to a longer length with surplus characters fills using only first": () => assert(leftpad("foobar", 10, "XY") === "XXXXfoobar"), "Padding to a longer length with an empty string fills with space": () => assert(leftpad("foobar", 8, "") === " foobar"), "Padding to a longer length with no specified fill fills with space": () => assert(leftpad("foobar", 9) === " foobar"), "Padding to a longer length with integer 0 fills with 0": () => assert(leftpad("foobar", 7, 0) === "0foobar"), "Padding to a longer length with single-digit integer fills with digit": () => assert(leftpad("foobar", 10, 1) === "1111foobar"), "Padding to a longer length with multiple-digit integer fills with first digit": () => assert(leftpad("foobar", 10, 42) === "4444foobar"), "Padding to a longer length with negative integer fills with -": () => assert(leftpad("foobar", 8, -42) === "--foobar"), "Padding a non-string uses string representation": () => assert(leftpad(4.2, 5, 0) === "004.2") })

  22. function assert(condition) { if(!condition) throw { name: "AssertionError", message: "assertion failed" } } function testPasses(toTry) { try { toTry() return true } catch (failure) { return false } } function report(testName, passed) { document.write(testName.fontcolor(passed ? "green" : "red") + "<br>") } function test(testCases) { for (var testName in testCases) if (testCases.hasOwnProperty(testName)) report(testName, testPasses(testCases[testName])) }

  23. Padding an empty string to a length of 0 results in an empty string Padding a non-empty string to a shorter length results in the same string Padding a non-empty string to a negative length results in the same string Padding a non-empty string to its length results in the same string Padding to a longer length with a single character fills to the left Padding to a longer length with surplus characters fills using only first Padding to a longer length with an empty string fills with space Padding to a longer length with no specified fill fills with space Padding to a longer length with integer 0 fills with 0 Padding to a longer length with single-digit integer fills with digit Padding to a longer length with multiple-digit integer fills with first digit Padding to a longer length with negative integer fills with - Padding a non-string uses string representation

  24. Padding an empty string to a length of 0 results in an empty string Padding a non-empty string to a shorter length results in the same string Padding a non-empty string to a negative length results in the same string Padding a non-empty string to its length results in the same string Padding to a longer length with a single character fills to the left Padding to a longer length with surplus characters fills using only first Padding to a longer length with an empty string fills with space Padding to a longer length with no specified fill fills with space Padding to a longer length with integer 0 fills with 0 Padding to a longer length with single-digit integer fills with digit Padding to a longer length with multiple-digit integer fills with first digit Padding to a longer length with negative integer fills with - Padding a non-string uses string representation

  25. zfill

  26. rjust

  27. I have yet to see any problem, however complicated, which, when you looked at it in the right way, did not become still more complicated. Anderson's Law

  28. I would therefore like to posit that computing's central challenge, "How not to make a mess of it", has not been met. Edsger W Dijkstra

  29. Most of our systems are much more complicated than can be considered healthy, and are too messy and chaotic to be used in comfort and confidence. Edsger W Dijkstra

Recommend


More recommend