3 ms·
Long ago, an OS I worked inside had a tool which took shared library indirect calls, and wired them out so you did not have a nested indirect function call cost
by ggm 7y ago
Long ago, an OS I worked inside had a tool which took shared library indirect calls, and wired them out so you did not have a nested indirect function call cost, but went direct from the call to the backend without the pass-through the null function mapping into the specific .so library. It made things faster by one layer of the onion skin.
Strip, as a UNIX tool removes the textual crap in a debuggable binary, to leave behind only the bits you needed.
It feels to me like if you can do runtime code call checks, and confirm which actual calls you make, then stripping the bits of libc and associated libraries out, being left with only the strictly required calls, and then by extension the syscalls, and then by extension the kernel elements, is actually possible a lot of the time.
So, library -> reduced library -> reduced calls -> reduced syscalls -> reduced kernel state is a sequence or set or something, of applied minimisations which can be done, if you can predict all the call paths in your code and their dependencies.
But then its not a generic OS any more: its an application specific binding to a general purpose CPU.
Why not go all the way, and work into the ALU and remove the bits you don't need? And then go into the micro code, and the associated FPGA, and everything else..
- sp332 7y agoYou have to make sure your test cases exercise every possible code path. German demogroup .theprodukkt made a demo one time, .kkreiger, a first-person shooter game in 96kb. They used a technique like this to strip every line of source code that was not hit during a playtest. But the playtester didn't press the up-arrow in the main menu, so that doesn't work. More importantly they didn't get hit by any bullets, so in the final release the player is invulnerable because the code that handles damage was never compiled. Edit: more informative link https://fgiesen.wordpress.com/2012/04/08/metaprogramming-for-madmen/ https://fgiesen.wordpress.com/2012/04/08/metaprogramming-for...
- ggm 7y agoYes. And its almost impossible to do this without a huge investment in time and effort, except: If you use languages with FP, and are rigorous, then I believe (possibly wrongly) its actually somewhat simpler to understand because the style of coding in FP exposes much of this "better" than in classic imperative coding So yes, I think you're right: great dream, hugely hard to do, if not actually impossible in most cases near as damnit, but there are places where program proofs take you to this, Military/Space/Medical needs to know the code calls don't have unexpected outcomes. And language choices which express as "how" you express code, can also help. Probably not enough.
- oblio 7y agoI think it's impossible, or close to it. Isn't it just another form of the halting problem? https://en.wikipedia.org/wiki/Halting_problem https://en.wikipedia.org/wiki/Halting_problem
- sp332 7y agoI'm not sure it's relevant. All real machines have limitations that we accept when we write programs and feed them data. Anyway just because you can't prove that all possible programs will or won't run correctly doesn't mean you can't prove this for a useful subset of programs.
- striking 7y agoWell, the alternative is that you limit the set of things you can do, such that you no longer have a Turing machine. But that's certainly less fun, isn't it?
- AnimalMuppet 7y agoDepends on your definition of fun.
- robto 7y agoThe halting problem states that it's impossible to know if computation will terminate in the general case, but there are lots of specific cases where we can prove that it will terminate. The Idris language compiler (think haskell with dependent types) will actually warn/error if you've written a function that it can't prove will terminate. It's actually really cool! If you're interested in learning more, I'd check out any talks by Edwin Brady or pick up his book[0] [0]Type-Driven Development with Idris
- o-__-o 7y agoThis sounds a lot like an Ethereum dApp...
- NelsonMinar 7y agoThat sounds a little like the ideas in the Synthesis kernel, the idea of the kernel JIT-compiling itself to optimize your code path.
- coldtea 7y ago>Why not go all the way, and work into the ALU and remove the bits you don't need? And then go into the micro code, and the associated FPGA, and everything else.. Because there are diminishing returns...
- kazinator 7y agoThere is a lazy binding optimization in ELF shared libraries on GNU/Linux. The first call to the "PLT stub" of a shared library routine will self-modify so that the next call will go directly to the destination without having to calculate it again from the global offset table.
- edwintorok 7y agoFPGA designs are usually created with high-level synthesis tools, where the input is not that much different from writing "software". See Chisel, and other such languages. The designs for some RISC-V CPUs are available as open-source, so one could in theory take all that, and make it available as a library that you can compose as you wish. Slight downside is that now you have to be knowledgeable at FPGAs, Operating Systems and Programming Languages to build something coherent. If the components are well documented, simple and easy to use then perhaps the resulting system would be of less complexity than your typical system today. It would be interesting to see how one could go in one direction to create a minimal self-contained system with such an architecture, i.e. the VPRI STEPS projects, but including FPGAs this time. On the other hand there is tremendous value in using some well-defined standards along the way so you can benefit from all the debugging, analysis and verification tools that already exist, so such hardware/software co-design is always a balance.
- m463 7y agoYou can also do things like runtime profile optimization and link time optimization. get a runtime profile, then optimize the code based on how it will run. linktime optimization has the compiler output bytecode files, then the optimization happens at the link step where it happens globally across all objects.