HNHacker News
TopNewBestAskShowJobs

zwegner

1,066 karma · joined February 12, 2013

https://github.com/zwegner https://twitter.com/zwegner zwegner@gmail.com
submissionscomments
zwegner··on Mathics – A free, light-weight alternative to Mathematica
They're certainly meant to be entertaining. I really don't think they're meant purely as jokes, though. And which are the trick questions with trivial answers? I can't recall seeing any of those.

Any question that is poorly specified can generally be augmented with reasonable assumptions or approximations, so that an AI could potentially give an answer. W|A is a natural language interface after all, and seeing all the "W|A can" posts on the account shows that it can certainly answer questions that don't have a precise mathematical definition. The intent behind each question is usually clear to me, and to have an AI that is useful to humans, we expect the AI to infer this intent and make reasonable assumptions.

Even "focal length of the Eye of Sauron" could conceivably be given a rough answer from estimates of the eye's geometry (either from descriptions in the books, or a visual comparison with other objects of approximately-known size in the movie).

The interesting part of the account IMO is thinking through how a hypothetical AI might answer each question. Take the latest question, "derivative of the shore length of Tasmania with respect to ocean depth". This is poorly specified in that "Tasmania" only exists for ocean depths that are low enough to not completely cover it and high enough to not have another land mass connect to it, and I'm sure there's tons of other assumptions that humans would implicitly make in answering a question like that. But the topography of the Earth is approximately known, and I can see how a rough answer could be calculated. Thinking through these assumptions, and comparing current technology with what we'd expect from an AGI, is quite illuminating, and is what makes that Twitter account so awesome IMO.

zwegner··on Mathics – A free, light-weight alternative to Mathematica
And I'd like to plug my favorite twitter account, Wolfram|Alpha Can't: https://mobile.twitter.com/wacnt/

It's a collection of queries that an AI could answer in theory, but are (probably) far beyond current technology. The questions are generally just super interesting.

Here's a few recent samples: "derivative of the shore length of Tasmania with respect to ocean depth" "total area enclosed by whole notes in a typical printing of the Brandenburg Concertos" "total duration of watch adjustments made by people changing time zones per day, if everyone had a watch and adjusted it" "volume of ink saved by the Times per year if they switched to American spelling"

zwegner··on Cog: Use pieces of Python code as generators in your source files
I wrote something very similar some years back: https://github.com/zwegner/prethon/

I can't remember if I saw Cog first, and wrote a different version that fit my needs better, or if I only found Cog afterwards...

It uses a more PHP-esque syntax for inserting Python code. It has inline expression syntax, and quote functions, which IMO make it nicer than Cog for using as a code preprocessor--it's easy to make e.g. function specializations, or loop over code blocks. It's not very well documented though, and is probably missing some nice features.

zwegner··on PEP 584 – Add + and – operators to the built-in dict class
While I agree with you, I will note that even set union in Python is not commutative. a | b should equal b | a in the sense of __eq__, but the actual objects in the result set depend on the order of the arguments (and in the opposite way from dict + dict). This happens with objects that are distinct but compare/hash equally (x is not y and x == y). Whether that actually matters for any useful program is another story...

Dumb program to illustrate this point:

    class Dummy:
        def __init__(self, value):  self.value = value
        def __repr__(self):         return 'Dummy(%s)' % self.value
        def __hash__(self):         return 0
        def __eq__(self, other):    return True

    a = {Dummy(0)}
    b = {Dummy(1)}
    print(a | b)
    print(b | a)
    print(a | b == b | a)
zwegner··on AVX512 VBMI – remove spaces from text
It actually would've been during my time at Intel working on the graphics stack for Larrabee, in the 2010-2011 timeframe--vcompressd was part of LRBNI. I was mainly doing infrastructure/compiler/optimization type work, and not much graphics stuff, so I can't recall using the instruction personally, but pretty sure it was used in various places around the stack.
zwegner··on AVX512 VBMI – remove spaces from text
Wow, not bad! I'm looking forward to the writeup.

I'm still thinking about this one. It seems that ~.5 cycles/byte is slower than it should be. There's 6 pext->kmovq->vpaddb chains, where the pexts and kmovqs are all independent and can be pipelined. One chain should be 3+2+1 cycles, so all 6 should be 11 cycles. Agner Fog's site doesn't have information for vpermb yet, but a Stack Overflow comment says it's 1 cycle (which is rather surprising, that's 64 64->1 8 bit muxes--lots of silicon!). The latency on most other instructions can be hidden.

I updated my code with a couple minor optimizations, that at least lead to some nicer assembly output:

Getting rid of the if (mask) branch--it should almost never be false in real code (and never is in the microbenchmarks).

Inverting the mask during the comparison:

        uint64_t mask = _mm512_cmpneq_epi8_mask(input, spaces)
                      & _mm512_cmpneq_epi8_mask(input, NL)
                      & _mm512_cmpneq_epi8_mask(input, CR);
...then the mask computation gets a lot cleaner, since there's now just three chained vpcmps (though this might lose a couple cycles or so because of the dependent 3 cycle latencies. Not sure how to trick gcc into using parallel vcmps with the ands on GPRs...). But we also save the mask = ~mask and the subtraction from 64 of the popcount.

All in all, speed-of-light for this code should be 3*3+2+11+1=23 cycles per iteration (if I'm counting everything properly), and probably even faster from pipelining between iterations. I hope it should be a bit faster than the 32ish that the old version was using.

zwegner··on AVX512 VBMI – remove spaces from text
Hi there! Thanks for the nice writeup and successfully nerd-sniping me! :) You can absolutely use the code.

Good tip on the SDE too. I had heard of it but didn't realize it was so lightweight, dynamically patching the binary to emulate only the needed instructions. Cool!

zwegner··on AVX512 VBMI – remove spaces from text
Oh sweet! That's an awesome instruction. I'd imagine that would be useful for lots of things. I believe I've seen vcompressd before, but totally forgot about it.

Unfortunately it looks like the byte-wise version is part of AVX512-VBMI2, which won't be out until Ice Lake...

zwegner··on AVX512 VBMI – remove spaces from text
Hmm, interesting idea.

The main problem I see is that PEXT can only move bits from within an 64-bit operand, so we can't operate on the 512-bit vectors anymore, AFAICT. We'd have to split the loop up into 8-byte chunks instead, and expand the mask from 1 to 8 bits per comparison, so PEXT pulls out all the bits of each character (e.g. a 4-bit mask 1011 becomes 0xFF00FFFF). This mask computation could be done in 512-byte chunks, but we'd have to split the original 1-bit mask up into 8-bit slices that each get popcounted individually (either in a 256 byte table lookup or with the popcount instruction). That's just so we know how much to increment the pointer between each 8-byte chunk.

All in all, I think the 8 popcounts + 8 PEXTs would make it slower than the full 512-bit version (there's only one PEXT execution unit on Skylake X chips). It might be competitive on machines without AVX-512, though. I'll try out some code--I should actually be able to run this one :)

zwegner··on AVX512 VBMI – remove spaces from text
Interesting, I started out thinking along these lines, but once I figured out I could use PEXT, I just went with that.

I think this approach needs some tweaks, though. Mainly that the vpermb at the end is the inverse of what we want--the bytes at dense indices get spread out to the sparse indices (it works analogously to gather, but we want scatter). I can't think of a way around this right now...

That said, it's an interesting approach. I think the PEXTs would be the bottleneck in my code (looks like there's only one execution unit for them, whereas there's two for the VPADDs), and finding a way to parallelize all the VPADDs could lead to a nice speedup.

zwegner··on AVX512 VBMI – remove spaces from text
Awesome, thanks! I'll play around a bit with the algorithms and see if I come up with anything neat. I'll email you if I do.
zwegner··on AVX512 VBMI – remove spaces from text
Ah, just figured it out. I accidentally deleted this line:

            len = 64 - __builtin_popcountll(mask);
So the destination pointer never got updated. Mental debugging is kind of annoying :)

Thanks!

zwegner··on AVX512 VBMI – remove spaces from text
OK, I got nerd-sniped here. You can actually construct the indices for the shuffle fairly easily with PEXT. Basically, you have 6 64-bit masks, each corresponding to a different bit of the index of each byte in the 64-byte vector. So for mask 0, a bit is set in the mask if its index has bit (1 << 0) set, mask 1 has the same but for bit (1 << 1), etc. The masks have a simple pattern, that changes between 1 and 0 bits every (1 << i) bits. So for 3 bits the masks would be: 10101010, 11001100, 11110000.

These masks are then extracted with PEXT for all the non-whitespace bytes. What this does is build up, bit by bit, the byte index of every non-whitespace byte, compressed down to the least-significant end, without the indices of whitespace bytes.

I wasn't actually able to run this code, since I don't have an AVX-512 machine, but I'm pretty sure it should be faster. I put the code on github if anyone wants to try: https://github.com/zwegner/toys/blob/master/avx512-remove-sp...

    const uint64_t index_masks[6] = {
        0xaaaaaaaaaaaaaaaa,
        0xcccccccccccccccc,
        0xf0f0f0f0f0f0f0f0,
        0xff00ff00ff00ff00,
        0xffff0000ffff0000,
        0xffffffff00000000,
    };
    const __m512i index_bits[6] = {
        _mm512_set1_epi8(1),
        _mm512_set1_epi8(2),
        _mm512_set1_epi8(4),
        _mm512_set1_epi8(8),
        _mm512_set1_epi8(16),
        _mm512_set1_epi8(32),

    };

  ...later, inside the loop:

    mask = ~mask;
    __m512i indices = _mm512_set1_epi8(0);
    for (size_t index = 0; index < 6; index++) {
        uint64_t m = _pext_u64(index_masks[index], mask);
        indices = _mm512_mask_add_epi8(indices, m, indices, index_bits[index]);
    }
    output = _mm512_permutexvar_epi8(indices, input);
zwegner··on It’s a Great Age for Jazz, but Don’t Call It Golden
There's many different directions to go in.

On the more jazzy/instrumental side:

BADBADNOTGOOD - Confessions: https://www.youtube.com/watch?v=CWF2jHFkNpk

Rob Araujo - Nineteen: https://www.youtube.com/watch?v=p3J11saZ1TU

Binkbeats - Little Nerves: https://www.youtube.com/watch?v=zfpSn7ZYC0A

Jaga Jazzist - Animal Chin: https://www.youtube.com/watch?v=HVIFUQV20NM

On the hip-hop/R&B side:

Otis Junior + Dr. Dundiff - Me vs Me: https://www.youtube.com/watch?v=-Aqqv6kQnbw

Woo Park - Boom Bap: https://www.youtube.com/watch?v=ZTLRUG5k1HY

April + Vista - Beasts: https://www.youtube.com/watch?v=yLb-swDzbv0

The Internet - Under Control: https://www.youtube.com/watch?v=cSlnd4YnmGI

Other artists that are all over the place, and have lots of jazz influences:

Hiatus Kaiyote - Mobius Streak: https://www.youtube.com/watch?v=lCvMtQSdCXo

Taylor McFerrin - Already There: https://www.youtube.com/watch?v=vY-MZ0bL1Gc

Anderson .Paak - The Season/Carry Me: https://www.youtube.com/watch?v=9v5-0caYfqc

zwegner··on It’s a Great Age for Jazz, but Don’t Call It Golden
That's a real nice track, thanks for that.

Admittedly, in the music I posted there's definitely roots in dubstep, neuro hop, glitch, etc. So it's not necessarily a "new" genre, and those tracks could have feasibly been made five years ago, but IMO there's so much sonic territory to explore that I still hear plenty of new tracks that sound unlike anything else I've ever heard.

I'll throw out a few more tracks in the hopes you might find something new to like:

Chee - Bane of Our Species - some heavier neuro hop type stuff, lots of broken rhythms: https://www.youtube.com/watch?v=_MI1i20GCRI

Zebbler Encanti Experience w/ Woulg - Flesh Out - alternating between spacey ambience and some super intense glitches: https://www.youtube.com/watch?v=d6OOW9j3ZCM

COPYCATT - Sweet Soul - some lush, jazzy neuro hop: https://www.youtube.com/watch?v=RfnJ8s_AhP4

Mindex - Cluster Overload - very layered, psychedelic bass type stuff: https://www.youtube.com/watch?v=Ir_tqgnStuU

zwegner··on It’s a Great Age for Jazz, but Don’t Call It Golden
Thanks for these recommendations. I already really like Yussef Kamaal, and from a short sampling these other artists will definitely make it into my rotation.

I feel I should also point out that Coltrane went much further than the sort of jazz that would be considered "academic" in his later years, as he got freer and more avant-garde. I particularly like the last year or so of his classic quartet (1965), as they stretched musical forms into very intense, dissonant directions, while still maintaining a masterful group cohesion. Take this performance[1] of My Favorite Things, for example, and compare it to the version released four years before--it's worlds apart.

[1] https://www.youtube.com/watch?v=NWYWgda5f0I

zwegner··on It’s a Great Age for Jazz, but Don’t Call It Golden
There's really quite a lot, if you know where to look. One particular genre I enjoy is experimental bass music, that tends to emphasize extremely detailed sound design and production. Every song will generally sound completely different. Here's a few songs, all from the last year or two, that should give a rough idea of what I'm talking about:

SIXIS - Faceless: https://www.youtube.com/watch?v=lmJ8KAt8dQ4

Mr. Bill & kLL sMTH - Killiam William: https://www.youtube.com/watch?v=9kBvWVkqebc

Frequent - Pumple Snout: https://www.youtube.com/watch?v=kkzZhefuPGI

Freddy Todd - Audible Edibles: https://www.youtube.com/watch?v=2hJM8nae9qM

KOAN Sound - Chilli Daddy: https://www.youtube.com/watch?v=I6r9qxHg3qk

Futexture - Through the Edge of Never: https://www.youtube.com/watch?v=KNPpgJtJ9E4

zwegner··on NewSQL databases fail to guarantee consistency and I blame Spanner
> If the satellite is overhead, the error would put you 300m into the ground so to speak.

Right, I was basically calculating where that signal would just be reaching the surface at the same time it was 300m under you. This is a circle around you with a radius of ~110km (again using the approximation of the ground as a flat plane). Thinking about it more, there's not much reason to do this (GPS isn't really tied to the surface of the Earth, it gives you 3-D coordinates). I guess my point was that the 300m of distance from 1us of light propagation should not be thought of as a horizontal distance.

zwegner··on NewSQL databases fail to guarantee consistency and I blame Spanner
> A 1 microsecond error is 300 meters.

While the speed-of-light propagation is about 300 meters in a microsecond, isn't the final position error possibly much greater? For calculating position on Earth, you can think about a sphere expanding at the speed of light from each satellite. The 1 microsecond error here corresponds to a radius 300m bigger or smaller, which only corresponds to 300m horizontal distance on the ground if the satellite is on the horizon (assuming that Earth is locally a flat plane for simplicity here). For a satellite directly overhead, the 300m error is a vertical distance. Calculating the difference in horizontal position from this error is then finding the length of a leg of a right triangle with other leg length D and hypotenuse length D+300m, where D is the orbital distance from the satellite (according to Wikipedia, 20180km). The final horizontal distance error is then sqrt((D+300)^2 - D^2), or about 110km.

Of course, this is just the effect of a 1us error in a single satellite, I'm sure there's ways to detect and compensate for these errors.

zwegner··on Dyslexia: scientists claim cause of condition may lie in the eyes
> I would expect that the social stigma would severely limit uptake in school though, which is why this isn't standard today -- kids can be rather vicious when they pick up on any hint of difference or weakness.

Random idea--what about a completely opaque contact lens, with an image of an iris/pupil on the outside, customized for the person's eye color? It would likely be noticeable up close, but could take away a lot of this social stigma.

zwegner··on APIs, robustness, and idempotency
Is there any plan for the ability to discard previously used idempotency keys, so that a request with all the same parameters can actually be duplicated? Sometimes a payment will fail because a customer's card is declined (e.g. because of fraud detection or insufficient funds), and after the customer sorts it out, we'd like to try recharging their card, and not just receive the same error message. Our current workaround is to wait 24 hours for the idempotency key to expire, but it would be nice to be able to retry the request sooner without maintaining state on our side to generate a different idempotency key for the same payment.
zwegner··on Keyframes: Delivering scalable, high-quality animations to mobile clients
Interesting, thanks for the actual-lawyer perspective! So is it that ToSes are less legally binding than copyright law? Or is there special meaning behind "can't grant that right"?

Seems like a clear abuse of GitHub's goodwill towards real open-source projects, though. Luckily, it looks like they're going to change the license: https://github.com/facebookincubator/Keyframes/issues/24

zwegner··on Keyframes: Delivering scalable, high-quality animations to mobile clients
Note that, by publishing this repo publicly on GitHub, there is a right to fork granted by GitHub's ToS[0], which this license seems to conflict with (though IANAL of course...). Not sure what "fork" means in this context, whether it's just duplicating a repository or also modifying it.

[0] https://help.github.com/articles/github-terms-of-service/#f-... Section F.1: "By setting your repositories to be viewed publicly, you agree to allow others to view and fork your repositories."

zwegner··on How I stopped the RSI pain that almost destroyed my programming career
Where, exactly, is your disagreement with the parent post? Nothing you said seems to contradict it, from what I can tell.
zwegner··on How Blockchain Will Change Your Life
First off, when did "blockchain" become an uncountable noun? "blockchains" or "blockchain technology" sounds much more natural.

Anyways, I wish more people in the media would differentiate between the Merkel tree, providing the immutable ledger part, and the proof-of-work distributed consensus algorithm, which provides some degree of trust through burning an ever-increasing amount of power. Most of the benefits the author lists would be true of just the Merkel tree without needing the wasteful proof-of-work consensus system, if it's used between trusted parties. Also, even if there's not complete trust, it would still provide an audit trail so that appropriate actions could be taken against bad actors.

When the author later talks about governance boards, that just underscores the incongruity even more. While I'm sure governance boards could be shoehorned into some DAO-like system over distributed consensus, it seems a lot easier to just get rid of the whole distributed consensus altogether and give some digital signatures to the governance board that can sign/bless the Merkel tree.

zwegner··on Show HN: A fork of sudo with Touch ID support
Also known as PNS Syndrome (PIN Number Syndrome (Personal Identification Number Number Syndrome Syndrome)).
zwegner··on Wolfram Alpha Can't
Saw this page linked from slatestarcodex.com, and was immediately nerd-sniped. I read through the entire history and was amazed by the depth and variety of all the different queries, some of them quite amusing. Pretty mind-opening to think of the level of AI needed to solve these automatically. Good source of puzzles and interview questions too--I wrote programs to solve a bunch of them.
zwegner··on Why Wait? the Science Behind Procrastination
> I think I get a lot of work done (solo game dev on my own), but I also re-organise my task list about every week too, does that make me a procrastinator? If I get stuck on a hard problem, I'll often browse the internet mindlessly, then come back and solve it. Does that make me a procrastinator? If I take a week off, am I a procrastinator!?

No, that behavior seems pretty rational, not like what is described in the article. You're not consistently putting off a painful task, you're taking breaks.

> Just because we made up a word for 'not doing work' doesn't make it real, or a problem.

Call it what you will, but procrastination has been a serious problem for me. The negative effects on my life are far too plentiful to mention, but an easy example is that I dropped out of college because I didn't want to write a paper. I tried to write it, couldn't make progress, stopped going to the class, and then didn't sign up for any more classes. There are just some tasks that are very stressful to think about, and for better or worse, my instinctual response is to simply not think about them at all. Unless you've experienced this, and seen relationships, jobs, personal projects, etc fall apart right in front of you, over and over again, I don't think you can say procrastination is not a problem.

I do a fair amount of Yoga, and indeed it helps with relaxation, but that's rather beside the point: it's quite susceptible to the same mental flinch as any other task. If I'm procrastinating on something, it's not any easier to decide to do Yoga to help make progress on it, than it is to just not procrastinate in the first place.

zwegner··on Heisenberg Developers (2014)
Great article, this echoes a lot of my frustrations working in the software world. It doesn't help that I've experienced being on a well-managed software team working on interesting problems--it kinda spoiled me for all those other jobs... :)

Anybody have any advice for escaping this? I want the freedom to work on interesting things in my own way with a minimum of the politics. Ideally a PM would be someone who pushes back on all this micromanagement crap and does everything they can to make the developers' jobs easier. It seems I'm not self-motivated enough to do freelance work or start a start-up, so what other options are there?

zwegner··on Rowhammer.js: Root privileges for web apps?
Hmm, it seems that all the pieces aren't in place yet. If I'm understanding correctly, the exploit technique they use relies on cross-page errors (causing errors in one page with accesses to another page), because the page with errors needs to get freed to the operating system to potentially reuse as PTEs, while still having the ability to cause the errors. There's a line on one of the slides that says you can use timing information to get cross-page information, but I'm really not sure what that means, and how feasible it is.

In addition, they need to find a double-bit error, one that would change both the writable bit and an address bit, if a PTE was in that place in memory. They mentioned that they tested their laptop for these errors, and they're possible, but much rarer--how rare? This point was kind of just glossed over.

I'd guess that these two combined would make an exploitable error much more unlikely.

← PreviousPage 4 of 11Next →