On 11/23/2026 7:39 PM, MitchAlsup wrote:
> BGB <cr88…@gmail.com> posted:
>
>> On 11/22/2026 7:04 PM, John Savard wrote:
>>> On Sun, 22 Nov 2026 16:34:12 -0600, BGB <cr88…@gmail.com> wrote:
>>>
>>>> To some extent though, does seem like much of the claimed performance
>>>> gains of the past 20 years are mostly an illusion though. Most of what
>>>> exists due more to "more and faster RAM" than due to the CPUs themselves
>>>> actually getting all that much faster. Like, the 2000s era computers
>>>> didn't have slow CPUs, they had a small amount of slow RAM (and people
>>>> then blamed the CPU for the RAM's deficiencies).
>
> To be fair, we blamed the system.
>
Blaming the whole system is a bit too coarse grained...
Like, there is no denying, say, that 20+ year old laptops are "not exactly fast".
But, the question is more what part in particular makes the 20 year old laptop slow...
Many act like it is solely a CPU thing, I suspect it is not.
>>>> People can disagree, but this is just what my experience seems to suggest.
>>>
>>> You are correct that ever since Dennart scaling died, CPUs haven't
>>> been getting faster by leaps and bounds the way they used to. Still,
>>> in addition to more RAM, there have still been...
>>>
>>> small incremental improvements in clock speed with scaling,
>>> more cores,
>>> more cache,
>>> more aggressive out-of-order execution
>>> ------------
>> Had noted, that there seems to be a machine-dependent thing on the
>> relative speed of the method used for copying a sequence of
>> self-overlapping bytes.
>>
>> Branch/shift method:
>> if(d==1)
>> {
>> tv=((byte *)dst)[-1];
>> tv|=tv<<8;
>> tv|=tv<<16;
>> tv|=tv<<32;
>> ((u64 *)dst)[0]=tv;
>> ((u64 *)dst)[1]=tv;
>> }else if(d==2)
>> {
>> tv=((u16 *)dst)[-1];
>> tv|=tv<<16;
>> tv|=tv<<32;
>> ((u64 *)dst)[0]=tv;
>> ((u64 *)dst)[1]=tv;
>> }else
>> ...
>> Vs, raw byte-copy method:
>> src=dst-d;
>> dst[0]=src[0];
>> dst[1]=src[1];
>> dst[2]=src[2];
>> dst[3]=src[3];
>> dst[4]=src[4];
>> dst[5]=src[5];
>> dst[6]=src[6];
>> dst[7]=src[7];
>> ...
>>
>> On most of the targets, the former is significantly faster, but
>> seemingly on the Intel side, the naive raw byte-copy method sees a large
>> boost (and so is not quite so slow in comparison).
>
> When memcopy() is an instruction, small machines can run at cache-width,
> and large machines can run at cache-width × ports ...
>
> When memcopy is for(i = 0; i < count; i++ ) to[i] = from[i]; your vVM
> unit can run it at SIMD-widths {say 512-bits copied per cycle}.
>
I would think you would need something special to handle self-overlap / RLE cases though.
Could maybe be useful if there were SIMD instructions to help with self-overlapping RLE.
If it behaves like a "memmove()", this can work for many use-cases, but is not what is typically needed for an LZ decompressor.
Well, there are different ways to do things, but this was more specifically about self-overlapping LZ copies, say:
Most copies are ~ 4-16 bytes;
Can almost specialize the "16 bytes or less" into its own category.
For speed, can allow all copies to be padded up;
Say, up to next multiple of 16, with up to 31 bytes of "stomp";
Copying an exact number of bytes comes with a large penalty.
With an a skew of distance probabilities (less than 8 bytes).
Most to least common: 1, 2, 4, 3, 5, 6, 7
Only applicable when dist<sz.
Else:
Just use the short-match non-overlap-copy case.
Then a question of, what is the fastest way to deal with them.
The most canonical answer might be:
for(i=0; i<sz; i++)
dst[i]=src[i];
But, this is also the slowest.
Some might unroll, and be like "branches are evil", but it is still slow.
If/else is still imperfect, but seemingly the lesser evil, if organized roughly according to the probability distribution.
Idea is, say, to pull out 1/2/4 first, then deal with 3/5/6/7 with a binary tree structure, say:
if(d<6)
{
if(d==3)
{ ... 3 }
else
{ ... 5 }
}else
{
if(d==6)
{ ... 6 }
else
{ ... 7 }
}
Which is, kinda bulky and ugly, but also works reasonably well at self-overlapping copies.
Could "switch()" but switch is usually slower in this case.
In this case, the switch will typically compile into the equivalent of:
if(d==1) goto case_1;
if(d==2) goto case_2;
if(d==3) goto case_3;
...
Some experiments had noted fastest patters were typically:
1/2/4: Same basic pattern from prior post.
3: Mask off low 24 bits, OR onto itself, then 3 stores at 6-byte stepping;
5/6/7: Load 64 bits, then do multiple stores to fill the 16-bytes.
Though, more specifically, this is what was typically fastest on my main PC in my testing.
For short non-overlap copy, can do, say:
tv0=((u64 *)src)[0];
tv1=((u64 *)src)[1];
((u64 *)dst)[0]=tv0;
((u64 *)dst)[1]=tv1;
...
I guess the relevant question would be how much a lot of this stuff is likely to differ from one machine to another.
Or, if there are actually machines where "just use a linear sequence of byte loads/stores is fastest".
There are also possible variants to be friendly to machines which use aligned-only loads/stores, but this is a level of "dark magic" I am less inclined to write out in a post... Or accept the hit and fall back to loading and storing individual bytes.
I guess, related to this:
How would someone try to implement something like LZ4 decompression semi-efficiently on a CPU like the original form of the DEC Alpha?...
...