Merge remote-tracking branch 'origin/main'

This commit is contained in:
zleyyij
2025-05-06 11:51:43 -06:00
150 changed files with 41599 additions and 502 deletions

15
notes/ANS Theory.md Normal file
View File

@ -0,0 +1,15 @@
<https://arxiv.org/abs/1311.2540>
In standard numeral systems, different digits are treated as containing the same amount of information. A 7 stores the same amount of info as a 9, which stores the same amount of info as a 1.
This makes the amount of information a single digit stores *uniform* across all digits. However, that's far from the most efficient way to represent most datasets.
ANS theory is based around the idea that digits that occur more often can be stored in a way that requires less information, and digits that occur less often can be stored using more information.
Taking a look at the standard binary numeral system, there are two digits in the set (0 and 1). Given a natural number represented in binary, eg `1010`, there are two different ways to *add information to that number*:
1. We can add a digit to the most significant position. As an example, adding a `1` to the above value would result in `11010`. Doing this means that the added digit stores information about *large ranges*. In the provided example, this means that setting that digit changes the value by 16.
2. We can add a digit to the least significant position. As an example, adding a `1` to the above value would result in `10101`. Changing the added digit will only change the resulting natural number by 1.
Given that $x$ represents a natural number, and $s$ is the digit we're adding. In a standard binary system, adding $s$ to the least significant position means that in the new number $x$ (before the addition) now represents the Nth appearance of an even (when $s = 0$ ), or odd (when $s = 1$). With ANS, the goal is is to make that asymmetrical, so that you can represent more common values with a denser representation.

View File

@ -15,17 +15,31 @@ One proposed use case of copy-and-patch compilation in the paper is as an SQL qu
(Halfway through Page 3):
> The compilation time of our compiler is so low that it is less than the time it takes to construct the AST of the program. Compared with interpreters, both have negligible startup delay (since constructing ASTs takes longer), but our execution performance is an order of magnitude faster. Compared with LLVM -O0, our implementation compiles two orders of magnitude faster and generates code that performs on average 14% better. Therefore, we conclude that copy-and-patch renders both interpreters and LLVM -O0 compilation obsolete in this use case.
# Implementation Details
At a broad level, copy and patch code compilation works by having a pre-built library of composable binary code snippets, referred to as binary stencils. This makes both code generation and optimization a simple task, achieved simply by performing a lookup in a data table to select the stencil, then copying it to the output and patching in the missing values.
At a broad level, copy and patch code compilation works by having a pre-built library of composable binary code snippets, referred to as binary stencils. Each binary stencil performs the operation of a single AST node/bytecode instruction. This makes both code generation and optimization a simple task, achieved simply by performing a lookup in a data table to select the stencil, then copying it to the output and patching in the missing values.
First, prior to compilation, MetaVar generates a stencil library.
That stencil library is used as input for a
That stencil library is used as input for a copy and patch code generator, alongside a bytecode sequence or AST node. In the copy step, stencils are copied from the stencil library that implement the bytecode/AST node. In the patch step, pre-determined places in the binary code (Operands of machine instructions, jump addresses, the values of constants).
Even though machine code is patched, a copy and patch compiler doesn't need to have knowledge of platform specific machine instructions, and is portable across architectures supported by the patch library.
## MetaVar
### Overview
MetaVar generates binary stencils, which allows the user to systematically generate the binary stencil variants in clean and pure C++, and leverages the
Clang + LLVM compiler infrastructure to hide all platform-specific low-level detail.
The MetaVar compiler generates binary stencils of different optimization levels for every bytecode or AST node.
MetaVar can generate binary stencils of different optimization levels for every bytecode or AST node, which the generator can select from at generation time. As am example, if the instruction is for adding a constant to a literal, the generator can select from addition implementations for the most optimized variant. It can also make register allocation decisions by keeping track of register availability and picking between stack instructions and register instructions.
### Stencil Library Construction
MetaVar constructs the stencil library from programmer defined *stencil generators*. One stencil generator is defined for every AST node using C++ template meta-variables to express variants, and special macros to express missing values to be patched at runtime.
At compile time, the compiler iterates over the values of the meta-variables and creates a library entry for every valid combination.
### Compile time
Stencil generators are templated C++ functions whose template instantiations produce stencils. At "runtime", the generator will perform tree pattern matching to determine the correct variant, then complete a hash table lookup to retrieve the stencil, then copy it to the output.
# Terminology
| Phrase | Definition |

View File

@ -0,0 +1 @@
https://arxiv.org/pdf/1311.2540

View File

@ -0,0 +1,5 @@
<https://dougallj.wordpress.com/2022/07/30/parallelising-huffman-decoding-and-x86-disassembly-by-synchronising-non-self-synchronising-prefix-codes/>
# Scratchpad
- Start decoding at arbitrary points throughout the data
- \

View File

@ -0,0 +1,11 @@
- https://www.ankermake.com/blogs/guides/how-to-make-3d-prints-stronger
- https://blog.prusa3d.com/how-to-improve-your-3d-prints-with-annealing_31088/
- https://markforged.com/resources/blog/joinery-onyx
- https://bigrep.com/posts/gyroid-infill-3d-printing/
- https://www.hp.com/us-en/printers/3d-printers/learning-center/3d-printed-joint-design.html
TL;dr:
- Use gyroid infill with an infill density of between 50-80% for structural prints
- Use PLA with a very slow speed, low layer height, and minimal/no cooling
- Use dovetail joints of scale defined in the HP article
- Anneal the print at 110c for ~30 minutes depending on the size and shape of the object