Better HN
topnewbestaskshowjobs
Log inSign up

Saltor

23 karma · joined Dec 12, 2014 (11y ago) · 5 submissions

Submissions

comment 10y ago · link · parent

I don't think that the implementation here performs correctly...

For example, the following:

    q := NewPrioq()
    q.In <- timestamp(20)
    q.In <- timestamp(10)
    q.In <- timestamp(30)
    o := <-q.Out
    fmt.Println("Read", o)
Prints "Read 20" rather than "Read 30".

Furthermore, this input:

    q := NewPrioq()
    for i := 0; i < 202; i++ {
        q.In <- timestamp(i)
    }
    o := <-q.Out
    fmt.Println("Read", o)
will result in a deadlock.

As far as I can tell, this code behaves like a FIFO queue with capacity 201. Each iteration of the loop in Prioq.run() will read once from the input channel, insert into the empty tree, remove the "max" element from the single item tree, and then insert into the output channel.

Reading from the input channel and writing to the output channel are performed in lockstep rather than as needed. A correct implementation of this pattern would need to use a select block and to avoid the deadlock and would need a way for writes to the output channel to be signaled as needed so to avoid the stale max value problem.

comment 10y ago · link · parent

This (funny and accessible, don't worry) talk by Gary Bernhardt is what helped me understand asm.js for the first time: https://www.destroyallsoftware.com/talks/the-birth-and-death...

comment 10y ago · link · parent

I'm hopeful that this will lead towards greater unification and innovation, but I can see why people are more likely to bring up "Embrace, Extend, Extinguish" when Microsoft does something compared to when other companies do. The difference is that Microsoft is the one who internally coined the term and used it to describe their strategies. It was a conscious and explicitly stated strategy rather than an unspoken side benefit.

You could certainly say that none of that matters and what we should care about is the actual actions that each company makes, but I can definitely see how people would read more intent into things like this when Microsoft does it compared to other companies.

comment 11y ago · link · parent

I'm not. Is there some performance penalty for using a struct over a 2 element array?

comment 11y ago · link · parent

why would you a 2 element array of int here instead of defining a struct of 2 ints?