Skip to content

Instantly share code, notes, and snippets.

View billywhizz's full-sized avatar
🤓
always be learning

Andrew Johnston billywhizz

🤓
always be learning
View GitHub Profile
@billywhizz
billywhizz / reader.js
Created July 31, 2021 13:15
POSIX shared memory example for just.js
const fd = just.sys.shmopen('/omgthisiscool')
const size = 1 * 1024 * 1024 * 1024
const ab = just.sys.mmap(fd, size)
const u32 = new Uint32Array(ab)
just.setInterval(() => {
just.print(Atomics.load(u32, 0))
}, 1000)
<p>
testing
</p>
@billywhizz
billywhizz / .gitignore
Last active February 19, 2021 22:26
stdio perf test for just-js
wc
wcb
scratch
@billywhizz
billywhizz / README.md
Last active January 24, 2021 07:22
sha256sum perf investigation - jan 2021

Create the test file

dd if=/dev/urandom of=/dev/shm/random.bin bs=65536 count=10000

Compile the c program

gcc -g -O3 -o sha256sum sha256sum.c
function checksum (file) {
const source = Buffer.alloc(65536)
const fd = openSync(file)
const hash = createHash('sha256')
let bytes = readSync(fd, source)
while (bytes > 0) {
if (bytes < 65536) {
hash.update(source.slice(0, bytes))
} else {
hash.update(source)
const { allFortunes } = sock
allFortunes.call(() => {
const html = getHTML(insertionSort([extra, ...allFortunes.getRows()]))
sock.writeString(`${rHTML}${utf8Length(html)}${END}${html}`)
})
sock.allFortunes = await compile(sock, {
formats: [],
sql: 'select * from Fortune',
fields: [{ format: 1, oid: INT4OID }, { format: 0, oid: VARCHAROID }],
name: 's2',
portal: '',
maxRows: 0,
htmlEscape: true,
params: []
})
sock.allFortunes = await compile(sock, {
formats: [],
sql: 'select * from Fortune',
fields: [{ format: 1, oid: INT4OID }, { format: 0, oid: VARCHAROID }],
name: 's2',
portal: '',
maxRows: 0,
htmlEscape: true,
params: []
})
@billywhizz
billywhizz / case.md
Last active October 18, 2020 00:09
v8 backingstore mutexes on access

v8 version

8.5.210.27

platform

linux, Ubuntu 18.06

arch

const { Socket, TCP } = library('socket', {})
const server = new Socket(TCP)
const read = Buffer.alloc(64 * 1024)
const write = Buffer.alloc(64 * 1024)
const bytes = new Uint8Array(read.bytes)
let off = 0, records = 0, resLength = 0
const response = `HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nServer: dv8\r\nDate: ${(new Date()).toUTCString()}\r\nContent-Length: 13\r\n\r\nHello, World!`
while (1) {
resLength = write.write(response, off)
off += resLength