Skip to content

Instantly share code, notes, and snippets.

View Voultapher's full-sized avatar
🦕
Fight perfection

Lukas Bergdoll Voultapher

🦕
Fight perfection
  • MVTec Software GmbH
  • Munich, Germany
  • 00:48 (UTC +02:00)
View GitHub Profile
// This file is a part of the IncludeOS unikernel - www.includeos.org
//
// Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences
// and Alfred Bratterud
//
// 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
<html>
<head>
<!--
We will create a family tree using just CSS(3)
The markup will be simple nested lists
-->
<style>
/*Now the CSS*/
* {margin: 0; padding: 0;}
@Voultapher
Voultapher / horrible_v1.cpp
Created March 28, 2017 18:27
never do this
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <sstream>
void foo(const char* filepath)
{
std::ifstream file(filepath);
#!/usr/bin/env python3
import sys
def print_crck():
overflow_str = b''.join([ b'a' for x in range(264) ])
sys.stdout.buffer.write(b'new a\n')
sys.stdout.buffer.write(b'new b\n')
sys.stdout.buffer.write(b'delete 0\n')
sys.stdout.buffer.write(b'new ' + overflow_str + b'\x9c\x0c\x40\n')
@Voultapher
Voultapher / cpp.ll
Created July 8, 2018 20:45
clang++ -O3 -std=c++17 main.cpp -emit-llvm -S
; ModuleID = 'main.cpp'
source_filename = "main.cpp"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: readnone sspstrong uwtable
define { i64, i8 } @_Z15return_optionall(i64) local_unnamed_addr #0 {
%2 = icmp slt i64 %0, 32
%3 = srem i64 %0, 752
%4 = zext i1 %2 to i8
@Voultapher
Voultapher / rust.ll
Created July 8, 2018 20:48
rustc --crate-type=lib -O main.rs --emit=llvm-ir
; ModuleID = 'main0-8787f43e282added376259c1adb08b80.rs'
source_filename = "main0-8787f43e282added376259c1adb08b80.rs"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"unwind::libunwind::_Unwind_Exception" = type { [0 x i64], i64, [0 x i64], void (i32, %"unwind::libunwind::_Unwind_Exception"*)*, [0 x i64], [6 x i64], [0 x i64] }
%"unwind::libunwind::_Unwind_Context" = type { [0 x i8] }
; main::return_option
; Function Attrs: norecurse nounwind readnone uwtable
@Voultapher
Voultapher / main.cpp
Last active July 16, 2018 17:49
rustc vs clang | llvm production | app
#include <cstdint>
auto foo(int64_t a, int64_t b) -> int64_t
{
return (a % 239082) % b;
}
auto bar(int64_t a) -> int64_t
{
return foo(a, 77);
@Voultapher
Voultapher / lib-min.rs
Last active July 16, 2018 17:51
rustc vs clang | llvm production | lib
pub fn foo(a: i64, b: i64) -> i64 {
(a % 239082) % b
}
pub fn bar(a: i64) -> i64 {
foo(a, 77)
}
@Voultapher
Voultapher / overview.md
Created July 16, 2018 17:56
rustc vs clang | llvm production

Hello, I'm interested in rustc' compile time. Some preliminary test left me with some questions.

I measured building a minimal application. https://gist.github.com/Voultapher/ebc3abb55994ea90f3ac604c5ffccc19

Things I noticed:

  • nightly is significantly faster than stable, yay!
  • clang's full run is less than emit llvm ir + compile llvm ir
  • rustc's full run is much slower than emit llvm ir + compile llvm ir
@Voultapher
Voultapher / result_std_with_fx_vs_hashbrown.txt
Created December 8, 2018 11:14
Using https://github.com/Voultapher/hashmap-compare to compare rust std::collections::HashMap using fx hasher with hashbrown::HashMap running on Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
----- Running rust benchmarks -----
Sat Dec 8 10:06:51 UTC 2018
CONFIGURATION: fx_hash
running 50 tests
test tests::big::clone ... bench: 6,507,451 ns/iter (+/- 2,369,267)
test tests::big::copy_element_wise ... bench: 9,405,607 ns/iter (+/- 1,097,552)
test tests::big::fill_only ... bench: 5,362,458 ns/iter (+/- 27,196)
test tests::big::insert_random ... bench: 7,773,228 ns/iter (+/- 77,974)
test tests::big::lookup_all ... bench: 5,816,665 ns/iter (+/- 86,600)