Skip to content

Instantly share code, notes, and snippets.

View valyala's full-sized avatar
:octocat:
VictoriaMetrics just works!

Aliaksandr Valialkin valyala

:octocat:
VictoriaMetrics just works!
View GitHub Profile
@valyala
valyala / word_chains_solution.cpp
Created December 5, 2011 18:33
Word Chains solution
// This is a solution for the Word Chains problem described
// at http://socialcam.com/jobs/problems .
//
// The problem.
//
// Two words are connected by a word chain if it is possible to change one into
// the other by making a series of single-character changes, such that every
// intermediate form is also a word. For example, CAT and DOG are connected with
// a word chain because CAT, COT, COG and DOG are all words. DEMONIC and
// UMBRELLA are not.
@valyala
valyala / spew.go
Created April 28, 2012 02:18
Spew implementation ( https://github.com/varnish/spew ) in golang
package main
import (
"flag"
"fmt"
"io"
"net"
"os"
"os/signal"
"strings"
// Example static file server. Serves static files from the given directory.
package main
import (
"flag"
"fmt"
"log"
"strconv"
"strings"
@valyala
valyala / go-tool-pprof-readline-support.diff
Created January 20, 2016 15:01
Add readline support for interactive mode in go tool pprof
diff --git a/src/cmd/pprof/internal/plugin/plugin.go b/src/cmd/pprof/internal/plugin/plugin.go
index a22ec5f..4d545de 100644
--- a/src/cmd/pprof/internal/plugin/plugin.go
+++ b/src/cmd/pprof/internal/plugin/plugin.go
@@ -6,7 +6,6 @@
package plugin
import (
- "bufio"
"fmt"
@valyala
valyala / README.md
Last active April 19, 2024 13:00
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data: