- Do a quick performance check in 60 seconds
- Use a number of different tools available in unix
- Use flamegraphs of the callstack if you have access to them
- Best performance winds are elimiating unnecessary wrok, for example a thread stack in a loop, eliminating bad config
- Mantras: Don't do it (elimiate); do it again (caching); do it less (polling), do it when they're not looking, do it concurrently, do it more cheaply
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use 5.010; | |
| use strict; | |
| use warnings; | |
| use Data::Dumper; | |
| use Marpa::R2 2.082000; | |
| my $input = <<'END_OF_STRING'; | |
| { | |
| name => 'test hash 1', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # see http://perldoc.perl.org/perlipc.html#Signals | |
| # http://www.calpoly.edu/cgi-bin/man-cgi?wait+2 | |
| # and Perl Cookbook, part 16.19. Avoiding Zombie Processes | |
| sub REAPER { | |
| local ($!, $?); | |
| while ( (my $pid = waitpid(-1, WNOHANG)) > 0 ) { | |
| say "Process $pid send CHLD with status $?"; | |
| if ( WIFEXITED($?) or WIFSIGNALED($?) ) { | |
| if ( $kids{$pid} ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use B; | |
| use Scalar::Util::LooksLikeNumber 'looks_like_number'; | |
| sub positive_int { | |
| my $lln = looks_like_number($_[0]); | |
| ($lln == 1 || $lln & B::SVf_IOK) && $_[0] > 0; | |
| } | |
| for (0, "0", 123, "123", 123.45, "123.45", "yolki-palki", "nancy") { | |
| print "$_ -> " . (positive_int($_) ? "true" : "false"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env tarantool | |
| local CONSOLE_SOCKET_PATH = 'unix/:/var/run/tarantool/tarantool.sock' | |
| local os = require("os") | |
| console = require('console') | |
| console.on_start(function(self) | |
| local status, reason | |
| status, reason = pcall(function() require('console').connect(CONSOLE_SOCKET_PATH) end) | |
| if not status then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _G.ls = setmetatable({}, { | |
| __serialize = function() | |
| local res = {} | |
| for _, sp_info in box.space._space:pairs(512, { iterator = "GE" }) do | |
| local sp = box.space[sp_info.name] | |
| local info = {} | |
| info.name = tostring(sp.name) | |
| info.engine = tostring(sp.engine) | |
| info.len = tostring(sp:len()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > tarantool -l fiber -l clock -e 'fiber.create(function() while true do while clock.time() < fiber.time()+0.1 do end fiber.sleep(0.01) end end)' test.lua | |
| entering the event loop | |
| e:100.011µs p:0.017µs t:99.998µs | |
| e:100.042µs p:0.010µs t:100.035µs | |
| e:100.013µs p:0.015µs t:100.004µs | |
| e:100.005µs p:0.006µs t:99.994µs | |
| e:100.007µs p:0.004µs t:99.996µs | |
| e:100.010µs p:0.009µs t:99.993µs | |
| e:100.012µs p:0.016µs t:100.000µs | |
| e:100.009µs p:0.050µs t:99.999µs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- RSA bindings for Tarantool | |
| --- Carefully adapted from https://github.com/spacewander/lua-resty-rsa | |
| local bit = require "bit" | |
| local band = bit.band | |
| local ffi = require "ffi" | |
| local ffi_new = ffi.new | |
| local ffi_gc = ffi.gc | |
| local ffi_copy = ffi.copy | |
| local ffi_str = ffi.string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| openssl req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout example.com.crt -out example.com.crt | |
| # Check cerificate | |
| openssl x509 -noout -text -in example.com.crt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env tarantool | |
| local pickle = require('pickle') | |
| local yaml = require('yaml') | |
| function trivec(str) | |
| str = string.lower(str) | |
| local vec = "" |
OlderNewer