Skip to content

Instantly share code, notes, and snippets.

View anelson's full-sized avatar

Adam Nelson anelson

View GitHub Profile
@anelson
anelson / minimal.vimrc
Last active January 24, 2019 18:14
Minimal vimrc to reproduce problem with ncm2 and neosnippets
"" vim:fdm=expr:fdl=0
"" vim:fde=getline(v\:lnum)=~'^"#'?'>'.(matchend(getline(v\:lnum),'"#*')-1)\:'='
if has('nvim')
set runtimepath+=~/.vim,~/.vim/after
set packpath+=~/.vim
endif
"# Standard boilerplate
@anelson
anelson / nvme0n1-after-blkdiscard.svg
Last active August 9, 2018 12:19
NVMe SSD benchmarking weirdness with XFS
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/sh
# Install chef-dk the arch way
TMPDIR=$HOME/temp # don't use mktemp here; the /tmp volume is usually too small on vagrant boxes
if [ ! "command -v chef" ]; then
mkdir -p $TMPDIR
cd $TMPDIR
curl -o chef-dk.tgz "https://aur.archlinux.org/cgit/aur.git/snapshot/chef-dk.tar.gz"
tar xvzf chef-dk.tgz
cd chef-dk
//...boilerplate
case class Role(policies: Option[Seq[Policy]]))
case class Policy(statements: Option[Seq[Statement]])
case class Statement(action: String)
val role: Role = ....
/* How do I:
* Set Role.policies to an empty Seq iff it's None

I've had a chance to test these suggestions again on an EC2 i2.4xlarge instance. atime=off made no difference, zfs_prefetch_disable=1 made no difference either.

Running iotop I am not seeing substantial read workloads; it's all writes as expected.

I can't get more than ~65K IOPS.

For lack of something else to try, here are the details of the most recent test I ran:

I set up the test with these commands:

// Generated on 2015-09-14 using generator-angular 0.12.1
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
@anelson
anelson / 1_hiding_exception.cs
Created August 31, 2010 10:45
Wrapping exceptions with InnerException, Kyiv 2010
public class UserManager {
public void Authenticate(string userName, string password) {
try {
_userDatabase.Authenticate(userName, password);
} catch (Exception e) {
// Now if authentication fails, when you catch AuthenticationFailedException
// you have no idea what actually caused the authentication to fail.
// That will make debugging, especially in the field, very hard
throw new AuthenticationFailedException();
}
@anelson
anelson / 1_meaningless_exception.cs
Created August 31, 2010 10:30
Choosing the right exception types, Kyiv 2010
public class UserManager {
public void AuthenticatedUser(string userName, string password) {
if (userName != _userName) {
//WTF does 'ApplicationException' mean? It means "something didn't work"
//That's not very helpful
throw new ApplicationException("Invalid username");
}
}
}
@anelson
anelson / properties_vs_methods.cs
Created August 31, 2010 10:24
Methods vs Properties, Kyiv 2010
public class UserManager {
// This property is doing WAY too much work to be a property
public string[] Users {
get {
var usersList = new List<string>();
using (var connection = ConnectToDatabase()) {
var users = connection.GetUsersTable();
users.Rows.ForEach((row) => usersList.Add(row.UserName));
}
@anelson
anelson / no_naming_convention.cs
Created August 31, 2010 10:09
No naming conventions, Kyiv 2010
//What the hell is going on here? I can't read it!
public class Foo {
private string Name;
private string Password;
public string UserName { get { return Name; } set { Name = value; } }
public bool ValidateUser(string UserName, string Pass) {
string CurrentUserName = UserName;