5 ms·
This is quite intriguing. In Ardour we have a 63 bit time type that uses the high (MS) bit to indicate whether it is a value in the audio time domain or the mus
by PaulDavisThe1st 3y ago
This is quite intriguing. In Ardour we have a 63 bit time type that uses the high (MS) bit to indicate whether it is a value in the audio time domain or the music time domain.
It did not occur to me to use the low (LS) bit as the tag. I wonder if the ocaml approach is faster or slower. We're not doing garbage collection, so the cool "pointers are free" aspect isn't relevant.
We're also even slower than the ocaml-style tagging for a different reason: we force atomic loads & stores because our values are by definition read/write from any number of threads.
[ EDIT: if anyone wants to tell me that my coding is crap and I could get a 4x speedup by doing <X>, please do: https://github.com/Ardour/ardour/blob/master/libs/pbd/pbd/int62.h https://github.com/Ardour/ardour/blob/master/libs/pbd/pbd/in... ]
- gpderetta 3y agoWhy the alignas 16 for an 8-byte type? In the wasted 8 bytes you could easily fit a type discriminant and a version counter/consistency check for to avoid teared read/writes (assuming you can't rely on atomic 128 bit access).
- PaulDavisThe1st 3y agoAnother excellent question that I regret not having an answer to. I'll have to investigate both the git history and also check the performance results of dropping that. EDIT: I think it may be related to this (now fixed) gcc bug:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65147 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65147
- nikic 3y agoWhy does the flag use different representation depending on whether the value is negative?
- PaulDavisThe1st 3y agoI will try to remember. Vague recollection was that it was necessary to get something obvious to work.
- aydyn 3y agoyoure making a real good case for better documenting one’s code right now
- tomcam 3y agoDo you think Paul doesn’t want to comment his code perfectly? Is it your thought that he has unlimited time to create complex free software up to your coding standards? You’re making a really good case for flagging comments, which I almost never do.
- PaulDavisThe1st 3y agoThanks for the defense, but to be honest I think GP has a point. Why on earth I would have used 2's complement conventions for what is truly just a boolean/bistate flag is far from obvious, and it ought to be (better) commented. One thing I would say in my own defense is that one aspect of remote-distributed cooperative development is that sometimes the conversations you have with others (e.g. on IRC, or mattermost or even discord if that's your thing) can sometimes feel as if you've just "written the documentation", even though it will generally vanish into the ether. I think that is what happened here. I remember discussing it with others on our IRC dev channel, but I don't keep logs.
- tomcam 3y agoYou’re a champ and I love you for that, but it’s no excuse for that kind of rudeness. There is literally no easier nor shallower critique in programming than one should’ve commented a little better. You rock, literally!
- aydyn 3y agomate, you need to relax fr. Its just a friendly jib
- tomcam 3y agoOops. Now I feel bad—my apologies.
- twoodfin 3y agoPure intuition, but if you don’t care about tagged pointers, I’d guess your approach would at worst break even and might even win some microbenchmarks: Flipping bits via a mask is cheaper transistor-wise than a shift, and a very cursory review of the latest Intel pipeline data from the canonical resource[1] suggests that this is reflected in the degree of macro-op fusion and number of execution units available for shift vs. bitlogic. See page 166 in particular. [1] https://www.agner.org/optimize/microarchitecture.pdf https://www.agner.org/optimize/microarchitecture.pdf