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
| {-# LANGUAGE OverloadedStrings, BangPatterns, FlexibleInstances #-} | |
| -- | Тупейший (и, надеюсь, быстрый) парсер xml -> теги. | |
| -- | |
| -- Выдает где-то от 40МБ/сек (а где-то и 80 и 200) | |
| -- | |
| -- Все теги и атрибуты возвращаются в lowercase (строка меняется INPLACE, | |
| -- для уменьшения числа аллокаций и фрагментации) | |
| -- | |
| -- После профилирования выяснилось, | |
| -- что TagSoup отжирает 75% памяти и >50% времени. Более того, |
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
| Core was generated by `/tank/riak-1.3.1/erts-5.9.1/bin/beam.smp -K true -A 64 -W w -- -root /tank/riak'. | |
| Program terminated with signal 11, Segmentation fault. | |
| #0 0x00007f162547fa30 in MurmurHash64A(void const*, int, unsigned int) () | |
| from /tank/riak-1.3.1/lib/eleveldb-1.3.0/priv/eleveldb.so | |
| (gdb) bt | |
| #0 0x00007f162547fa30 in MurmurHash64A(void const*, int, unsigned int) () | |
| from /tank/riak-1.3.1/lib/eleveldb-1.3.0/priv/eleveldb.so | |
| #1 0x00007f162547833c in leveldb::(anonymous namespace)::BloomFilterPolicy2::CreateFilter(leveldb::Slice const*, int, std::string*) const () | |
| from /tank/riak-1.3.1/lib/eleveldb-1.3.0/priv/eleveldb.so |
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
| import qualified Data.ByteString.Lazy.Char8 as B | |
| import qualified Data.Text.Lazy as T | |
| import qualified Data.Text.Lazy.Encoding as T | |
| import qualified Data.Aeson as JSON | |
| import Data.Char | |
| import Text.Printf | |
| import Control.Monad | |
| -- wget http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt |
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
| {-# LANGUAGE GADTs #-} | |
| class Clickable a where | |
| click :: a -> String | |
| class Renderable a where | |
| render :: a -> String | |
| data Interface a where | |
| Clickable :: Clickable a => Interface a | |
| Renderable :: Renderable a => Interface a |
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
| resolveA :: DNSCache -> String -> IO (Either T.Text HostAddress) | |
| resolveA c d = | |
| handle Left $ checkDomain id d $ fmap errorStr $ resolve c (B.pack d) | |
| resolveCachedA :: DNSCache -> String -> IO (Maybe (Either T.Text HostAddress)) | |
| resolveCachedA c d = | |
| handle (Just . Left) $ checkDomain Just d $ fmap (fmap errorStr) $ resolveCache c (B.pack d) | |
| handle f a = a `E.catch` handleError f |
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
| {-# LANGUAGE GHC2021, LambdaCase, PatternSynonyms, RecordWildCards, | |
| ViewPatterns, OverloadedStrings, GADTs, NoMonoLocalBinds, | |
| UnboxedTuples, MagicHash #-} | |
| {-# OPTIONS_GHC -O2 -fspec-constr-count=100 -fllvm #-} | |
| -- need at least 8 to completely remove all allocations | |
| -- (I don't know what change lead to it) | |
| {-# OPTIONS_GHC -Wall -Wno-gadt-mono-local-binds -Wno-type-defaults #-} |
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
| {-# LANGUAGE TypeFamilies #-} | |
| import Control.Concurrent | |
| import Control.Concurrent.Async | |
| import Control.Concurrent.Chan | |
| import Control.Concurrent.MVar | |
| import Control.Concurrent.QSem | |
| import Control.Exception qualified as E | |
| import Control.Monad | |
| import Control.Monad.IO.Class |
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
| /* Experiment with a uniform representation of values that can hold | |
| references to C++ objects and be used polymorphically. Examples of | |
| the Rank2 IO monad dictionary and relation extend are provided at | |
| the bottom. | |
| The approach is the same as in dynamically typed languages. | |
| Primitive values are coupled with types at runtime. Functions only | |
| keep their arity to know when to apply. Empty values ([] or | |
| Nothing) are untyped. |
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++ -g -O3 -fopenmp -std=c++20 -Iboost_1_89_0 -Wall -Wpedantic hashtable.cpp && perf stat -e branches,branch-misses,bus-cycles,cache-misses,cache-references,cycles,instructions,ref-cycles ./a.out | |
| #include <atomic> | |
| #include <functional> | |
| #include <utility> | |
| #include <string> | |
| #include <vector> | |
| #include <stdexcept> | |
| #include <map> | |
| #include <unordered_map> | |
| #include <bit> |
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++ -g -fopenmp -O2 -std=gnu++2c -Wall -Wpedantic -Iboost_1_89_0 Graph.cpp && ./a.out | |
| /* [WIP] | |
| TODO | |
| - removing unused nodes? | |
| - ref data use case -- evaluate immediately and only keep results | |
| - exceptions in recipes -- do not keep unused nodes | |
| - recipes that add nodes but do not use them |