Skip to the content ForoHackers
Log inJoin

Rust 1.80: dos dibujos me piden la misma tabla de senos. Se ha presentado un solo cocinero

Maintenance and legacy codeMeasurement and evaluationRust
#15365 · · Quote · Report

En la versión estable de hoy tenemos LazyLock y LazyCell. Para un dibujito doméstico probé una sola LazyLock estática: el primer dibujo pide la tabla y la inicializa. El segundo usa esa misma tabla. Al medir el tiempo del primer fotograma estaba incluyendo el coste de prepararla. Adivinad en qué fotograma he fundado mi carrera de saboteador de estadísticas.

#15608 · · Quote · Report

Use the same static for both drawings. A counter inside the initialisation function answers a narrower and much more useful question than "was frame one slow". Two different lazy values are allowed to initialise twice.

#15609 · · Quote · Report

Eso es lo que quería distinguir. En pequeño: static TABLE: LazyLock<Vec<f64>> = LazyLock::new(build);. Llamo a dos funciones de dibujo que consultan TABLE. Una línea de aviso dentro de build. Sale una vez, no una por función.

#15610 · · Quote · Report

If we draw one picture to warm it first, then publish figures for the next hundred, do we get a bronze medal in the extremely specific event of Not Drawing The First Picture?

#15611 · · Quote · Report

eso no es trampa si cuentas qué mercado estás vendiendo, po. a mí, tío, en una vista interactiva sí me importa cuándo aparece por primera vez. a quien ya la tiene abierta le importan los tirones después.

#15612 · · Quote · Report

Y tampoco he demostrado que todo lo que haga con datos mutables después sea seguro. La prueba cuenta inicializaciones de ese objeto. No me regaléis un premio por una pregunta que ni he hecho.

#15613 · · Quote · Report

Yes. Pure one-off initialisation plus later reads is easy to reason about. If the actual application wants a changing table, it needs to say how those changes are coordinated. Different question, different bug report.

#15614 · · Quote · Report

Dejé dos cifras separadas: primera apertura y dibujos posteriores. El link de la estable es https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html . El gráfico de la primera apertura me sigue dejando fatal; probablemente es el que más me gusta.

#15625 · · Quote · Report

Me dejé el contador al rehacer la prueba y creí que se había inicializado cero veces. No, hostia, sin contador lo único que sé es que alguien ha borrado el contador.

#15626 · · Quote · Report

jajaja pero ahora tu benchmark mide lo que tarda el investigador en encontrar su propia chapuza. eso sí que no lo optimiza Rust todavía.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply