Article View: comp.arch
Article #917Re: Very Depressing Video
From: BGB
Date: Tue, 24 Nov 2026 04:28
Date: Tue, 24 Nov 2026 04:28
190 lines
7251 bytes
7251 bytes
On 11/23/2026 7:39 PM, MitchAlsup wrote:
> BGB <cr88192@gmail.com> posted:
>
>> On 11/22/2026 7:04 PM, John Savard wrote:
>>> On Sun, 22 Nov 2026 16:34:12 -0600, BGB <cr88192@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?...
...
Technical Details
Message-ID:
<11e33ol$2gkdu$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<6aff95fd.2756312@news.eternal-september.org> <6b02f61c.2940750@news.eternal-september.org> <11dvql5$1cfvl$1@dont-email.me> <6b038fcc.42284937@news.eternal-september.org> <11e28vv$27g58$1@dont-email.me> <1795484398-5857@newsgrouper.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: BGB <cr88192@gmail.com> Newsgroups: comp.arch Subject: Re: Very Depressing Video Date: Mon, 23 Nov 2026 22:28:04 -0600 Organization: A noiseless patient Spider Lines: 190 Message-ID: <11e33ol$2gkdu$1@dont-email.me> References: <6aff95fd.2756312@news.eternal-september.org> <6b02f61c.2940750@news.eternal-september.org> <11dvql5$1cfvl$1@dont-email.me> <6b038fcc.42284937@news.eternal-september.org> <11e28vv$27g58$1@dont-email.me> <1795484398-5857@newsgrouper.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 24 Nov 2026 04:28:06 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2642366"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zwMXoukQZckMe0YEZXwHxUd2gc1oae/Y="; posting-host="0134f31a5b1a20288131fad378fafe1d" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:CIKEo6i2dxrUffkM2GUY0JjWaZc= sha256:da8GZueiY3KmyoCdb8hT9dN3vAKZw2PB3uJ65UnVHpM= sha1:EMhQYENmmHKcvwJyRmkqH/NgOy4= sha256:nc++qZnMpSZjnpAz4dRvqq2pPOMiomMnjHZx5s3RkQA= In-Reply-To: <1795484398-5857@newsgrouper.org> Content-Language: en-US