Readit News logoReadit News
Brentward commented on Mimalloc Cigarette: Losing one week of my life catching a memory leak (Rust)   pwy.io/posts/mimalloc-cig... · Posted by u/Patryk27
Patryk27 · a year ago
Not sure why all the hostility here - you haven't seen the code, know nothing about the domain and yet you're certain that our performance requirements are false and that "code base got sacrificed" (apparently by adding two lines of rather self-explanatory code?)

Feels like you've just read grugbrain.dev and decided to shoot your golden tips at everybody without actually trying to understand the situation.

Anyway, there's one good point here:

> why is your allocator in this path, then?

Because those prices change 24/7/365, million times a day, and so refreshing happens pretty much all the time in the background, eating CPU time. What's more, calculating prices is much more complicated than a hashmap lookup - hotels can have dynamic number of discounts, taxes etc., and they can't all be precomputed (too many combinations).

You know, not all complexity is made up, a little trust in others won't hurt.

Brentward · a year ago
I agree that the comment sounded pretty hostile, but I also agreed with the assessment that it might be better to avoid allocation in general. I know the code in the post is highly simplified, but you aren't exactly fully using "lazy iterators," at least in the post. refresh/load_hotels is still allocating new Hotels, each of which contains a one-million-element Vec. If you could reuse the existing self.hotels[id].prices Vec allocations, that might help, again at least in the example code.

On second glance, I guess this is what you're getting at with the ArcSwap comment in the post. It sounds like you really do want to reallocate the whole State and atomically swap it with the previous state, which would make reusing the prices Vec impossible, at least without keeping around two States and swapping between them.

Anyway, tone aside, I still think the comment had validity in a general optimization sense, even if not in this specific case.

Brentward commented on Compilers for continuous integration of Fortran projects   fortran-lang.discourse.gr... · Posted by u/genphy1976
zaikunzhang · a year ago
Did you succeed in porting the code? It would not be easy according to my experience with PRIMA. I would be happy to learn if you have a GitHub repo of it. Thanks.
Brentward · a year ago
Yes, at least the parts that my research group used regularly. I ported them to Rust, though, not modern Fortran. They're also pretty specific to computational chemistry, rather than general packages like PRIMA, but I'll link them here in case you're curious anyway. I was also still learning Rust and followed the original Fortran API and naming scheme where possible, so this code could use a refactor too! But at least there are no gotos.

https://github.com/ntBre/anpass - ordinary least squares fitting https://github.com/ntBre/intder - internal coordinate transformations https://github.com/ntBre/spectro - vibrational perturbation theory

PRIMA looks very interesting, by the way. I may see if I can get some use out of it in my research!

Brentward commented on Compilers for continuous integration of Fortran projects   fortran-lang.discourse.gr... · Posted by u/genphy1976
leonheld · a year ago
> The concept of CI (Continuous Integration) and GitHub Actions have been not only life-changing but also eye-opening to me. They enable me to test my code with intensity and extensiveness that are unimaginable otherwise.

That's such a surprising sentence for me to read in 2024. CI to me is like a compiler: a basic, necessary tool. One of those things I assume everyone else also does. I guess the Fortran people move a bit slower than the rest of the industry in this regard?

Brentward · a year ago
In grad school I worked on three separate Fortran code bases written as early as the 80s with tens of thousands of lines, no source control or version history, no build systems or even build scripts, and no tests. I think a lot of old scientific software is in the same condition, with some mix of "if ain't broke don't fix it" and the code being very hard to refactor.

This quote from the linked PRIMA page pretty much sums up my experience porting the above code too: "I hope I am the last one in the world to decode a maze of 244 GOTOs in 7939 lines of Fortran 77 code — I did this for three years and I do not want anyone else to do it again"

Brentward commented on How Hackerman would create an image just by typing 0 and 1 – deep dive into GIF   medium.com/@happybits/how... · Posted by u/happybits
jolmg · 2 years ago
That first

> 00 00 00 00

should be `05 00 05 00`.

Brentward · 2 years ago
Yeah the article says these "aren't used anymore," but my image viewer (sxiv) complained that the gif was corrupted until I put something there. It still displayed the image, but it also complained afterwards.
Brentward commented on Advent of Code 2023 is nigh   adventofcode.com/2023/... · Posted by u/i13e
AdamH12113 · 2 years ago
Unless the question has been edited recently, it did. There are multiple lines in the second example input that show the overlap:

> eightwothree

> 4nineeightseven2

> zoneight234

I test my AoC solutions incrementally by printing output, so I found that I was failing to produce the correct list of numbers in a line right away. I suppose if you're taking a faster approach and just trying to extract the first and last numbers that it's easier to miss. It's always a good idea to look at the example input, though.

Brentward · 2 years ago
Those examples contain overlap, but not in the first or last digit that is given as the solution. So from the instructions you can't tell that the intermediate list of numbers should be 8, 2, 3, you only know that the final answer is 83.
Brentward commented on Star neuroscientist may have manipulated data to support a major stroke trial   science.org/content/artic... · Posted by u/EndXA
MPSimmons · 2 years ago
If you (like me) weren't familiar with the Excel mistake:

https://www.businessinsider.com/reinhart-and-rogoff-admit-ex...

Brentward · 2 years ago
I thought it was going to be the Excel DNA to date conversion.

https://www.theverge.com/2020/8/6/21355674/human-genes-renam...

Brentward commented on Chess Written in GNU Sed   github.com/moldabekov/che... · Posted by u/pabs3
chasil · 2 years ago
For awk, start with the book by Kernighan/Aho/Weinberger. The PDF of the first edition is freely available on archive.org, and a second edition has been announced. Chapter 2 of the first edition is only 40 pages, and describes all language features.

https://news.ycombinator.com/item?id=13451454

For sed, the best resource is likely the free "UNIX Bookshelf" from O'Reilly that can be found online; this contains a book specifically focusing on Sed and Awk.

https://freecomputerbooks.com/The-Unix-CD-Bookshelf-Version-...

Brentward · 2 years ago
The second edition is out! I started reading it last week, and it's great so far.

https://www.awk.dev/

Brentward commented on Using Emacs as $EDITOR   magnus.therning.org/2023-... · Posted by u/signa11
earthscienceman · 2 years ago
Well,this is extremely clever and simple. I tried that out from vterm in 29.1 and it crashed emacs...
Brentward · 2 years ago
Personally, I got tired of weird quirks like this with vterm and now bind this command to the key I used to have vterm on to spawn my actual terminal (st) in my current directory. It's probably not what most people want from vterm, but I prefer it.

  (defun open-term-here ()
    "open st in `default-directory`"
    (interactive)
    (call-process-shell-command
     (concat "st bash -c \"cd "
      default-directory
      " && exec zsh\"")
     nil 0))

Brentward commented on Let's write a treesitter major mode for Emacs   masteringemacs.org/articl... · Posted by u/nanna
shanusmagnus · 2 years ago
Is there anything that returns a parse tree of an org document? A while ago I wrote some super hacky elisp to navigate around the structure of a giant org mode doc, but it was rickety and terrible and constantly breaking.

Part of this is surely that I don't know wtf I'm doing, but it seemed like there was not an underlying data structure held in memory that you could conveniently query / manipulate, but rather, most of the existing org functionality built some kind of structure each time you did an operation.

Would appreciate any pointers, code examples, tutorials that show how to effectively navigate / manipulate an org structure and have it reflected in the buffer, if there is such a thing.

Brentward · 2 years ago
In org-alert we use `org-map-entries` and a simple `org-alert--parse-entry` function for stripping out the details we're looking for. Depending on what you want, it's not exactly a data structure, but maybe it will help you get started!

https://github.com/spegoraro/org-alert/blob/master/org-alert...

Brentward commented on Even more hindsight on Vim, Helix and Kakoune   phaazon.net/blog/more-hin... · Posted by u/cosmojg
jhoechtl · 2 years ago
Where is Emacs? Version 29 will be an absolutely great release!
Brentward · 2 years ago
It already is! I've been building Emacs from the development branch for the last couple of years, and the improvements in 29 and now 30 have really been great. I barely remember the sluggishness the other comment mentions.

u/Brentward

KarmaCake day41September 10, 2020View Original