Add pushover notifications, this should be a super basic MVP
This commit is contained in:
parent
ed13a5994f
commit
d9917ab8b0
505 changed files with 195741 additions and 9 deletions
127
vendor/github.com/dgraph-io/ristretto/z/simd/baseline.go
generated
vendored
Normal file
127
vendor/github.com/dgraph-io/ristretto/z/simd/baseline.go
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
package simd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sort"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Search finds the key using the naive way
|
||||
func Naive(xs []uint64, k uint64) int16 {
|
||||
var i int
|
||||
for i = 0; i < len(xs); i += 2 {
|
||||
x := xs[i]
|
||||
if x >= k {
|
||||
return int16(i / 2)
|
||||
}
|
||||
}
|
||||
return int16(i / 2)
|
||||
}
|
||||
|
||||
func Clever(xs []uint64, k uint64) int16 {
|
||||
if len(xs) < 8 {
|
||||
return Naive(xs, k)
|
||||
}
|
||||
var twos, pk [4]uint64
|
||||
pk[0] = k
|
||||
pk[1] = k
|
||||
pk[2] = k
|
||||
pk[3] = k
|
||||
for i := 0; i < len(xs); i += 8 {
|
||||
twos[0] = xs[i]
|
||||
twos[1] = xs[i+2]
|
||||
twos[2] = xs[i+4]
|
||||
twos[3] = xs[i+6]
|
||||
if twos[0] >= pk[0] {
|
||||
return int16(i / 2)
|
||||
}
|
||||
if twos[1] >= pk[1] {
|
||||
return int16((i + 2) / 2)
|
||||
}
|
||||
if twos[2] >= pk[2] {
|
||||
return int16((i + 4) / 2)
|
||||
}
|
||||
if twos[3] >= pk[3] {
|
||||
return int16((i + 6) / 2)
|
||||
}
|
||||
|
||||
}
|
||||
return int16(len(xs) / 2)
|
||||
}
|
||||
|
||||
func Parallel(xs []uint64, k uint64) int16 {
|
||||
cpus := runtime.NumCPU()
|
||||
if cpus%2 != 0 {
|
||||
panic(fmt.Sprintf("odd number of CPUs %v", cpus))
|
||||
}
|
||||
sz := len(xs)/cpus + 1
|
||||
var wg sync.WaitGroup
|
||||
retChan := make(chan int16, cpus)
|
||||
for i := 0; i < len(xs); i += sz {
|
||||
end := i + sz
|
||||
if end >= len(xs) {
|
||||
end = len(xs)
|
||||
}
|
||||
chunk := xs[i:end]
|
||||
wg.Add(1)
|
||||
go func(hd int16, xs []uint64, k uint64, wg *sync.WaitGroup, ch chan int16) {
|
||||
for i := 0; i < len(xs); i += 2 {
|
||||
if xs[i] >= k {
|
||||
ch <- (int16(i) + hd) / 2
|
||||
break
|
||||
}
|
||||
}
|
||||
wg.Done()
|
||||
}(int16(i), chunk, k, &wg, retChan)
|
||||
}
|
||||
wg.Wait()
|
||||
close(retChan)
|
||||
var min int16 = (1 << 15) - 1
|
||||
for i := range retChan {
|
||||
if i < min {
|
||||
min = i
|
||||
}
|
||||
}
|
||||
if min == (1<<15)-1 {
|
||||
return int16(len(xs) / 2)
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
func Binary(keys []uint64, key uint64) int16 {
|
||||
return int16(sort.Search(len(keys), func(i int) bool {
|
||||
if i*2 >= len(keys) {
|
||||
return true
|
||||
}
|
||||
return keys[i*2] >= key
|
||||
}))
|
||||
}
|
||||
|
||||
func cmp2_native(twos, pk [2]uint64) int16 {
|
||||
if twos[0] == pk[0] {
|
||||
return 0
|
||||
}
|
||||
if twos[1] == pk[1] {
|
||||
return 1
|
||||
}
|
||||
return 2
|
||||
}
|
||||
|
||||
func cmp4_native(fours, pk [4]uint64) int16 {
|
||||
for i := range fours {
|
||||
if fours[i] >= pk[i] {
|
||||
return int16(i)
|
||||
}
|
||||
}
|
||||
return 4
|
||||
}
|
||||
|
||||
func cmp8_native(a [8]uint64, pk [4]uint64) int16 {
|
||||
for i := range a {
|
||||
if a[i] >= pk[0] {
|
||||
return int16(i)
|
||||
}
|
||||
}
|
||||
return 8
|
||||
}
|
51
vendor/github.com/dgraph-io/ristretto/z/simd/search.go
generated
vendored
Normal file
51
vendor/github.com/dgraph-io/ristretto/z/simd/search.go
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
// +build 386 arm armbe arm64 mips mipsle mips64p32 mips64p32le ppc ppc64 ppc64le sparc
|
||||
|
||||
/*
|
||||
* Copyright 2020 Dgraph Labs, Inc. and Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package simd
|
||||
|
||||
// Search uses the Clever search to find the correct key.
|
||||
func Search(xs []uint64, k uint64) int16 {
|
||||
if len(xs) < 8 {
|
||||
return Naive(xs, k)
|
||||
}
|
||||
var twos, pk [4]uint64
|
||||
pk[0] = k
|
||||
pk[1] = k
|
||||
pk[2] = k
|
||||
pk[3] = k
|
||||
for i := 0; i < len(xs); i += 8 {
|
||||
twos[0] = xs[i]
|
||||
twos[1] = xs[i+2]
|
||||
twos[2] = xs[i+4]
|
||||
twos[3] = xs[i+6]
|
||||
if twos[0] >= pk[0] {
|
||||
return int16(i / 2)
|
||||
}
|
||||
if twos[1] >= pk[1] {
|
||||
return int16((i + 2) / 2)
|
||||
}
|
||||
if twos[2] >= pk[2] {
|
||||
return int16((i + 4) / 2)
|
||||
}
|
||||
if twos[3] >= pk[3] {
|
||||
return int16((i + 6) / 2)
|
||||
}
|
||||
|
||||
}
|
||||
return int16(len(xs) / 2)
|
||||
}
|
60
vendor/github.com/dgraph-io/ristretto/z/simd/search_amd64.s
generated
vendored
Normal file
60
vendor/github.com/dgraph-io/ristretto/z/simd/search_amd64.s
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Code generated by command: go run asm2.go -out search_amd64.s -stubs stub_search_amd64.go. DO NOT EDIT.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func Search(xs []uint64, k uint64) int16
|
||||
TEXT ·Search(SB), NOSPLIT, $0-34
|
||||
MOVQ xs_base+0(FP), AX
|
||||
MOVQ xs_len+8(FP), CX
|
||||
MOVQ k+24(FP), DX
|
||||
|
||||
// Save n
|
||||
MOVQ CX, BX
|
||||
|
||||
// Initialize idx register to zero.
|
||||
XORL BP, BP
|
||||
|
||||
loop:
|
||||
// Unroll1
|
||||
CMPQ (AX)(BP*8), DX
|
||||
JAE Found
|
||||
|
||||
// Unroll2
|
||||
CMPQ 16(AX)(BP*8), DX
|
||||
JAE Found2
|
||||
|
||||
// Unroll3
|
||||
CMPQ 32(AX)(BP*8), DX
|
||||
JAE Found3
|
||||
|
||||
// Unroll4
|
||||
CMPQ 48(AX)(BP*8), DX
|
||||
JAE Found4
|
||||
|
||||
// plus8
|
||||
ADDQ $0x08, BP
|
||||
CMPQ BP, CX
|
||||
JB loop
|
||||
JMP NotFound
|
||||
|
||||
Found2:
|
||||
ADDL $0x02, BP
|
||||
JMP Found
|
||||
|
||||
Found3:
|
||||
ADDL $0x04, BP
|
||||
JMP Found
|
||||
|
||||
Found4:
|
||||
ADDL $0x06, BP
|
||||
|
||||
Found:
|
||||
MOVL BP, BX
|
||||
|
||||
NotFound:
|
||||
MOVL BX, BP
|
||||
SHRL $0x1f, BP
|
||||
ADDL BX, BP
|
||||
SHRL $0x01, BP
|
||||
MOVL BP, ret+32(FP)
|
||||
RET
|
6
vendor/github.com/dgraph-io/ristretto/z/simd/stub_search_amd64.go
generated
vendored
Normal file
6
vendor/github.com/dgraph-io/ristretto/z/simd/stub_search_amd64.go
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
// Code generated by command: go run asm2.go -out search_amd64.s -stubs stub_search_amd64.go. DO NOT EDIT.
|
||||
|
||||
package simd
|
||||
|
||||
// Search finds the first idx for which xs[idx] >= k in xs.
|
||||
func Search(xs []uint64, k uint64) int16
|
Loading…
Add table
Add a link
Reference in a new issue