HN user

molenzwiebel

249 karma
Posts9
Comments18
View on HN

For this use-case, you can squeeze out even more performance by using the SHA-1 implementation in Intel ISA-L Crypto [1]. The SHA-1 implementation there allows for multi-buffer hashes, giving you the ability to calculate the hashes for multiple chunks in parallel on a single core. Given that that is basically your usecase, it might be worth considering. I doubt it'll provide much speedup if you're already I/O bound here though.

[1] https://github.com/intel/isa-l_crypto

Time and time again we learn that people do stupid things under stress. Consider Transair flight 810 [1], in which a simple engine failure during takeoff results in a complete loss of the aircraft when both pilots mistakenly identify the _wrong_ engine as malfunctioning, despite identifying the failure correctly only minutes earlier. OP has an article on that crash too, actually [2].

[1] https://en.wikipedia.org/wiki/Transair_Flight_810 [2]: https://admiralcloudberg.medium.com/dark-waters-of-self-delu...

If you liked this article, definitely consider checking out other articles written by Kyra (Admiral_Cloudberg). She has done a ton of articles on almost all notable (near)crashes, including their root causes, investigations, and subsequent effects on the airplane industry.

For some crashes that have interesting causes (at least from an engineering perspective) beyond "maintenance failed to identify a problem before takeoff" or "pilots fail to identify problem or take wrong actions", I strongly recommend the articles on TWA 800 (1996) [1] and the near-crash of SmartLynx Estonia 9001 (2018) [2]. The first goes into great detail exactly _how_ the FAA discovered the root cause, whereas the second one involves a logic oversight in the flight computers of a modern Airbus plane.

[1] https://admiralcloudberg.medium.com/memories-of-flame-the-cr... [2]: https://admiralcloudberg.medium.com/the-dark-side-of-logic-t...

He used to be. He recently left the rust-analyzer and rust compiler development teams to broaden his horizons, and is working full-time on a project that uses Zig now (which no doubt sparked this thought experiment).

Worth checking out if you're interested in using constraint/logic programming languages for type checking is the Statix (https://www.spoofax.dev/references/statix/) language, which is used in the Spoofax language workbench. It works similarly to Prolog in solving constraints, but adds support for scope graphs, which are a generic approach to specifying the name binding behavior of programming languages through logic constraints.

A friend suggested we try do this after seeing stack-overflow-import (https://github.com/drathier/stack-overflow-import), which queries stackoverflow for some matching result and loads it. For small functions, it's surprisingly effective. You still need Copilot access to use this, unfortunately.

Some other examples:

  >>> from copilot import rock_paper_scissors
  >>> rock_paper_scissors('Rock', 'Scissors')
  'Player 1 wins'

  >>> from copilot import get_current_git_commit
  >>> get_current_git_commit()
  b'29c7e9b138a9247c598b613ca378d103de878e2a\n'

  >>> from copilot import answer_to_everything
  >>> answer_to_everything(1)
  42
Practically, it works through two separate copilot calls. The first one asks copilot to predict the arguments a function would take, then the second one asks it to predict the body of the function. The returned code is then parsed, both to ensure that it is actual valid Python (it almost always is, although it sometimes spits out Python 2 or cuts off due to length limits), and to remove any extra statements that are not part of the function (sometimes it likes to include an `if __name__ == "__main__"` for example).

The function is then wrapped in an error handler that will attempt to include a module if the snippet references an undefined variable. Copilot tends to use the correct libraries, but forgets to import them so this step is necessary to get most things working. We experimented with prompting an `import ` inside the function body, which worked decent but delivered some wonky results when the code needed more than one import or when it needed none at all.