Skip to content

Instantly share code, notes, and snippets.

package dazzle
import (
"fmt"
)
func main() {
fmt.Println("Hello world")
}

New code results

New code results

for i in {1..6}; do ./wrk -d10s -t24 -c24 --latency --pipeline 512 http://server:8000; done
Running 10s test @ http://server:8000
  24 threads and 24 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    27.11ms   20.35ms 285.64ms   85.02%

Req/Sec 25.04k 11.73k 74.74k 63.48%

26.10% haywire_hello_w libc-2.17.so [.] 0x000000000008109e
11.82% haywire_hello_w haywire_hello_world [.] http_parser_execute
4.91% haywire_hello_w libc-2.17.so [.] malloc
4.38% haywire_hello_w [kernel.kallsyms] [k] native_read_msr_safe
4.31% haywire_hello_w [kernel.kallsyms] [k] _raw_spin_unlock_irqrestore
3.37% haywire_hello_w haywire_hello_world [.] http_request_on_header_field
2.31% haywire_hello_w haywire_hello_world [.] hw_route_compare_method
1.96% haywire_hello_w [kernel.kallsyms] [k] tcp_sendmsg
1.72% haywire_hello_w libc-2.17.so [.] __libc_calloc
1.30% haywire_hello_w [kernel.kallsyms] [k] default_send_IPI_mask_sequence_phys
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "uv.h"
#include "haywire.h"
#include "hw_string.h"
#include "khash.h"
#include "http_response_cache.h"
#include "http_server.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "uv.h"
#include "haywire.h"
#include "hw_string.h"
#include "khash.h"
#include "http_response_cache.h"
#include "http_server.h"
/*
So I want to refactor this to be faster.
https://github.com/kellabyte/Haywire/blob/master/src/haywire/http_response_cache.c#L53
After my changes this memcpy seems to make no actual append, the destination is unchanged, why?
https://github.com/kellabyte/Haywire/blob/master/src/haywire/http_response.c#L89
Here are the changes I made that caused the above to break. I'm not even convinced this is faster
but I'm concerned why it breaks the appending in the link above. All the hard coded numbers are temporary
and I don't even know what I was drinking when I cooked that mess up. Are those maybe causing the problems?

Aston Martin Vanquish: 250 ms
Ferrari 575M: 220 ms
BMW M3 E36 with SMG I: 220 ms
Ferrari 360: 150 ms
Enzo Ferrari: 150 ms
Lexus LFA: 150 ms
Ferrari FXX: Under 100 ms
Nissan GT-R: 100ms
BMW M3 E46 with SMG II: 80 ms
Ferrari 430 Scuderia & FXX Evoluzione: 60 ms

Program received signal SIGPIPE, Broken pipe.
[Switching to Thread 0x7fffb83e2700 (LWP 18881)]
0x00007ffff76c3ccd in write () at ../sysdeps/unix/syscall-template.S:82
82 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) backtrace
#0 0x00007ffff76c3ccd in write () at ../sysdeps/unix/syscall-template.S:82
#1 0x00000000004286ea in uv__write (stream=0x7fffb0010ba0) at lib/haywire/lib/libuv/src/unix/stream.c:785
#2 0x0000000000429839 in uv__stream_io (loop=0x644360, w=0x7fffb0010c10, events=4)
at lib/haywire/lib/libuv/src/unix/stream.c:1123
#3 0x0000000000421ef2 in uv__run_pending (loop=0x644360) at lib/haywire/lib/libuv/src/unix/core.c:580
Program received signal SIGSEGV, Segmentation fault.
0x000000000041a390 in __ac_X31_hash_string (s=0xffffffffb0000950 <Address 0xffffffffb0000950 out of bounds>)
    at lib/haywire/src/haywire/khash.h:387
387  	khint_t h = (khint_t)*s;
(gdb) bt
#0  0x000000000041a390 in __ac_X31_hash_string (s=0xffffffffb0000950 <Address 0xffffffffb0000950 out of bounds>)
    at lib/haywire/src/haywire/khash.h:387

The key looks to have gone out of scope. It's no longer "/" or something here? Why? It was fine on frame #2.

==18387== Memcheck, a memory error detector
==18387== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==18387== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==18387== Command: ./lib/haywire/builds/unix/debug/haywire_hello_world
==18387== 
Added route /stats

http_server.c:107

==18387== Invalid write of size 4