!NnQKKHycLsnvUKYsfE:matrix.org

Wgpu Random

176 Members
Off-topic18 Servers

Load older messages


SenderMessageTime
18 Jul 2023
@m4b:matrix.orgm4boh yea why don't i just option box06:02:40
@m4b:matrix.orgm4bhahaha06:02:43
@m4b:matrix.orgm4byou see my head has been stuck in this unsafe rust land last 5 hours, i just assumed it had to be raw pointers06:03:02
@cwfitzgerald:matrix.orgcwfitzgeraldI don't think I've ever actually directly used maybe uninit06:04:03
@m4b:matrix.orgm4bi have to look at it though, there might be a reason; it is super gnarly low level code06:04:07
@cwfitzgerald:matrix.orgcwfitzgeraldIt mainly comes up in container implementations 06:04:23
@m4b:matrix.orgm4byea this is a container06:04:30
@cwfitzgerald:matrix.orgcwfitzgeraldhttps://doc.rust-lang.org/nomicon/unchecked-uninit.html might be worth a read06:05:39
@m4b:matrix.orgm4byes yes06:05:51
@cwfitzgerald:matrix.orgcwfitzgerald(similarly their section on impling Vec06:06:13
@m4b:matrix.orgm4bthat section is literally what i was doing06:06:32
@m4b:matrix.orgm4balmost verbatim taken; the problem i had was i had a final leak when deallocating the entire thing; and i had no real way to know which things were allocated or not (Box not being null (even using std::mem::zeroed is a compile time error now!))06:07:49
@m4b:matrix.orgm4bi could deallocate them when particular elements were removed, but if you just dropped the whole thing, anything that wasn't explicitly removed was leaked06:08:19
@cwfitzgerald:matrix.orgcwfitzgeraldYou're making a vec box T basically? 06:10:01
@m4b:matrix.orgm4bthey're like chunks of arrays of recursive nested arrays of boxes that are dynamic, yes06:10:48
@cwfitzgerald:matrix.orgcwfitzgeraldWhosy what a what06:11:19
@m4b:matrix.orgm4beach child has a mask group, and this extra control information determines what goes in where, and if it's 0, they get deallocated06:11:28
@cwfitzgerald:matrix.orgcwfitzgeraldOh I think I know what you're getting at06:11:51
@cwfitzgerald:matrix.orgcwfitzgeraldCan't you look at the mask info to know when to drop things? 06:12:09
@m4b:matrix.orgm4bi thought about doing that but i wrote this code like 3 years ago and i'd have to reverse engineer the masking stuff; it felt easier to just check if the allocated things were 0 (or None, now)06:12:56
@m4b:matrix.orgm4bi feel like i was on drugs or something when i wrote it, i don't even recognize this strange persons writing :P06:13:19
@cwfitzgerald:matrix.orgcwfitzgeraldProbably not worth the bother anyway06:13:51
@cwfitzgerald:matrix.orgcwfitzgeraldCpus churn through branches like nobody's business 06:14:06
@m4b:matrix.orgm4b well its still a branch anyway looking up the child information, right? so i figured it shouldn't matter much. i'm actually more worried about the branching on accesses with unwrap now 06:14:56
@m4b:matrix.orgm4b
            #[inline(always)]
            fn set_mask(storage: &mut [u32], i: usize, x: bool) {
                const BITS_U32: usize = 32;
                let w = i / BITS_U32;
                let b = i % BITS_U32;
                let flag = 1 << b;
                // i believe we can unsafe access due to i being shifted internally
                let val = if x {
                    storage[w] | flag
                } else {
                    storage[w] & !flag
                };
                storage[w] = val;
            }

like this is the masking code, wtf, i don't even know; i'd have to invert this and get a list of children mapping to the array indexes, seems like a lot of trouble

06:16:08
@cwfitzgerald:matrix.orgcwfitzgerald
In reply to @m4b:matrix.org
well its still a branch anyway looking up the child information, right? so i figured it shouldn't matter much. i'm actually more worried about the branching on accesses with unwrap now
Unwrap_unchecked?
06:20:05
@m4b:matrix.orgm4bfor someone who says they don't write any unsafe, you sure do seem to know some unsafe stuff 😆06:20:44
@cwfitzgerald:matrix.orgcwfitzgeraldI said I don't use maybeuninit :) 06:21:10
@m4b:matrix.orgm4bah06:21:24
@m4b:matrix.orgm4bi'm more of a transmute kind of person anyway :P06:21:37

Show newer messages


Back to Room ListRoom Version: 5