logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

Status-update.md (4054B)


  1. ---
  2. date: 2020-08-16
  3. layout: post
  4. title: Status update, August 2020
  5. tags: ["status update"]
  6. ---
  7. Greetings! Today is another rainy day here in Philadelphia, which rather sours
  8. my plans of walking over to the nearby cafe to order some breakfast to-go. But I
  9. am tired, and if I'm going to make it to the end of this blog post in one piece,
  10. I'm gonna need a coffee. brb.
  11. Hey, that was actually pretty refreshing. It's just drizzling, and the rain is
  12. nice and cool. Alright, here goes! What's new? I'll leave the Wayland news for
  13. [Simon Ser's blog](https://emersion.fr/blog) this month - he's been working on
  14. some exciting stuff. The [BARE encoding](https://baremessages.org/) announced
  15. last month has received some great feedback and refinements, and there are now
  16. six projects providing BARE support for their author's favorite programming
  17. language[^1]. There have also been some improvements to the Go implementation
  18. which should help with some SourceHut plans later on.
  19. [^1]: Or in some cases, the language the author is begrudgingly stuck with.
  20. On the subject of SourceHut, I've focused mainly on infrastructure improvements
  21. this month. There is a new server installed for hg.sr.ht, which will also be
  22. useful as a testbed for additional ops work planned for future expansion.
  23. Additionally, the PostgreSQL backup system has been overhauled and made more
  24. resilient, both to data loss and to outages. A lot of other robustness
  25. improvements have been made fleet-wide in monitoring. I'll be working on more
  26. user-facing features again next month, but in the meanwhile, contributors like
  27. наб have sent many patches in which I'll cover in detail in the coming "What's
  28. cooking" post for [sourcehut.org](https://sourcehut.org/blog).
  29. Otherwise, I've been taking it easy this month. I definitely haven't been
  30. spending a lot of my time on a secret project, no sir. Thanks again for your
  31. support! I'll see you next month.
  32. <details>
  33. <summary>?</summary>
  34. <pre>
  35. use io;
  36. use io_uring = linux::io_uring;
  37. use linux;
  38. use strings;
  39. export fn main void = {
  40. let uring = match (io_uring::init(256u32, 0u32)) {
  41. err: linux::error => {
  42. io::println("io_uring::init error:");
  43. io::println(linux::errstr(err));
  44. return;
  45. },
  46. u: io_uring::io_uring => u,
  47. };
  48. let buf: [8192]u8 = [0u8...];
  49. let text: nullable *str = null;
  50. let wait = 0u;
  51. let offs = 0z;
  52. let read: *io_uring::sqe = null: *io_uring::sqe,
  53. write: *io_uring::sqe = null: *io_uring::sqe;
  54. let eof = false;
  55. while (!eof) {
  56. read = io_uring::must_get_sqe(&uring);
  57. io_uring::prep_read(read, linux::STDIN_FILENO,
  58. &buf, len(buf): u32, offs);
  59. io_uring::sqe_set_user_data(read, &read);
  60. wait += 1u;
  61. let ev = match (io_uring::submit_and_wait(&uring, wait)) {
  62. err: linux::error => {
  63. io::println("io_uring::submit error:");
  64. io::println(linux::errstr(err));
  65. return;
  66. },
  67. ev: uint => ev,
  68. };
  69. wait -= ev;
  70. for (let i = 0; i < ev; i += 1) {
  71. let cqe = match (io_uring::get_cqe(&uring, 0u, 0u)) {
  72. err: linux::error => {
  73. io::println("io_uring::get_cqe error:");
  74. io::println(linux::errstr(err));
  75. return;
  76. },
  77. c: *io_uring::cqe => c,
  78. };
  79. if (io_uring::cqe_get_user_data(cqe) == &read) {
  80. if (text != null) {
  81. free(text);
  82. };
  83. if (cqe.res == 0) {
  84. eof = true;
  85. break;
  86. };
  87. text = strings::must_decode_utf8(buf[0..cqe.res]);
  88. io_uring::cqe_seen(&uring, cqe);
  89. write = io_uring::must_get_sqe(&uring);
  90. io_uring::prep_write(write, linux::STDOUT_FILENO,
  91. text: *char, len(text): u32, 0);
  92. io_uring::sqe_set_user_data(write, &write);
  93. wait += 1u;
  94. offs += cqe.res;
  95. } else if (io_uring::cqe_get_user_data(cqe) == &write) {
  96. assert(cqe.res > 0);
  97. io_uring::cqe_seen(&uring, cqe);
  98. } else {
  99. assert(false, "Unknown CQE user data");
  100. };
  101. };
  102. };
  103. io_uring::close(&uring);
  104. };
  105. </pre>
  106. <details>
  107. <summary>hmm?</summary>
  108. <p>I might note that I wrote this program to test my io_uring wrapper; it's not
  109. representative of how normal programs will do I/O in the future.</p>
  110. </details>
  111. </details>