News for hackers. Stuff that matters.
Re:LeanQt – GUI is here, Widgets are near by Waterluvian on Saturday November 12, 2022 @11:34AM (#33574612)
Are there tools to evaluate (imperfectly) the percent of a binary that actually gets used?

Like, run an application, run the watcher tool, then “walk the application” as best as possible and get an output: “35% of the binary was never read.” ?

What’s on my mind is evaluating the actual result of tools and methods for not including unnecessary things. I struggle with this in web land. Tree shaking and such does a wonderful job but I honestly don’t know how much of my bundle is still superfluous.

Re:LeanQt – GUI is here, Widgets are near by bkallus on Saturday November 12, 2022 @11:36AM (#33574640)
I don't know, but one could implement this without too much difficulty as a wrapper around afl-showmap.
Re:LeanQt – GUI is here, Widgets are near by xcambar on Saturday November 12, 2022 @12:28PM (#33575130)
No, because you can't prove every piece of functionality has been executed.
Re:LeanQt – GUI is here, Widgets are near by Waterluvian on Saturday November 12, 2022 @12:30PM (#33575144)
True. What’s what I meant by (imperfectly). But perfect can’t be the enemy of good. There’s tremendous value in the data. You wouldn’t use it to just omit those bits. But it tells you a lot.
Re:LeanQt – GUI is here, Widgets are near by ergvgdvgrd on Saturday November 12, 2022 @12:32PM (#33575171)
Run time "code coverage" would give you that.
Re:LeanQt – GUI is here, Widgets are near by speps on Saturday November 12, 2022 @01:08PM (#33575452)
Read this classic article: https://fgiesen.wordpress.com/2012/04/08/metaprogramming-for...

The section called "A plan so insane, it might just work" describes what you mention.

Re:LeanQt – GUI is here, Widgets are near by tscherno on Saturday November 12, 2022 @01:42PM (#33575765)
In an interview I can't find anymore a developer from Farbrausch said that they used such a method to optimize the .kkrieger demo and ended up having a bug in the main menu because while recording the coverage the user never scrolled to a certain main menu item. So once you scrolled there you couldn't scroll up anymore.
Re:LeanQt – GUI is here, Widgets are near by Waterluvian on Saturday November 12, 2022 @01:55PM (#33575885)
This reminds me of Naughty Dog overwriting standard library functions to gain more RAM for Crash Bandicoot. They would just “delete a function and see if the game still worked.”
Re:LeanQt – GUI is here, Widgets are near by speps on Saturday November 12, 2022 @05:03PM (#33577592)
See my comment in the same parent: https://news.ycombinator.com/item?id=33575452
Re:LeanQt – GUI is here, Widgets are near by 323 on Saturday November 12, 2022 @02:00PM (#33575933)
Executable binaries are memory mapped into memory. So the pages are lazily loaded. So in theory you could study how many of the pages (4 KB each) of the binary were actually loaded to get a rough idea. Obviously not very precise since it has a 4 KB granularity.
Re:LeanQt – GUI is here, Widgets are near by bitwize on Saturday November 12, 2022 @02:24PM (#33576175)
You can run a profiler to determine which functions actually get called.

I'm reminded of a Smalltalk hack called Spoon. It required two systems: a host system running the full Smalltalk with all its classes, and a target system which had the barest possible Smalltalk environment. Any time an attempt was made to access a class that didn't exist on the target system, it would ask the host system for that class and if available, download it in serialized bytecode form and run it. This may have worked at method level granularity -- i.e., classes were only populated with methods that were actually used on the target system -- I'm not sure. But the result was the target system only contained enough of Smalltalk to actually run the program.

Re:LeanQt – GUI is here, Widgets are near by heavyset_go on Saturday November 12, 2022 @03:56PM (#33576985)
That feels halting problem-esque.
Re:LeanQt – GUI is here, Widgets are near by Epa095 on Saturday November 12, 2022 @05:18PM (#33577719)
It definitely is if you want a 100% correct and 100% certain answer. But if you accept 3 categories 1: this we know is used 2: this we know is not used, 3 this we don't know anything about, then it's doable.
Re:LeanQt – GUI is here, Widgets are near by colejohnson66 on Saturday November 12, 2022 @06:40PM (#33578381)
But (2) requires knowing everything the binary will do. You can’t know what something won’t do without knowing what it will do.
Re:LeanQt – GUI is here, Widgets are near by tadfisher on Saturday November 12, 2022 @07:21PM (#33578653)
You can do (2) if you can tolerate false positives. For example, if a symbol isn't referenced literally elsewhere in the binary, consider it unused, but add a configuration option to keep it in case it is referenced dynamically. The JVM world has been doing this for years with ProGuard.
Re:LeanQt – GUI is here, Widgets are near by yarg on Saturday November 12, 2022 @09:28PM (#33579344)
Branches are a problem, depending on the number of parameters needed to be evaluated:

> Solving a constraint satisfaction problem on a finite domain is an NP-complete problem in general.

https://en.wikipedia.org/wiki/Complexity_of_constraint_satis...