#๐Ÿช…-progaming

1 messages ยท Page 109 of 1

supple whale
#

big difference

royal nymph
#

not what i asked

supple whale
#

no it actually matters

#

because threading is "fuck it, dont care throw this task on another thread, w/e, jsut dont fuck my main thread"

#

multithreading is "fuck i need this complex task computed as fast as possible across all cores"

royal nymph
#

it's kinda the first but i also don't want it to take for ages so multiple workers on demand

supple whale
#

so im making sure this aint an A/B problem

royal nymph
#

i wish i was using go rn

supple whale
#

what are you trying to do?

royal nymph
#
go doThing()
supple whale
#

because i know few things that scale well with multi-threading in JS

royal nymph
#

it's not about scaling, it's just for @elder yarrow

#

just not to block the main thread (and also be able to do multiple requests at once)

#

rn if u generate a gif with venbot it just blocks the entire bot lmao

supple whale
#

yeah workerpool is useless for that then, you want to spawn a separate worker for each manip, as the requests come in

#

since you cant do image manip across multiple threads at once

royal nymph
#

how is it useless? isn't using a pool that can reuse workers way more efficient than always spawning a new one

supple whale
#

because it simply doesnt scale with threads

#

so you'd be wasting compute

royal nymph
#

how does it not scale wdym

#

this isn't gonna be editing 1000 images at once

#

a few at once at max

#

those should be done parallely

supple whale
#

yeah, and you'll be performing likely synchronous merge operations on a single data array, this isnt C, and you wont be micro optimising mutexes

#

node threads are green threads, so you can simply spawn 10k of them, they are very low cost to start

#

but sorry, to answer your question, i've never used workerpool, since as a rule of thumb, all worker pool implementations in JS are dogshit, because its JS, when I need that kind of performance I usually opt for NAPI and C multi threading, which performs x1000 better

#

lemme have a gander at the codebase and i'll give u my opinion

#

its dogshit

#

its a very generic worker pool implementation, but it converts all functions you pass to it to a string first

#

which it then executes in the worler

#

you could write something better yourself in 2 minutes

royal nymph
#

yeah i wouldnt use that lol you can also create a worker pool from a file

#

2 minutes is a bit of an overstatement WatameComfy

supple whale
#

no

#

really

#

i'm not even joking

#

this is rudementary at best

#

it horrendously overcomplicates this lol

supple whale
#

anyways, i'd still probs just spawn a worker per action, since i'm lazy as shit, and worry about perf if that problem shows up then, but it shouldnt

supple whale
#

no worker pools have very good uses, its just.... they arent very common

crude star
#

launching a worker obviously has its overhead

supple whale
#

V's use case is decent enough

#

just the language itself isnt quite suited to it

crude star
#

and idle workers are idle so its not wasting anything

supple whale
#

its just an object with its own scope

#

its a green thread

#

this seems like a less... insane version of what u need

#

i dont think it has serialization doe, which might be a problem

crude star
#

if you launch 1 per request and dont limit it you'll selfddos

crude star
#

yope

shrewd canopy
crude star
#

what's there to async

supple whale
crude star
#

js is single threaded

supple whale
#

node-canvas is the only thing

#

and its sync

royal nymph
#

why are they abusing the add function as an object instead of just creating a new object lmao

#

module.exports = { add, multiply } ๐Ÿ˜ญ

supple whale
#

seems quite sane no?

royal nymph
#

it's below

royal nymph
supple whale
#

yeah thats for multiple functions per worker

#

i dont think you'd care abt that tbf

royal nymph
#

did you even read what I said love

supple whale
#

yeh

royal nymph
#

the cursed part is that they're doing ```js
add.add = add;
add.multiply = multiply;
export add

supple whale
#

well i skimmed over it because i'm looking for that one benchmark that shows that nodejs can easily handle like 20k workers at once

#

for rini

shrewd canopy
#

Eris does same afaik

crude star
#

add({ a: 1, b: 1 })

#

so sane

supple whale
royal nymph
crude star
supple whale
#

aka "fake in software threads"

royal nymph
#

I mean nothing wrong with that

supple whale
#

like you can easily run 1 mil threads in nodejs

#

just like go

royal nymph
#

go threading is really efficient

supple whale
#

i wish they'd improve it, go would be unbeatable if they did

crude star
#

never had problems with it

royal nymph
#

go has the best multithreading I've ever used

supple whale
royal nymph
#

go would be best language then

supple whale
#

the only thing stopping nodejs from having go-like threading is the language syntax, because the featureset allows it

#

which suuuucks major dick

#

we need inline threading so much its unfunny

royal nymph
#

honestly i might just use a single worker with a queue

supple whale
#

like just let us do

function goCommitDie() {}

new Worker(goCommitDie)
royal nymph
#

people can wait a bit for their request it's not like 200 people will be using it at once

supple whale
#

yeah pretty much

supple whale
#

since it alr implements a q

#

but yeah

royal nymph
#

is there any point even sharing small buffers (like few hundred kb) or is it cheaper to just copy them

supple whale
#

always share them

#

sorry

#

always transfer them

crude star
#

you should add an image generation currency

supple whale
#

always use transferred buffers

#

its 0 cost

royal nymph
#

yeah that's what I mean

#

transferring

supple whale
#

and always faster

royal nymph
#

didn't know the exact word

supple whale
#

it can cause errors if you dont handle it correctly yes

#

but its 0 cost, and always faster

royal nymph
#

is it really 0 cost tho

supple whale
#

yes

#

its the same process, it operates on the same vm, in the same memory

royal nymph
#

In go it's usually faster to copy function parameters than pass a reference

supple whale
#

Unlike child_process or cluster, worker_threads can share memory.

crude star
supple whale
#

it depends on ur throughput, if the data is like >50MB/s it REALLY helps

#

if its not then fuck cares tbf

royal nymph
#

well duh

#

how often are u passing 50mb to a func tho

supple whale
#

no sir, 50MB/s

#

not 50MB/call

#

it could be 1k calls of 50kb

#

objects are also automagically transferred

#

so no need to worry there

#

you only need to specify transferable arguments manually for potentially problematic things like direct memory aka arraybuffers, GPU bitmaps, and images

#

since those are often controlled

royal nymph
supple whale
#

im fairly sure not in v8

#

again, its pretty much the same process, so there's no copying even happening

royal nymph
#

if you pass a reference it has to deref it from memory which is slower

supple whale
#

yes but its pretty much always faster than structure cloning it

#

unless the data is like 8 bytes

royal nymph
#

and more efficient allocation

#

it can put the value on the stack

royal nymph
#

Also gc shenanigans

supple whale
#

yeah for go its defo true

#

but i'm 99% sure thats not true for v8

royal nymph
#

if it can put it on the stack it doesn't have to gc

#

if you use a pointer it likely has to put it on the heap and then it has to gc it later

royal nymph
supple whale
#

the smallest data benchmark i can find is for 32MB

#

which is still a nuts difference

royal nymph
royal nymph
#

I was mainly interested in smaller data

supple whale
#

32MB isnt large XD

royal nymph
#

well

#

compared to 500kb it is

supple whale
#

i fucking do 3GB/s for my subtitle renderer

royal nymph
#

I always shit myself when I see huge data structures until I realise it's actually not as much as it seems

#

like casual array with 1 million elements

#

it's not actually that much

supple whale
#

lmao yeah

#

i recently got my torrent client to run at like 2Gbit/s @ 1k connections on a single fucking thread

#

and its so horrendously simple to do high perf at scale in JS its crazy

#

just dont .slice() and dont copy

#

its always that simple

royal nymph
#

holy fuck js array limit is 4 billion

#

time to make a 1 billion element array

royal nymph
supple whale
#

arraybuffer is bigger afaik, but you need to manually increase the max V8 VM memory size

supple whale
royal nymph
#

a good while ago I was playing around with js performance a bit

#

I wrote a simple password brute force algorithm

my first implementation was so slow cause I used string manipulation & comparison

then I rewrote it with nodejs Buffer and it was better but still slow

then I rewrite it with raw Uint8Array and it was incredibly fast

supple whale
#

anyways, always use trasnferables, its a good habit to have, and its good to get used to the edge cases

supple whale
royal nymph
#

lesson of the story Buffer sucks mariGrin

supple whale
#

its ancient

#

so it suffers a lot from backwards compatibility problems

#

it sucks because it needs to support its first versions, which sucked

#

and readables suck for the same reason do

royal nymph
#

only like 20% slower iirc

supple whale
#

i always replace all readable usages with streamx, because its API is 95% the same, and its x10 faster, and interoperable with streams

royal nymph
#

what's streamx

supple whale
#

but not bad for a fucking GC language eh???

#

v8 is NUTS

supple whale
#

just, not dogshit

#

3rd party lib

#

im not joking when i say ALWAYS use streamx instead of nodejs streams if you need to

#

but its always best if you use async iterators

#

but u cant always, so just use streamx

#

its SO much faster, because it doesnt touch buffer

#

nodejs streams always do a Buffer.from() on incoming data

#

streamx doesnt care, it just passes whatever data is given to it

royal nymph
#

I never use streams much cause I don't usually have a need for them

supple whale
#

and it also uses microtasks instead of timers

#

so the perf diff its nuts

supple whale
#

and if you DO need to just use:

for await (const buffer of fs.createReadStream('/path/to/data')){
    //stuff
}
#

and

async function data * () {
   yield 42
}

Readable.from(data()).pipe(fs.createWriteStream('/path/to/data'))
#

its unfunny how much faster it is than streams, even with the promise overhead

royal nymph
#

I think the only time I used streams is when uploading / downloading files with fetch

#

res.body.pipe(createWriteStream())

supple whale
#

i legit did this for the torrent client lib i work on, made it 80% faster, reduced bundle size down to 400kb from 3MB, and dropped memory usage by over half

#

its nuts XD

#

hashing in nodejs still sucks tho

royal nymph
#

I hate how in nodejs there's both web and node streams and different apis use either one so it's a pain to make them compatible and you have to constantly Readable.fromWeb

#

like i get the desire to be spec compliant but man does it suck

supple whale
#

the web crypto api in nodejs is fucking slow, and the node api for it is synchronous and blocking, but x4 faster :/

supple whale
#

i strictly operate only on async iterators

#

seriously u should adopt this ideology

#

just async iterators everywhere

#

fuck stream bullshit

royal nymph
supple whale
#

here u dont need to since u dont douch the data

royal nymph
#

res.body is response from nodejs global fetch

supple whale
#

so what u have works fine

pearl stagBOT
supple whale
#

i'd use file handles, ut yeah

#

yeah that works perfectly fine

royal nymph
#

the fact that you gotta convert it to node from web first annoys me

supple whale
#

its not that bad

#

node fs is stream only for the most part

#

ofc i have my own implementations which are faster, using handles and data flushing

#

for random access file

#

but u dont need that perf, so that is perfectly usable

royal nymph
#

yeah it almost never matters for the things I'm doing

supple whale
#
import 'fast-readable-async-iterator'
import { open } from 'node:fs/promises'

const res = await fetch('gay')
const fd = await open('sample.txt')

for await (const data of res.body) {
  await fd.writeFile(data)
}
await fd.close()
#

i think this should work

#

i dont remember i didnt use file handles for quite some time now

#

i dont remember if writeFile appended or overwrote

royal nymph
#

completely unrelated but I wish web had something like android's recyclerview

its really more difficult than it should be to make performant lists in html

like rendering thousands of items efficiently

#

android's recyclerview is so nice to work with for stuff like this

supple whale
#

you mean dynamic lists?

#

idk what recyclerview is

#

yeah dynamic lists

royal nymph
#

take a lot of items and render them efficiently in complex layouts with smooth scroll, filtering, etc

supple whale
#
.parent {
  will-change: scroll-position;
  contain: strict;
}
#

thank you for coming to my ted talk

royal nymph
#

mariGrin well it's not that simple lmao

supple whale
#

it actually is

royal nymph
#

if you just render all elements at once it's gonna be uber laggy

supple whale
#

skia is actually that good

supple whale
#

tested this on lists with like 40k items

#

works like a charm

#

its like 80% of the perf of a dynamic list

#

for how easy it is, might as well

#

there's a CSS property for this

#

if you have fixed sizes

#

one sec

#

contain-intrinsic-height

#

pretty much does dynamic lists like that

#

with content-visibility: auto

#

that is

#

here

#

this is simply why web is better than android or switft, you dont need to bother with implementing dogshit like that for rendering UI, the web does it for you

#

and its craaaaaaaaaazy discord uses none of this

#

i had to write a fuckload of css just to unfuck the discord UI perf

royal nymph
#

extremely simple example: there's noticeable lag here when you click generate and only will get worse the more complex your layout becomes & styles are added

#

this just rendered everything and if you had 1000 notifications it would lag for like 2 seconds no joke

#

i migrated it to Discord's lazy scroller implementation TenmaStare

supple whale
royal nymph
#

okay so make it speeeedddy

#

show

#

also real word example is here https://badges.vencord.dev/explorer, the performance is really shitty

although the lag is kinda expected cause it's loading like 400mb worth of images (and this site is incredibly low effort)

supple whale
#

but yeah 99% of the perf here is the images, not the list

#

so its not even the same problem

royal nymph
#

is that with the images

supple whale
#

actually

supple whale
#

i added 2 0's to the list

#

and no problems

#

ah it finally died at 10000000

royal nymph
#

i added two zeroes and got this

#

and with one added zero theres incredible lag

supple whale
royal nymph
#

i see

#

thats also laggy for me tho

royal nymph
supple whale
#

yeah i gor the repro

#

yeah

#

i see your skill issue

#

you're thinking that the JS lagging is the UI lagging

#

the UI isnt frozen, its the JS chugging iterating the array

#

so this is a bad repro

supple whale
royal nymph
#

also those js measurements seem really off so the js thread seems to be freezing a lot

#

because it's rendering?

supple whale
#

no, because its iterating tru the array

#
<style>
    #container {
        height: 100vh;
        overflow: auto;
        will-change: scroll-position;
        contain: strict;
        content-visibility: auto;
        contain-intrinsic-height: 34px;
    }
</style>
<div id="container"></div>
<button id="generate">Generate</button>

<script>

    generate.onclick = () => {
        const data = Array.from({ length: 1000000 }, () => Math.random())

        const elements = data.map(n => {
            const p = document.createElement("p")
            p.textContent = n
            return p
        })

        for (let i = 0; i < elements.length; i += 100000) {
            const batch = elements.slice(i, i + 100000)
            container.append(...batch)
        }
    }
</script>
#

this will get the render down to 0

#

if u enable rendering -> frame renderign stats

#

and if u go on badges, and enable paint flashing

#

you'll see why that's lagging

#

you're also not using decoding="async" on the image

royal nymph
#

try scrolling fast you will get a lot of white screen

supple whale
#

not for me?

#

oh yeah

#

fucking duh

#

thats ur GPU running out of memory

#

any virtual list will have 1:1 the same problem

#

scratch that, no virual list will catch up to those speeds

#

but i'm scrolling at my display's vsync

#

aka 165fps

crude star
supple whale
#

no sir, virtual lists do not manage GPU memory

#

they cant tell skia to evict a bitmap

#

they can remove an element, which will schedule it for eviction

#

but that's still slower than simply scrolling it out of view

crude star
#

why would it not deallocate immediately

supple whale
#

because that's expensive

#

its always done in batches

#

thats how GC works sir

crude star
#

alright ma'am

supple whale
#

sir skia limits itself to <1.4GB of GPU bitmap memory

royal nymph
#

why

supple whale
#

worst part, its shared across all active chromium processes

#

so if you have, discord, steam open, its reduced even more

royal nymph
#

wait what ๐Ÿ˜ญ

supple whale
# royal nymph why

lord i wish i knew, i've been trying to change this behavior for 2 years now

royal nymph
#

i have so many chromiums open is that really why

supple whale
#

because gifs are horrendously inefficient when it comes to repaints

royal nymph
#

oh i know

supple whale
#

again, open ur badges thingy and enable paint flashing

royal nymph
#

ive had my share of pain with gifs

royal nymph
#

i dont mind it using up most of my resources for a better experience

#

that's what i bought it for

supple whale
#

fucking

#

mood

#

as

#

fuck

#

ive been fighting this for ages

#

and i still dont know the exact in and outs of it

#

but its horrendous

#

worst part? your shit will start blinking if ur fps is too high

#

and u have other views

#

its REALLY bad

royal nymph
# royal nymph no?

also i love how this kept stressing my pc until i closed the page just now even minutes after i stopped

royal nymph
#

i get that it's always gonna be laggy cause of rendering so many fucking images but man

#

why does it even take this long to load from disk cache

supple whale
#

on the img tag

#

and not using gifs

#

also if ur framework supports it, enhanced images

royal nymph
#

"my framework" bro it's just a single html file ๐Ÿ˜ญ

royal nymph
#

like this white empty bar at the top for a bit while it's loading

supple whale
#

LMAO

royal nymph
#

why does this happen

#

shit is already loaded in and should just show empty black border

supple whale
#

reload

#

and it probs wont look like that

royal nymph
supple whale
#

it for the most part works for me

#

scorllign cant keep up

supple whale
royal nymph
#

it wasnt like this without async decoding (instead of empty white bar it would show empty black borders)

supple whale
#

disable gpu acceleration and that will go away

#

:))))))))

royal nymph
#

really

supple whale
#

yes!

royal nymph
#

dude it got way worse lmao

supple whale
#

lmao srs?

royal nymph
#

this is with --disable-gpu

supple whale
#

X D?

gilded surge
#

at least vencord badge explorer uses less ram than nixos config options page

supple whale
#

enjoy linux i guess?

royal nymph
#

what does this mean

supple whale
#

that you manually override rgb profiles for ur chromium instance most likely?

#

most likely?

royal nymph
#

i def dont

supple whale
royal nymph
#

well i dont have those in chrome fwiw

supple whale
#

but yeah simply too many animated images at once

royal nymph
#

nah wtf just happened ๐Ÿ˜ญ

supple whale
#

and shit shits itself

royal nymph
#

the entire ui is fuckded up

supple whale
#

yes, contain: strict isnt easy to work with

#

and intrinsic size needs to be sthe size of the element and its padding

royal nymph
#

oh my god zooming out was a mistake

supple whale
#

you're legit working with the worst possible case scenario here

#

aka a fuckload of animated gifs

#

and massively oversized images

royal nymph
#

i should just merge them into one big spritesheet

royal nymph
#

all the new ones are sane (mostly webp and all 64x64)

#

should probably write a script at some point that optimises all the old ones but no point really

supple whale
#

just throw it into sveltekit real quick and use enhance:img

#

XD

royal nymph
supple whale
#

the UI isnt

royal nymph
#

ya

#

or do we just have to accept that

supple whale
#

uuuh

#

nuke all ur chromium processes and start ur chromium process with --force-gpu-mem-available-mb=9000 then use d3d9 ANGLE

#

will improve it a bit

#

not by much tho

supple whale
#

also disabling raw-draw might help

royal nymph
#

only 500x500
only 75 frames
still 15mb

god i love the gif file format

#

dude i converted it to webp with no other changes and it's just 1mb ๐Ÿ˜ญ

supple whale
#

convert it to a webm

#

legit will probs cost less to render

#

XD

royal nymph
#

nah bro this shit is put in a img tag

supple whale
#

worst part? still asaggy as the original gif

#

as it causes a paint update each frame

#

KEKW

royal nymph
#

anyway the explorer isnt that important anyway i just made it for fun

#

this is just for displaying badges in discord @steady cloak

royal nymph
#

40kb vs 15mb

#

if it really is less efficient than video why don't browsers make it more efficient

#

gif i get - gif is just inherently atrocious

but an optimised webp/avif?

supple whale
#

but not much

#

the repaints are the biggest problem

royal nymph
#

i will simply merge all images into one single sprite sheet smarty

supple whale
#

I honestly don't know what's the best solution here

royal nymph
#

idea for you: make the gif picker in discord less terrible

supple whale
#

most people just use videos for this since they are less laggy

supple whale
#

fixed

#

legit no cap

supple whale
royal nymph
#

i have like 500+ favourite gifs

#

when you scroll it's just blue loading for eternity

#

a while ago i thought about making a plugin that generates thumbnails for each gif and displays those while stuff is loading

woeful perch
#

Hiya !

jade stone
#

what is the rust equivalent of make -C someDir

tired vigil
lavish frigate
supple whale
#

oh yeah @royal nymph add loading='lazy' to the images too

royal nymph
#

yeah i did already ages ago

supple whale
#

hm android wack

austere idol
crude star
#

-C <DIRECTORY> Change to DIRECTORY before doing anything (nightly-only)

#

why is it nightly rust is so fucking dumb

solemn ravine
#

@woven mesa trying to add something that presses cmd v to paste into a field but seems like it doesnt work idk how to fix

woven mesa
#

unfortunately i cant test it and figure out what to do correctly for you

#

sorry oomf

solemn ravine
#

sad because the apis are super straight forward but idk whatโ€™s wrong with it

#

makes a source and disables keyboard events for the time being

#

then press keys

#

also maccy making an entire class just for AXIsProcessTrustedWithOptions is kinda funny

#

might as well just use AXIsProcessTrustedWithOptions only, itโ€™s just a bool

ivory heath
ivory heath
#

Most people and Linux distributions ship outdated versions of av1 encoders

supple whale
supple whale
ivory heath
#

I remember when Debian was shipping libaom 1.1 or whatever when 3.0 was about to release which was orders of magnitude faster

ivory heath
#

I said encoders

supple whale
#

ah

ivory heath
#

Avif isnโ€™t common cause to most people theyโ€™re expensive to make

#

And cheaper to just use more bandwidth

#

Because server hardware is typically old as shit

supple whale
#

no, avif isnt used because it doesnt have full browser support and because its slower to render as it causes more repaints

#

how difficult it is to make has NOTHING to do with it

#

for web def what matters is first contentful paint, and browser share support, legitimately nothing else matters, because those 2 things are DIRECTLY tied to revenue

#

4 cents of extra cpu time to encode an image is not the determining factor, trust me

ivory heath
supple whale
#

its also why progressive loading formats have been completly abandoned, becuase they imploded first contentful paint times

supple whale
#

that dense?

#

or just pretending?

#

discord isnt a website

#

its an electron desktop app

#

its constraints are different

#

discord has a pre-determined featureset and feature support since its always running the same chromium version

ivory heath
#

Discord electron has supported av1/avif for years

supple whale
#

great, cool

ivory heath
#

We used a bug to embed av1 for a long time sodalove

#

But yes discord is different, but most CDNs also have strict transcode deadlines as well

#

Because of the amount they deal with

supple whale
#

yep, is still is no way related to global adoption of AVIF

ivory heath
#

Then why donโ€™t they if 96% of all web users have browsers with support?

#

HTML supports built in fall backs

supple whale
#

thats the cool thing

#

the versions that support fallback support avif

#

the ones that dont support fallbacks dont support avif

#

its TRULLY that simple

ivory heath
#

So weโ€™re stuck using jpeg forever by that logic

supple whale
#

yes!

#

exactly!

#

its why webp failed

#

and one of the reasons why JXL failed

#

tho thats a MUCH longer list

#

google pretty much said that JXL and AVIF is effectively unusable because they implode first contentful paint times, and implode CPU on lower end phones, which are horrendously common

#

i could probably find the exact comment

#

its somewhere on web.dev

ivory heath
#

Webp wasnโ€™t a failure

supple whale
#

it is

ivory heath
#

All of Google uses webp, plenty of popular websites use webp

supple whale
#

they still use jpg

ivory heath
supple whale
ivory heath
supple whale
#

why are you making shit up lol?

ivory heath
#

Iโ€™m not?

supple whale
#

legit none of google images is webp, none of youtube is webp

#

they have PARTIAL support for those formats, but 80% of the time they fall back to jpg because they dont have most thumbnails in webp

#

on google images out of 230 loaded images only one was a webp

#

on yyoutube not a single one was, and half is avif, since only half are actually in that format

#

since youtube simply doesnt do avif for most video thumbnails

#

they also fall back to jpeg based on user agent

ivory heath
#

Correction. The thumbnail for the latest Mr beast video is avif

supple whale
#

cool

#

go back a year and not a single will be

ivory heath
#

Google mislabels the extensions for images

#

Theyโ€™re all typically webp or avif

supple whale
#

yes im going off the actual media type

#

not extension

#

im not stupid

ivory heath
#

Idk youโ€™re saying I make shit up when Iโ€™m right about YouTube

supple whale
#

and they miss-label the extension of the image, because the source image is still just a jpeg, they just trancode it on the fly based on user agent

ivory heath
#

Maybe a year ago it was different. Does not matter AkaShrug

supple whale
#

motherfucker are you reading what im saying

ivory heath
#

Google uses their own image formats itโ€™s amazing

supple whale
#

thats the sqp based converted image

ivory heath
#

Yes.

supple whale
#

and the source image is a jpg

#

they convert it on the fly

#

based on browser's support

ivory heath
#

You said YouTube does not use avif/webp AkaShrug

#

They do use it

supple whale
#

yeah the source images are still jpg mate

ivory heath
#

Why does that matter?

alpine pecan
#

@alpine pecan, to be frank you are an annoying, rash, and intolerable person to talk to.
I'm far more invested into the project you have been seeing me complain about in #๐Ÿช…-progaming than you ever will be and i know more than you ever will.
I'm not sure how the hell a person like you who is so insufferable can exist.

supple whale
#

...?

#

are you insane or insane?

#

they cant use avif, because browsers dont support is simply

#

they always need to use jpeg

#

they simply detect my browser supports it

#

the source data is still jpg, it still operates on jpg

#

because they cant abandon it

#

because avif isnt good enough to replace jpg

ivory heath
#

This is how internet works

#

Deleting the original jpg also means they add generation loss when AV2 releases in the next 1-2 years

#

They STILL use it for users who can see it

supple whale
#

yes

#

but we're still gonna be using jpgs in 2 years

#

because webp and avif will never be able to replace it

#

thats why those formats failed

pearl dawn
#

you are both stupid

ivory heath
#

Weโ€™re always going to have to use JPEG but as a fallback.

pearl dawn
#

you should be using protobuf instead

ivory heath
#

We can use anything better for 90% or all users

#

FALLBACKS are a good thing

#

I donโ€™t think they should go away

supple whale
#

youtube is giga specific because it doesnt run on mobile

#

which is likely why google decided to use avif only on youtube

#

and nowhere else

ivory heath
#

Even on mobile they serve avif

supple whale
#

yes but the mobile userbase is 0.1% of what google image has as the mobile userbase

pearl dawn
#

also youtube does use webp for things like those animated thumbnail previews

ivory heath
#

Jop

supple whale
#

and it still takes ages to adopt it

pearl dawn
#

avif is the newer format so it's the one they predominantly use

ivory heath
#

Youโ€™re saying adoption is the total destruction of jpeg and itโ€™s not

pearl dawn
#

googles image proxy encodes as avif by default iirc

ivory heath
#

Discord even on mobile uses webp for thumbnails sodalaugh

pearl dawn
#

jpeg is never dying out lol

ivory heath
#

Yeah

pearl dawn
#

every consumer camera I know outputs jpeg

supple whale
#

google photos does webp for 20px previews, and jpeg for everything else

#

because webp is too computationally expensive to allow on mobile

pearl dawn
#

every phone automatically converts to jpeg when you try to use pictures taken in anything but the built in gallery

ivory heath
#

It even has causes some peoples libraries to become corrupted

supple whale
nimble minnow
deep mulch
#

my camera has option to save in HEIF

supple whale
pearl dawn
#

My friends are super into photography and their cameras output raws and jpeg by default

#

because jpeg "just works" on everything

ivory heath
#

Hopefully eventually JpegXL not jpeg

deep mulch
ivory heath
#

Do they even use 10 bit jpegs

supple whale
pearl dawn
#

jpeg xl isn't ever happening unless chrome adopts it

ivory heath
#

Look at the mailing list

#

Libjxl is too big and.. buggy

supple whale
ivory heath
#

Memory consumption for encoding yes thatโ€™s the biggest one /j

supple whale
#

nope

deep mulch
#

consume my memory

ivory heath
#

What is it then oh great oracle

supple whale
#

decode times, cpu times for decoding, repaints caused during decoding, long large contentful paint times

#

keep in mind they are targetting android 8 phones from india with e-waste for CPUs with 3G internet

ivory heath
#

Avif is only slightly faster than jpegxl and thatโ€™s only 8bit avifs

#

Enter the domain of HDR and JpegXL starts to win or anything > 8bit really

#

JpegXL internally represents everything as fp32

supple whale
#

hm i see the problem

#

you're back in your "lets debate the best format in the world" mode where u ignore all other parts of the conversation, where im saying "whats the most viale format for websites"

#

JXL is good, but its not a good fit for the web

ivory heath
supple whale
#

JXL decode times are so bad, this exists as an option for google's image encoder

ivory heath
#

Itโ€™s a library feature in libjxl and svt av1 has a similar feature called fast decode

#

The main problem why avif is faster is chroma sub sampling and unfortunately 444 isnโ€™t supported in the main profile

supple whale
#

man is still talking to himself about the 2 slowest decoding formats

#

nuts

ivory heath
#

Iโ€™m sorry you canโ€™t fathom anything outside of your world

supple whale
#

yes

#

because my world is web development

#

your world is "my best media format in the world"

ivory heath
#

Itโ€™s not. If it was then Iโ€™d be talking about VVC sodalaugh

#

Both avif and JpegXL have their place. Everyone on the chromium team agrees as well as almost every other person in web dev that actually knows a thing or two about image formats

supple whale
#

yeah they do have their hyper specific use cases

nimble minnow
#

never seen anyone actually use avif

supple whale
#

but they simply wont superseed the most commonyl used formats

#

it wont happen

ivory heath
#

Nothing will replace jpeg not even PNG

#

it will see usage tho

supple whale
#

png does replace jpeg, its pretty much a back and forth

#

the both have the same support

deep mulch
#

jpeg isn't gonna go away for a long time probably never

supple whale
#

jpeg is better for compression, png is better for high quality and well... alpha

supple whale
#

15 years and only like 3 years ago did all browsers fully support it

deep mulch
#

oh I thought webp was newer than that

supple whale
#

I think?

#

yeah 2010

#

i remembered right

#

ff added support after 9 yeasr XD

#

safari after 12

#

nuts.

ivory heath
#

Cause Mozjpeg is or was better than webp

#

It never had a reason to exist

#

But unfortunately most people donโ€™t use mozjpeg

nimble minnow
supple whale
#

its still jpeg

#

doesnt change anything

nimble minnow
#

saw the article yesterday but i forgot the link

supple whale
#

it still has all the limitations of jpeg

ivory heath
#

Webp has more limitations than JPEG

supple whale
#

what encoder u use doesnt matter

ivory heath
#

No 422 no 444

supple whale
#

it could lick my balls for all i care

supple whale
#

like trully doesnt matter

#

it has alpha, animations and better compression ratios

#

so fuck cares

#

web isnt about lossless quality

ivory heath
supple whale
#

its about loading content quickly

supple whale
#

sometimes yes sometimes no

#

more often than not, yes

ivory heath
#

When webp first release jpeg was still the winner

#

15 years later webp wins by 10%

#

In MOS rankings

#

Not 30-50 like google claimed

#

Fucking 10

ivory heath
#

Or what format itโ€™s in

#

I donโ€™t think 10% is worth adding webp support

ionic lake
#

webpiss

ivory heath
#

True.

#

I will keep using the browser on my Nintendo DS so the unknown can never adopt anything better than jpeg

#

Or IE6 in a vm works too

frosty skiff
#

nice banner

spark tiger
#

stole*

frosty skiff
#

thanks I made it myself

#

no need to thank me

deep mulch
#

@young flicker

frosty skiff
valid jetty
#

@hoary sluice @deep mulch @royal nymph

valid jetty
#

obviously

deep mulch
#

I love

#

@valid jetty I have funny idea im gonna make

#

@valid jetty IR data transmitter and receiver for transmitting files and whatever

supple whale
#

just like off to the side

#

XD

deep mulch
#

will be fun i think to experiment with different protocol ideas

#

@valid jetty

supple whale
#

like 4-10 kbps

#

with a 50% error rate

#

idk bro

deep mulch
#

nop

#

i estimate I can get maybe at least 50 kbps

#

with error checking and possibly correction

supple whale
#

i estimate at best 10kbps

#

either way 10 or 50, its not usable speeds XD

#

do wifi

deep mulch
#

nop

#

too complex

#

probably even 1 mbps is possible with the right driving circuitry

hoary sluice
winged mantle
#

TIL you can do this in c

typedef struct {
    Color color;
    bool bold;
} SuperPrintOptions;

#define super_print(text, ...) _super_print(text, (SuperPrintOptions){ __VA_ARGS__ })
void _super_print(const char *text, SuperPrintOptions opt);

// somewhere in code...
super_print("hello world!", .bold = true, .color = Color_Green);
#

just like python

ivory heath
#

Yeah the C preprocessor is very powerful.

winged mantle
#

i never thought of this though...

#

or used varargs

#

i'm not a huge fan of macro magic

#

but this is cool

#

it's enough to confuse vscode though..

#

autocompletion doesn't work

valid jetty
# winged mantle TIL you can do this in c ```c typedef struct { Color color; bool bold; }...

one trick i found useful was this

#include <stdio.h>
#include <stdbool.h>
#include <stdarg.h>

typedef struct {
    int value;
    bool __last;
} Foo;

void _print_Foos(int _, ...) {
    va_list args;
    va_start(args, _);

    for (;;) {
        Foo foo = va_arg(args, Foo);
        if (foo.__last) break;
        printf("Foo { value = %d }\n", foo.value);
    }

    va_end(args);
}

#define print_Foos(...) _print_Foos(0, __VA_ARGS__, (Foo){ .value = 0, .__last = true })

int main() {
    print_Foos((Foo){ .value = 3 }, (Foo){ .value = 5 });
    print_Foos((Foo){ .value = -42 }, (Foo){ .value = 32 }, (Foo){ .value = 39 });

    return 0;
}
#

only works for single typed structs

#

but pretty awesome

crude star
#

insane

#

use (Foo[]) {} and sizeof

valid jetty
#

i mean yeah you can do that too

nimble bone
#

@valid jetty add // @ts-ignore to Elle

deep mulch
#

@valid jetty make coal

winged mantle
#

does the abs function in c give you abs

valid jetty
crude star
#

no need for vaargs...

valid jetty
#

thats boring..

deep mulch
#

@valid jetty add fast math to elle

#

use avx512

supple whale
#

fast math doesnt use avx512

#

it just lowers precision

#

no?

deep mulch
#

elle needs the fastest implementation

supple whale
#

you dare sugggest it to have worse compatibility?

deep mulch
#

yes

#

anyways won't matter when elle works for java applets and runs on the jvm blobcatcozy

#

@valid jetty Elle JVM NOW

ivory heath
#

And native things like reflection

jade stone
#

what is the proper way to store callbacks in rust

example of what i mean in c++

static std::vector<std::function<void()> callbacks;

void add_callback(std::function<void()> callback) {
  callbacks.push_back(callback);
}

int start_thread() {
  new std::thread([] {
    while (true) {
      // wait for something
      for (const auto& cb : callbacks) {
        cb();
      }
    }
  });
}
frosty obsidian
#

fast math (only integer arithmetic)

jade stone
#

(if this can't be done in safe code then rust is insane)

winged mantle
valid jetty
#

just pass it around

jade stone
valid jetty
#

@jade stone ```rs
use std::sync::{LazyLock, Mutex};

static CALLBACKS: LazyLock<Mutex<Vec<Box<dyn Fn() + Send + Sync>>>> =
LazyLock::new(|| Mutex::new(Vec::new()));

fn do_x() {
let callbacks = CALLBACKS.lock().unwrap();
for callback in callbacks.iter() {
callback();
}
}

fn main() {
CALLBACKS.lock().unwrap().push(Box::new(|| println!("hello world!")));
CALLBACKS.lock().unwrap().push(Box::new(|| println!("hello sadan!")));
do_x();
}

#

its a LazyLock not LazyCell

#

but yeah

#

this is so fucking terrible to use because rust needs to make sure the things are thread safe

valid jetty
#

@jade stone you can also do this if youre sure your functions wont capture anything

use std::sync::{LazyLock, Mutex};

static CALLBACKS: LazyLock<Mutex<Vec<fn()>>> = LazyLock::new(|| Mutex::new(Vec::new()));

fn do_x() {
    let callbacks = CALLBACKS.lock().unwrap();
    for callback in callbacks.iter() {
        callback();
    }
}

fn main() {
    CALLBACKS.lock().unwrap().push(|| println!("hello world!"));
    CALLBACKS.lock().unwrap().push(|| println!("hello sadan!"));

    do_x();
}
jade stone
#

so hrug

#

ill try it

valid jetty
#

fn() is just a function pointer, Box<dyn Fn()> is a capturing lambda trait item

valid jetty
jade stone
#

ah so fn() is like void (*)() and Box<dyn Fn()> is like std::function<void()>

valid jetty
#

i guess so yeah

#

yeah thats exactly correct

#

Box<T> is what means "this heap allocates"

jade stone
#

yeah i knew that

valid jetty
#

rust closures dont usually heap allocate, however since theyre being stored, their captures must live long enough and be sharable between threads sooo

jade stone
#

and i assume Mutex is just an raii mutex wrapper

valid jetty
#

in normal sane code youd just see Fn(i32) -> i64 as a type

jade stone
#

but i've never heard of lazylock

valid jetty
#

basically all you have to know lol

jade stone
#

is a lazycell just a lazy value?

valid jetty
#

yeah

jade stone
#

i'll do this after i finish this level of one shot

valid jetty
#

before rust had this, i did it like this

#[macro_export]
macro_rules! global {
    ($name:ident : $type:ty = $value:expr, $getter:ident) => {
        pub static mut $name: Option<$type> = Some($value);

        macro_rules! $getter {
            () => {
                unsafe { $name.unwrap() }
            };
        }

        #[allow(unused)]
        pub(crate) use $getter;
    };
}
#

so just using unsafe lool

jade stone
valid jetty
#

well i technically still do it like this

#

i didnt update yet

#

thats gonna be part of my migration to rust 2024

valid jetty
#

i think i stole it from you โค๏ธ

royal nymph
deep mulch
#

@valid jetty

#

@valid jetty rosinga

ornate quiver
jade stone
#

is it possible to get the value of the input to a match clause in the catch all branch without using a variable

#

something like this

#

status is a massive enum

crude star
#

error_code =>

#

else is zig fr

jade stone
#

i didn't know the exact syntax

crude star
#

what then

jade stone
crude star
#

communication

twin matrix
jade stone
#

python is evil

#

give me back my braces

twin matrix
#

ok

jade stone
#

AAAAAAA rust docs are insane

deep mulch
#

@jade stone you love rust

jade stone
#

a bit less than c++

deep mulch
#

@jade stone help

#

my server is about to explode i think

#

notihng responsive

jade stone
#

uhhh ssh in

#

and run journalctl -xef

deep mulch
#

ssh froze

jade stone
deep mulch
#

dont have

jade stone
deep mulch
#

buy for me blobdamncozy

#

bru

#

i ssh'd another terminal and it froze too

jade stone
#

go reboot

deep mulch
#

guhhh

#

its in the middle of an upgrade

#

oh my god

#

literally every ssh session freezes after like 20 seconds

#

this is so annoying

jade stone
#

@deep mulch

#

it's 1 line in c

deep mulch
jade stone
#
XInternAtom(display, atom_name, False);
deep mulch
#

so much simpler

jade stone
#

yop

#

and blazingly fast

deep mulch
#

STOP TIMING OUT OMG

#

????

#

i dont get it

#

literally every time i ssh it freezes several seconds later

#

then im just stuck in this useless frozen ssh session

#

@jade stone why is it preferring the ipv6 for lan

#

?????

fleet cedar
#

Antway it is one line in rust too conn.intern_atom()?.reply()?.atom

jade stone
#

rust woozy

hoary sluice
jade stone
hoary sluice
#

do you use this unironically

jade stone
crimson sparrow
#

Itโ€™s great

jade stone
#

I think I'd pay like $50 if someone made ligatures for it.

alpine pecan
jade stone
alpine pecan
#

dumb

jade stone
#

Type aliases often convey a lot of meaning in their names

frosty obsidian
#

typealiases are a very good way to self document code

fleet cedar
#

As clippy points out

#

Why are you not running clippy

crude star
#

rust api suffers from perl syndrome ๐Ÿ’”

hearty lintel
crude star
#

"There's more than one way to do it"

#

that's perl's slogan

valid jetty
fleet cedar
#

No, .map().flatten()

valid jetty
#

so and_then == flat_map???

fleet cedar
#

It's called and_then on Result/Option/Future and flat_map on iterators

valid jetty
#

ohhh i see

fleet cedar
#

Both are traditionally called >>=

valid jetty
#

that makes sense

valid jetty
fleet cedar
#

And in nvim devicons, and powerline-style prompts

crude star
#

he's referring to the fact it's comic sans

clear bison
#

is it possible to modify and load plugins into discord web on firefox

#

like saving/loading plugins on local files and running themes in real-time

limpid mica
#

i need someone to talk about x86 instrinsics with

#

mostly optimizing codesize

#

rather than performance

placid cape
#

you can create functions in css

winged mantle
#

is it weird that i'm wishing rust had templates

lavish frigate
#

??

winged mantle
#

like with duck typing like c++

fleet cedar
#

That's what macros are for

#

I hate c++'s duck typed templates

winged mantle
#

a library i'm using has two types which happen to have the same methods but it's not shared with a trait

#

rust needs templates

#
template <typename T>
fn quack(duck: T) {
    duck.quack();
}
fleet cedar
#

You could also try writing code that doesn't suck

winged mantle
#

it's the libraries fault though

#

or maybe not

#

library limitation

lavish frigate
winged mantle
#

that function won't automatically support any type that has a method called quack though

fleet cedar
#

Yep, because function names mean nothing

#

What would you do if someone passes you a Doctor, which also is a quack?

winged mantle
#

solution: make function names as descriptive as possible

#

put the whole function body as the name

fleet cedar
#

I think Duck::quack is a very descriptive name

winged mantle
#

with illegal chars replaced

lavish frigate
winged mantle
#

wait i guess rust allows you to implement triats for foreign types

#

a feature i'm not too fond of but oh well...

fleet cedar
#

That's one of traits' biggest advantages over interfaces

shrewd canopy
lavish frigate
shrewd canopy
winged mantle
lavish frigate
#

are templates not basically just generics

fleet cedar
winged mantle
#

i just... basically everything about go aligns with my opinions and go doesn't have this xd

#

go is always right

fleet cedar
#
impl Deserialize for BaseChannel
impl<K, V> Deserialize for QMap<K, V>
``` etc
crude star
fleet cedar
#

But there is nothing in that code that asks for quacks like a duck

#

It only asks for quacks

shrewd canopy
crude star
#

no biggie

shrewd canopy
#

Glad i can have magic like complete math at compile-time

crude star
#

real answer: the return type is important too

#

let quack: Quack = doctor.quack()

#

quacks like a duck blobcatcozy

lavish frigate
#

if quack returns something im blowing something else up i expect that to directly print to stdout if it does anything else someone will die

lavish frigate
winged mantle
#

ok i guess they're cool...

valid jetty
#

look at this

fn Iterator::flat_map<T, U, AnyEnded>(Iterator<T, AnyEnded> self, fn(T) -> U cb) {
    return self
        .map(cb)
        .map(fn(x) x.__iter__())
        .reduce(fn(acc, it) acc.chain(it))
        .unwrap_or_else(fn() Iterator::empty());
}
#

if it wasnt duck typed, x.__iter__ would NEED to return Iterator<U, ???>

#

however if youre returning something like a hashmap, the result is Iterator<(T, U), ???>

#

its helpful to have duck typing in some cases