SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
Ingénierie de la performance au sein des
mégadonnées
Daniel Lemire et collaborateurs
https://lemire.me
“One Size Fits All”: An Idea Whose Time Has Come and Gone
(Stonebraker, 2005)
2
Redécouvrir Unix
Plusieurs composantes spécialisées et réutilisables:
Calcite : SQL + optimisation
Hadoop
etc.
"Make your own database from parts"
3
Ensembles
Un concept fondamental (ensemble de documents, d'enregistrements)
→ Pour la performance, on utilise des ensemble d'entiers (identifiants).
→ Souvent des entiers à 32 bits suffise (identifiants locaux).
4
tests : x ∈ S?
intersections : S ∩ S
unions : S ∪ S
differences : S ∖ S
Jaccard/Tanimoto : ∣S ∩ S ∣/∣S ∪ S ∣
iteration:
for x in S do
print(x)
2 1
2 1
2 1
1 1 1 2
5
Mise en oeuvre
tableaux triés ( std::vector<uint32_t> )
tables de hachage ( java.util.HashSet<Integer> ,
 std::unordered_set<uint32_t> )
…
bitmap ( java.util.BitSet )
bitmap compressé
6
Tableaux
while (low <= high) {
int mI =
(low + high) >>> 1;
int m = array.get(mI);
if (m < key) {
low = mI + 1;
} else if (m > key) {
high = mI - 1;
} else {
return mI;
}
}
return -(low + 1);
7
table de hachage
valeur x stockée à l'index h(x)
accès aléatoire à une valeur rapide
accès ordonné pénible
8
accès ordonné pénible
[15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7]
[15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7]
[15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7]
[15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7]
[15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7]
[15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7]
(Robin Hood, sondage linéaire, fonction de mixage MurmurHash3)
9
Opérations ensemblistes sur les tables de hachage
h1 <- hash set
h2 <- hash set
...
for(x in h1) {
insert x in h2 // échec (mémoire tampon)
}
10
Faire "crasher" Swift
var S1 = Set<Int>(1...size)
var S2 = Set<Int>()
for i in S1 {
S2.insert(i)
}
11
Quelques chiffres: une demi‑heure pour 64M
taille temps (s)
1M 0.8
8M 22
64M 1400
Maps and sets can have quadratic‑time performance
https://lemire.me/blog/2017/01/30/maps‑and‑sets‑can‑have‑
quadratic‑time‑performance/
Rust hash iteration+reinsertion
https://accidentallyquadratic.tumblr.com/post/153545455987/ru
st‑hash‑iteration‑reinsertion
12
13
Les bitmaps ou bitsets
Façon efficace de représenter les ensembles d'entiers.
Par ex., 0, 1, 3, 4 devient  0b11011 ou "27".
{0} →  0b00001 
{0, 3} →  0b01001 
{0, 3, 4} →  0b11001 
{0, 1, 3, 4} →  0b11011 
14
Manipuler un bitmap
Processeur 64 bits.
Étant donné  x , l'index du mot est  x/64 et l'index du bit est  x % 64 .
add(x) {
array[x / 64] |= (1 << (x % 64))
}
15
Est‑ce que c'est rapide?
index = x / 64 -> un shift
mask = 1 << ( x % 64) -> un shift
array[ index ] |- mask -> un OR avec la mémoire
Un bit par ≈ 1.65 cycles à cause de la superscalarité
16
Parallélisme des bits
Intersection entre {0, 1, 3} et {1, 3}
équivaut à une seule opération AND
entre  0b1011 et  0b1010 .
Résultat est  0b1010 ou {1, 3}.
Aucun embranchement!
17
Les bitmaps bénéficient des mots étendus
SIMD: Single Intruction Multiple Data
SSE (Pentium 4), ARM NEON 128 bits
AVX/AVX2 (256 bits)
AVX‑512 (512 bits)
AVX‑512 est maintenant disponible (par ex. chez Dell!) avec les
processors ayant une microarchitecture Skylake‑X.
18
Similarité ensembliste avec les bitmaps
Jaccard/Tanimoto : ∣S ∩ S ∣/∣S ∪ S ∣
devient
1.15 cycles par paire de mots (64‑bit)
Wojciech Muła, Nathan Kurz, Daniel Lemire
Faster Population Counts Using AVX2 Instructions
Computer Journal 61 (1), 2018
(adopté par clang)
1 1 1 2
∣B  OR B ∣1 2
∣B  AND B ∣1 2
19
Les bitsets peuvent être gourmants
{1, 32000, 64000} : 1000 octets pour 3 nombres
On utilise donc la compression!
20
Qu'est‑ce qu'on entend par compression?
Modèle conventionnel: compresse, stocke, décompresse, traite;
RAM → CPU → RAM → CPU
Modèle performant: compresse, stocke, traite sans
décompression;
RAM → CPU
21
Git (GitHub) utilise EWAH
Codage par plage
Exemple: 000000001111111100 est
00000000 − 11111111 − 00
On peut coder les longues séquences de 1 ou de 0 de manière concise.
https://github.com/git/git/blob/master/ewah/bitmap.c
22
[EWAH in Git] has already saved our users roughly a century of
waiting for their fetches to complete (and the equivalent amount of
CPU time in our fileservers).
http://githubengineering.com/counting‑objects/
23
Après une comparaison exhaustive des techniques de
compressions par plage sur les bitmaps, Guzun et al. (ICDE 2014)
en arrive à la conclusion...
EWAH offers the best query time for all distributions.
24
Complexité
Intersection : O(∣S ∣ + ∣S ∣) ou O(min(∣S ∣, ∣S ∣))
Union en place (S ← S ∪ S ): O(∣S ∣ + ∣S ∣) ou O(∣S ∣)
1 2 1 2
2 1 2 1 2 2
25
Roaring Bitmaps
http://roaringbitmap.org/
Apache Lucene, Solr et Elasticsearch, Metamarkets’ Druid, Apache
Spark, Apache Hive, Apache Tez, Netflix Atlas, LinkedIn Pinot,
InfluxDB, Pilosa, Microsoft Visual Studio Team Services (VSTS),
Couchbase's Bleve, Intel’s Optimized Analytics Package (OAP),
Apache Hivemall, eBay’s Apache Kylin.
Mise en oeuvre en Java, C, Go (interopérable)
Point départ: thèse de S. Chambi (UQAM), co‑dirigée avec Robert
Godin
Roaring bitmaps 26
Modèle hybride
Décompose l'espace 32 bits en des sous‑espaces de 16 bits. Au sein
du sous‑espace de 16 bits, utilisons la meilleure structure (contenant):
tableau trié ({1,20,144})
bitset (0b10000101011)
plages ([0,10],[15,20])
C'est Roaring!
Travaux similaires: O'Neil's RIDBit + BitMagic
Roaring bitmaps 27
Voir https://github.com/RoaringBitmap/RoaringFormatSpec
Roaring bitmaps 28
Roaring
Tous les contenants ont 8 kB ou moins (mémoire cache du
processeur)
On prédit le type de structure à la volée pendant les calculs
Par ex. quand un tableau devient trop volumineux, on passe au
bitset
L'union de deux grands tableaux est prédite comme étant un
bitset...
Des dizaines d'heuristiques... réseaux de tri, etc.
Roaring bitmaps 29
Use Roaring for bitmap compression whenever possible. Do not
use other bitmap compression methods (Wang et al., SIGMOD
2017)
kudos for making something that makes my software run 5x faster
(Charles Parker, BigML)
Roaring bitmaps 30
Unions de 200 éléments
taille en bits par éléments :
bitset tableau hachage Roaring
census1881 524 32 195 15.1
weather 15.3 32 195 5.38
cycles par valeur par éléments :
bitset tableau hachage Roaring
census1881 9.85 542 1010 2.6
weather 0.35 94 237 0.16
Roaring Bitmaps: Implementation of an Optimized Software
Library, Software: Practice and Experience Volume 48, Issue 4
April 2018 https://arxiv.org/abs/1709.07821
Roaring bitmaps 31
Compression d'entiers
Technique "standard" : VByte, VarInt, VInt
Utilisation de 1, 2, 3, 4, ... octets per entiers
Utilise un bit par octet pour indique longueur des entiers en octets
Lucene, Protocol Buffers, etc.
32 : 00100000
128 : 10000000 + 00000001
Compression d'entiers 32
varint‑GB de Google
VByte: un embranchement par entier
varint‑GB: un embranchemement par bloc de 4 entiers
chaque bloc de 4 entiers est précédé d'un octet 'descriptif'
Exige de modifier le format (pas compatible avec VByte)
Compression d'entiers 33
Compression d'entiers 34
Accélération par vectorisation
Stepanov (inventeur du STL en C++) travaillant pour Amazon a
proposé varint‑G8IU
Stocke autant d'entiers que possible par blocs de 8 octets
Utilise la vectorisation (SIMD)
Exige de modifier le format (pas compatible avec VByte)
Protégé par un brevet
SIMD‑Based Decoding of Posting Lists, CIKM 2011
https://stepanovpapers.com/SIMD_Decoding_TR.pdf
Compression d'entiers 35
Compression d'entiers 36
Observations de Stepanov et al. (partie 1)
Incapable de vectoriser VByte (original)
Compression d'entiers 37
Accélérer VByte (sans changer le format)
C'est possible nonobstant l'échec de Stepanov et al.
Décodeur avec SIMD: Masked VByte
Travaux réalisés avec Indeed.com (en production)
Jeff Plaisance, Nathan Kurz, Daniel Lemire, Vectorized VByte Decoding,
International Symposium on Web Algorithms 2015, 2015.
Compression d'entiers 38
Compression d'entiers 39
Observations de Stepanov et al. (partie 2)
Possible de vectoriser le varint‑GB de Google, mais moins
performant que varint‑G8IU
Compression d'entiers 40
Stream VByte
Reprend l'idée du varint‑GB de Google
Mais au lieu de mélanger les octets descriptifs avec le reste des
données...
On sépare les octets descriptifs du reste
Daniel Lemire, Nathan Kurz, Christoph Rupp
Stream VByte: Faster Byte‑Oriented Integer Compression
Information Processing Letters 130, 2018
Compression d'entiers 41
Compression d'entiers 42
Compression d'entiers 43
Compression d'entiers 44
Compression d'entiers 45
Stream VByte est utilisé par...
Redis (au sein de RediSearch) https://redislabs.com
upscaledb https://upscaledb.com
Trinity https://github.com/phaistos‑networks/Trinity
Compression d'entiers 46
As you can see, Stream VByte is over 30% faster than the second
fastest, (...) This is quite an impressive improvement in terms of
query execution time, which is almost entirely dominated by
postings list access time (i.e integers decoding speed).
https://medium.com/@markpapadakis/trinity‑updates‑and‑
integer‑codes‑benchmarks‑6a4fa2eb3fd1
Compression d'entiers 47
Pour en savoir plus...
Blogue (2 fois/semaine) : https://lemire.me/blog/
GitHub: https://github.com/lemire
Page personnelle : https://lemire.me/fr/
CRSNG : Faster Compressed Indexes On Next‑Generation
Hardware (2017‑2022)
Twitter @lemire
@lemire 48

Contenu connexe

Tendances

Wygday 2011 - C#5 Async CTP - Reactive Extensions
Wygday 2011  - C#5 Async CTP - Reactive ExtensionsWygday 2011  - C#5 Async CTP - Reactive Extensions
Wygday 2011 - C#5 Async CTP - Reactive Extensionswyggio
 
Programmation sur GPU avec CUDA
Programmation sur GPU avec CUDAProgrammation sur GPU avec CUDA
Programmation sur GPU avec CUDAIn Fine
 
Matlab formation Sound and image Processing
Matlab formation Sound and image ProcessingMatlab formation Sound and image Processing
Matlab formation Sound and image ProcessingKais Baccour
 
[Paris Unity3D meetup] - Système d’instancing dans endless legend reskin
[Paris Unity3D meetup] - Système d’instancing dans endless legend reskin[Paris Unity3D meetup] - Système d’instancing dans endless legend reskin
[Paris Unity3D meetup] - Système d’instancing dans endless legend reskinBeMyApp
 
Traitement des données massives (INF442, A4)
Traitement des données massives (INF442, A4)Traitement des données massives (INF442, A4)
Traitement des données massives (INF442, A4)Frank Nielsen
 
Afup Day 2020 en linge: Les structures de données en PHP
Afup Day 2020 en linge: Les structures de données en PHPAfup Day 2020 en linge: Les structures de données en PHP
Afup Day 2020 en linge: Les structures de données en PHPFrederic Bouchery
 

Tendances (8)

Wygday 2011 - C#5 Async CTP - Reactive Extensions
Wygday 2011  - C#5 Async CTP - Reactive ExtensionsWygday 2011  - C#5 Async CTP - Reactive Extensions
Wygday 2011 - C#5 Async CTP - Reactive Extensions
 
Programmation sur GPU avec CUDA
Programmation sur GPU avec CUDAProgrammation sur GPU avec CUDA
Programmation sur GPU avec CUDA
 
PostgreSQL Meetup Nantes #2
PostgreSQL Meetup Nantes #2PostgreSQL Meetup Nantes #2
PostgreSQL Meetup Nantes #2
 
Matlab formation Sound and image Processing
Matlab formation Sound and image ProcessingMatlab formation Sound and image Processing
Matlab formation Sound and image Processing
 
[Paris Unity3D meetup] - Système d’instancing dans endless legend reskin
[Paris Unity3D meetup] - Système d’instancing dans endless legend reskin[Paris Unity3D meetup] - Système d’instancing dans endless legend reskin
[Paris Unity3D meetup] - Système d’instancing dans endless legend reskin
 
Traitement des données massives (INF442, A4)
Traitement des données massives (INF442, A4)Traitement des données massives (INF442, A4)
Traitement des données massives (INF442, A4)
 
Bitmaps
BitmapsBitmaps
Bitmaps
 
Afup Day 2020 en linge: Les structures de données en PHP
Afup Day 2020 en linge: Les structures de données en PHPAfup Day 2020 en linge: Les structures de données en PHP
Afup Day 2020 en linge: Les structures de données en PHP
 

Similaire à Ingénierie de la performance au sein des mégadonnées

BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseriesBreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseriesXavier MARIN
 
OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...
OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...
OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...Pôle Systematic Paris-Region
 
Développer en natif avec C++11
Développer en natif avec C++11Développer en natif avec C++11
Développer en natif avec C++11Microsoft
 
Mat lab1
Mat lab1Mat lab1
Mat lab1fouadDD
 
Spark-adabra, Comment Construire un DATALAKE ! (Devoxx 2017)
Spark-adabra, Comment Construire un DATALAKE ! (Devoxx 2017) Spark-adabra, Comment Construire un DATALAKE ! (Devoxx 2017)
Spark-adabra, Comment Construire un DATALAKE ! (Devoxx 2017) univalence
 
Digital_Signal_Processors_TG_FULL.pdf
Digital_Signal_Processors_TG_FULL.pdfDigital_Signal_Processors_TG_FULL.pdf
Digital_Signal_Processors_TG_FULL.pdfHouBou3
 
C# et .NET : Enigmes et puzzles
C# et .NET : Enigmes  et puzzlesC# et .NET : Enigmes  et puzzles
C# et .NET : Enigmes et puzzlesMicrosoft
 
Spark - au dela du dataframe avec Tungsten et Catalyst
Spark - au dela du dataframe avec Tungsten et CatalystSpark - au dela du dataframe avec Tungsten et Catalyst
Spark - au dela du dataframe avec Tungsten et CatalystMathieu Goeminne
 
Le cloud-in-a-box avec Cloud Platform System (CPS) et Windows Azure Pack
Le cloud-in-a-box avec Cloud Platform System (CPS) et Windows Azure PackLe cloud-in-a-box avec Cloud Platform System (CPS) et Windows Azure Pack
Le cloud-in-a-box avec Cloud Platform System (CPS) et Windows Azure PackMicrosoft Décideurs IT
 
.NET Microframework: du code, de l&rsquo;électronique, de la robotique
.NET Microframework: du code, de l&rsquo;électronique, de la robotique.NET Microframework: du code, de l&rsquo;électronique, de la robotique
.NET Microframework: du code, de l&rsquo;électronique, de la robotiqueMicrosoft
 
03 big data échelle
03 big data échelle03 big data échelle
03 big data échellePatrick Bury
 
03 big data échelle
03 big data échelle03 big data échelle
03 big data échellePatrick Bury
 
Présentation du logiciel PixInsight
Présentation du logiciel PixInsightPrésentation du logiciel PixInsight
Présentation du logiciel PixInsightDidier Walliang
 
ch2-hadoop-L3-2023-4p (1).pdf
ch2-hadoop-L3-2023-4p (1).pdfch2-hadoop-L3-2023-4p (1).pdf
ch2-hadoop-L3-2023-4p (1).pdfsalmanakbi
 
Modern DevOps - kill the bottleneck (part 2/2)
Modern DevOps - kill the bottleneck (part 2/2)Modern DevOps - kill the bottleneck (part 2/2)
Modern DevOps - kill the bottleneck (part 2/2)Loic Ortola
 
C++ 11 - Tech Days 2014 in Paris
C++ 11 - Tech Days 2014 in ParisC++ 11 - Tech Days 2014 in Paris
C++ 11 - Tech Days 2014 in Parischristophep21
 
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++Microsoft
 

Similaire à Ingénierie de la performance au sein des mégadonnées (20)

BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseriesBreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
 
OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...
OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...
OSIS18_IoT: L'approche machine virtuelle pour les microcontrôleurs, le projet...
 
Implementing a key/value store
Implementing a key/value storeImplementing a key/value store
Implementing a key/value store
 
Développer en natif avec C++11
Développer en natif avec C++11Développer en natif avec C++11
Développer en natif avec C++11
 
Cours de Matlab
Cours de MatlabCours de Matlab
Cours de Matlab
 
Mat lab1
Mat lab1Mat lab1
Mat lab1
 
Spark-adabra, Comment Construire un DATALAKE ! (Devoxx 2017)
Spark-adabra, Comment Construire un DATALAKE ! (Devoxx 2017) Spark-adabra, Comment Construire un DATALAKE ! (Devoxx 2017)
Spark-adabra, Comment Construire un DATALAKE ! (Devoxx 2017)
 
Digital_Signal_Processors_TG_FULL.pdf
Digital_Signal_Processors_TG_FULL.pdfDigital_Signal_Processors_TG_FULL.pdf
Digital_Signal_Processors_TG_FULL.pdf
 
C# et .NET : Enigmes et puzzles
C# et .NET : Enigmes  et puzzlesC# et .NET : Enigmes  et puzzles
C# et .NET : Enigmes et puzzles
 
Spark - au dela du dataframe avec Tungsten et Catalyst
Spark - au dela du dataframe avec Tungsten et CatalystSpark - au dela du dataframe avec Tungsten et Catalyst
Spark - au dela du dataframe avec Tungsten et Catalyst
 
Le cloud-in-a-box avec Cloud Platform System (CPS) et Windows Azure Pack
Le cloud-in-a-box avec Cloud Platform System (CPS) et Windows Azure PackLe cloud-in-a-box avec Cloud Platform System (CPS) et Windows Azure Pack
Le cloud-in-a-box avec Cloud Platform System (CPS) et Windows Azure Pack
 
Inf208
Inf208Inf208
Inf208
 
.NET Microframework: du code, de l&rsquo;électronique, de la robotique
.NET Microframework: du code, de l&rsquo;électronique, de la robotique.NET Microframework: du code, de l&rsquo;électronique, de la robotique
.NET Microframework: du code, de l&rsquo;électronique, de la robotique
 
03 big data échelle
03 big data échelle03 big data échelle
03 big data échelle
 
03 big data échelle
03 big data échelle03 big data échelle
03 big data échelle
 
Présentation du logiciel PixInsight
Présentation du logiciel PixInsightPrésentation du logiciel PixInsight
Présentation du logiciel PixInsight
 
ch2-hadoop-L3-2023-4p (1).pdf
ch2-hadoop-L3-2023-4p (1).pdfch2-hadoop-L3-2023-4p (1).pdf
ch2-hadoop-L3-2023-4p (1).pdf
 
Modern DevOps - kill the bottleneck (part 2/2)
Modern DevOps - kill the bottleneck (part 2/2)Modern DevOps - kill the bottleneck (part 2/2)
Modern DevOps - kill the bottleneck (part 2/2)
 
C++ 11 - Tech Days 2014 in Paris
C++ 11 - Tech Days 2014 in ParisC++ 11 - Tech Days 2014 in Paris
C++ 11 - Tech Days 2014 in Paris
 
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
 

Plus de Daniel Lemire

Accurate and efficient software microbenchmarks
Accurate and efficient software microbenchmarksAccurate and efficient software microbenchmarks
Accurate and efficient software microbenchmarksDaniel Lemire
 
Fast indexes with roaring #gomtl-10
Fast indexes with roaring #gomtl-10 Fast indexes with roaring #gomtl-10
Fast indexes with roaring #gomtl-10 Daniel Lemire
 
Parsing JSON Really Quickly: Lessons Learned
Parsing JSON Really Quickly: Lessons LearnedParsing JSON Really Quickly: Lessons Learned
Parsing JSON Really Quickly: Lessons LearnedDaniel Lemire
 
Next Generation Indexes For Big Data Engineering (ODSC East 2018)
Next Generation Indexes For Big Data Engineering (ODSC East 2018)Next Generation Indexes For Big Data Engineering (ODSC East 2018)
Next Generation Indexes For Big Data Engineering (ODSC East 2018)Daniel Lemire
 
SIMD Compression and the Intersection of Sorted Integers
SIMD Compression and the Intersection of Sorted IntegersSIMD Compression and the Intersection of Sorted Integers
SIMD Compression and the Intersection of Sorted IntegersDaniel Lemire
 
Decoding billions of integers per second through vectorization
Decoding billions of integers per second through vectorizationDecoding billions of integers per second through vectorization
Decoding billions of integers per second through vectorizationDaniel Lemire
 
Logarithmic Discrete Wavelet Transform for High-Quality Medical Image Compres...
Logarithmic Discrete Wavelet Transform for High-Quality Medical Image Compres...Logarithmic Discrete Wavelet Transform for High-Quality Medical Image Compres...
Logarithmic Discrete Wavelet Transform for High-Quality Medical Image Compres...Daniel Lemire
 
Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Daniel Lemire
 
Engineering fast indexes
Engineering fast indexesEngineering fast indexes
Engineering fast indexesDaniel Lemire
 
MaskedVByte: SIMD-accelerated VByte
MaskedVByte: SIMD-accelerated VByteMaskedVByte: SIMD-accelerated VByte
MaskedVByte: SIMD-accelerated VByteDaniel Lemire
 
Roaring Bitmaps (January 2016)
Roaring Bitmaps (January 2016)Roaring Bitmaps (January 2016)
Roaring Bitmaps (January 2016)Daniel Lemire
 
Roaring Bitmap : June 2015 report
Roaring Bitmap : June 2015 reportRoaring Bitmap : June 2015 report
Roaring Bitmap : June 2015 reportDaniel Lemire
 
La vectorisation des algorithmes de compression
La vectorisation des algorithmes de compression La vectorisation des algorithmes de compression
La vectorisation des algorithmes de compression Daniel Lemire
 
Decoding billions of integers per second through vectorization
Decoding billions of integers per second through vectorization  Decoding billions of integers per second through vectorization
Decoding billions of integers per second through vectorization Daniel Lemire
 
Extracting, Transforming and Archiving Scientific Data
Extracting, Transforming and Archiving Scientific DataExtracting, Transforming and Archiving Scientific Data
Extracting, Transforming and Archiving Scientific DataDaniel Lemire
 
Innovation without permission: from Codd to NoSQL
Innovation without permission: from Codd to NoSQLInnovation without permission: from Codd to NoSQL
Innovation without permission: from Codd to NoSQLDaniel Lemire
 
Faster Column-Oriented Indexes
Faster Column-Oriented IndexesFaster Column-Oriented Indexes
Faster Column-Oriented IndexesDaniel Lemire
 
Compressing column-oriented indexes
Compressing column-oriented indexesCompressing column-oriented indexes
Compressing column-oriented indexesDaniel Lemire
 

Plus de Daniel Lemire (20)

Accurate and efficient software microbenchmarks
Accurate and efficient software microbenchmarksAccurate and efficient software microbenchmarks
Accurate and efficient software microbenchmarks
 
Fast indexes with roaring #gomtl-10
Fast indexes with roaring #gomtl-10 Fast indexes with roaring #gomtl-10
Fast indexes with roaring #gomtl-10
 
Parsing JSON Really Quickly: Lessons Learned
Parsing JSON Really Quickly: Lessons LearnedParsing JSON Really Quickly: Lessons Learned
Parsing JSON Really Quickly: Lessons Learned
 
Next Generation Indexes For Big Data Engineering (ODSC East 2018)
Next Generation Indexes For Big Data Engineering (ODSC East 2018)Next Generation Indexes For Big Data Engineering (ODSC East 2018)
Next Generation Indexes For Big Data Engineering (ODSC East 2018)
 
SIMD Compression and the Intersection of Sorted Integers
SIMD Compression and the Intersection of Sorted IntegersSIMD Compression and the Intersection of Sorted Integers
SIMD Compression and the Intersection of Sorted Integers
 
Decoding billions of integers per second through vectorization
Decoding billions of integers per second through vectorizationDecoding billions of integers per second through vectorization
Decoding billions of integers per second through vectorization
 
Logarithmic Discrete Wavelet Transform for High-Quality Medical Image Compres...
Logarithmic Discrete Wavelet Transform for High-Quality Medical Image Compres...Logarithmic Discrete Wavelet Transform for High-Quality Medical Image Compres...
Logarithmic Discrete Wavelet Transform for High-Quality Medical Image Compres...
 
Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)
 
Engineering fast indexes
Engineering fast indexesEngineering fast indexes
Engineering fast indexes
 
MaskedVByte: SIMD-accelerated VByte
MaskedVByte: SIMD-accelerated VByteMaskedVByte: SIMD-accelerated VByte
MaskedVByte: SIMD-accelerated VByte
 
Roaring Bitmaps (January 2016)
Roaring Bitmaps (January 2016)Roaring Bitmaps (January 2016)
Roaring Bitmaps (January 2016)
 
Roaring Bitmap : June 2015 report
Roaring Bitmap : June 2015 reportRoaring Bitmap : June 2015 report
Roaring Bitmap : June 2015 report
 
La vectorisation des algorithmes de compression
La vectorisation des algorithmes de compression La vectorisation des algorithmes de compression
La vectorisation des algorithmes de compression
 
OLAP and more
OLAP and moreOLAP and more
OLAP and more
 
Decoding billions of integers per second through vectorization
Decoding billions of integers per second through vectorization  Decoding billions of integers per second through vectorization
Decoding billions of integers per second through vectorization
 
Extracting, Transforming and Archiving Scientific Data
Extracting, Transforming and Archiving Scientific DataExtracting, Transforming and Archiving Scientific Data
Extracting, Transforming and Archiving Scientific Data
 
Innovation without permission: from Codd to NoSQL
Innovation without permission: from Codd to NoSQLInnovation without permission: from Codd to NoSQL
Innovation without permission: from Codd to NoSQL
 
Write good papers
Write good papersWrite good papers
Write good papers
 
Faster Column-Oriented Indexes
Faster Column-Oriented IndexesFaster Column-Oriented Indexes
Faster Column-Oriented Indexes
 
Compressing column-oriented indexes
Compressing column-oriented indexesCompressing column-oriented indexes
Compressing column-oriented indexes
 

Ingénierie de la performance au sein des mégadonnées

  • 1. Ingénierie de la performance au sein des mégadonnées Daniel Lemire et collaborateurs https://lemire.me
  • 2. “One Size Fits All”: An Idea Whose Time Has Come and Gone (Stonebraker, 2005) 2
  • 3. Redécouvrir Unix Plusieurs composantes spécialisées et réutilisables: Calcite : SQL + optimisation Hadoop etc. "Make your own database from parts" 3
  • 4. Ensembles Un concept fondamental (ensemble de documents, d'enregistrements) → Pour la performance, on utilise des ensemble d'entiers (identifiants). → Souvent des entiers à 32 bits suffise (identifiants locaux). 4
  • 5. tests : x ∈ S? intersections : S ∩ S unions : S ∪ S differences : S ∖ S Jaccard/Tanimoto : ∣S ∩ S ∣/∣S ∪ S ∣ iteration: for x in S do print(x) 2 1 2 1 2 1 1 1 1 2 5
  • 6. Mise en oeuvre tableaux triés ( std::vector<uint32_t> ) tables de hachage ( java.util.HashSet<Integer> ,  std::unordered_set<uint32_t> ) … bitmap ( java.util.BitSet ) bitmap compressé 6
  • 7. Tableaux while (low <= high) { int mI = (low + high) >>> 1; int m = array.get(mI); if (m < key) { low = mI + 1; } else if (m > key) { high = mI - 1; } else { return mI; } } return -(low + 1); 7
  • 8. table de hachage valeur x stockée à l'index h(x) accès aléatoire à une valeur rapide accès ordonné pénible 8
  • 9. accès ordonné pénible [15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7] [15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7] [15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7] [15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7] [15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7] [15, 3, 0, 6, 11, 4, 5, 9, 12, 13, 8, 2, 1, 14, 10, 7] (Robin Hood, sondage linéaire, fonction de mixage MurmurHash3) 9
  • 10. Opérations ensemblistes sur les tables de hachage h1 <- hash set h2 <- hash set ... for(x in h1) { insert x in h2 // échec (mémoire tampon) } 10
  • 11. Faire "crasher" Swift var S1 = Set<Int>(1...size) var S2 = Set<Int>() for i in S1 { S2.insert(i) } 11
  • 12. Quelques chiffres: une demi‑heure pour 64M taille temps (s) 1M 0.8 8M 22 64M 1400 Maps and sets can have quadratic‑time performance https://lemire.me/blog/2017/01/30/maps‑and‑sets‑can‑have‑ quadratic‑time‑performance/ Rust hash iteration+reinsertion https://accidentallyquadratic.tumblr.com/post/153545455987/ru st‑hash‑iteration‑reinsertion 12
  • 13. 13
  • 14. Les bitmaps ou bitsets Façon efficace de représenter les ensembles d'entiers. Par ex., 0, 1, 3, 4 devient  0b11011 ou "27". {0} →  0b00001  {0, 3} →  0b01001  {0, 3, 4} →  0b11001  {0, 1, 3, 4} →  0b11011  14
  • 15. Manipuler un bitmap Processeur 64 bits. Étant donné  x , l'index du mot est  x/64 et l'index du bit est  x % 64 . add(x) { array[x / 64] |= (1 << (x % 64)) } 15
  • 16. Est‑ce que c'est rapide? index = x / 64 -> un shift mask = 1 << ( x % 64) -> un shift array[ index ] |- mask -> un OR avec la mémoire Un bit par ≈ 1.65 cycles à cause de la superscalarité 16
  • 17. Parallélisme des bits Intersection entre {0, 1, 3} et {1, 3} équivaut à une seule opération AND entre  0b1011 et  0b1010 . Résultat est  0b1010 ou {1, 3}. Aucun embranchement! 17
  • 18. Les bitmaps bénéficient des mots étendus SIMD: Single Intruction Multiple Data SSE (Pentium 4), ARM NEON 128 bits AVX/AVX2 (256 bits) AVX‑512 (512 bits) AVX‑512 est maintenant disponible (par ex. chez Dell!) avec les processors ayant une microarchitecture Skylake‑X. 18
  • 19. Similarité ensembliste avec les bitmaps Jaccard/Tanimoto : ∣S ∩ S ∣/∣S ∪ S ∣ devient 1.15 cycles par paire de mots (64‑bit) Wojciech Muła, Nathan Kurz, Daniel Lemire Faster Population Counts Using AVX2 Instructions Computer Journal 61 (1), 2018 (adopté par clang) 1 1 1 2 ∣B  OR B ∣1 2 ∣B  AND B ∣1 2 19
  • 20. Les bitsets peuvent être gourmants {1, 32000, 64000} : 1000 octets pour 3 nombres On utilise donc la compression! 20
  • 21. Qu'est‑ce qu'on entend par compression? Modèle conventionnel: compresse, stocke, décompresse, traite; RAM → CPU → RAM → CPU Modèle performant: compresse, stocke, traite sans décompression; RAM → CPU 21
  • 22. Git (GitHub) utilise EWAH Codage par plage Exemple: 000000001111111100 est 00000000 − 11111111 − 00 On peut coder les longues séquences de 1 ou de 0 de manière concise. https://github.com/git/git/blob/master/ewah/bitmap.c 22
  • 23. [EWAH in Git] has already saved our users roughly a century of waiting for their fetches to complete (and the equivalent amount of CPU time in our fileservers). http://githubengineering.com/counting‑objects/ 23
  • 24. Après une comparaison exhaustive des techniques de compressions par plage sur les bitmaps, Guzun et al. (ICDE 2014) en arrive à la conclusion... EWAH offers the best query time for all distributions. 24
  • 25. Complexité Intersection : O(∣S ∣ + ∣S ∣) ou O(min(∣S ∣, ∣S ∣)) Union en place (S ← S ∪ S ): O(∣S ∣ + ∣S ∣) ou O(∣S ∣) 1 2 1 2 2 1 2 1 2 2 25
  • 26. Roaring Bitmaps http://roaringbitmap.org/ Apache Lucene, Solr et Elasticsearch, Metamarkets’ Druid, Apache Spark, Apache Hive, Apache Tez, Netflix Atlas, LinkedIn Pinot, InfluxDB, Pilosa, Microsoft Visual Studio Team Services (VSTS), Couchbase's Bleve, Intel’s Optimized Analytics Package (OAP), Apache Hivemall, eBay’s Apache Kylin. Mise en oeuvre en Java, C, Go (interopérable) Point départ: thèse de S. Chambi (UQAM), co‑dirigée avec Robert Godin Roaring bitmaps 26
  • 27. Modèle hybride Décompose l'espace 32 bits en des sous‑espaces de 16 bits. Au sein du sous‑espace de 16 bits, utilisons la meilleure structure (contenant): tableau trié ({1,20,144}) bitset (0b10000101011) plages ([0,10],[15,20]) C'est Roaring! Travaux similaires: O'Neil's RIDBit + BitMagic Roaring bitmaps 27
  • 29. Roaring Tous les contenants ont 8 kB ou moins (mémoire cache du processeur) On prédit le type de structure à la volée pendant les calculs Par ex. quand un tableau devient trop volumineux, on passe au bitset L'union de deux grands tableaux est prédite comme étant un bitset... Des dizaines d'heuristiques... réseaux de tri, etc. Roaring bitmaps 29
  • 30. Use Roaring for bitmap compression whenever possible. Do not use other bitmap compression methods (Wang et al., SIGMOD 2017) kudos for making something that makes my software run 5x faster (Charles Parker, BigML) Roaring bitmaps 30
  • 31. Unions de 200 éléments taille en bits par éléments : bitset tableau hachage Roaring census1881 524 32 195 15.1 weather 15.3 32 195 5.38 cycles par valeur par éléments : bitset tableau hachage Roaring census1881 9.85 542 1010 2.6 weather 0.35 94 237 0.16 Roaring Bitmaps: Implementation of an Optimized Software Library, Software: Practice and Experience Volume 48, Issue 4 April 2018 https://arxiv.org/abs/1709.07821 Roaring bitmaps 31
  • 32. Compression d'entiers Technique "standard" : VByte, VarInt, VInt Utilisation de 1, 2, 3, 4, ... octets per entiers Utilise un bit par octet pour indique longueur des entiers en octets Lucene, Protocol Buffers, etc. 32 : 00100000 128 : 10000000 + 00000001 Compression d'entiers 32
  • 33. varint‑GB de Google VByte: un embranchement par entier varint‑GB: un embranchemement par bloc de 4 entiers chaque bloc de 4 entiers est précédé d'un octet 'descriptif' Exige de modifier le format (pas compatible avec VByte) Compression d'entiers 33
  • 35. Accélération par vectorisation Stepanov (inventeur du STL en C++) travaillant pour Amazon a proposé varint‑G8IU Stocke autant d'entiers que possible par blocs de 8 octets Utilise la vectorisation (SIMD) Exige de modifier le format (pas compatible avec VByte) Protégé par un brevet SIMD‑Based Decoding of Posting Lists, CIKM 2011 https://stepanovpapers.com/SIMD_Decoding_TR.pdf Compression d'entiers 35
  • 37. Observations de Stepanov et al. (partie 1) Incapable de vectoriser VByte (original) Compression d'entiers 37
  • 38. Accélérer VByte (sans changer le format) C'est possible nonobstant l'échec de Stepanov et al. Décodeur avec SIMD: Masked VByte Travaux réalisés avec Indeed.com (en production) Jeff Plaisance, Nathan Kurz, Daniel Lemire, Vectorized VByte Decoding, International Symposium on Web Algorithms 2015, 2015. Compression d'entiers 38
  • 40. Observations de Stepanov et al. (partie 2) Possible de vectoriser le varint‑GB de Google, mais moins performant que varint‑G8IU Compression d'entiers 40
  • 41. Stream VByte Reprend l'idée du varint‑GB de Google Mais au lieu de mélanger les octets descriptifs avec le reste des données... On sépare les octets descriptifs du reste Daniel Lemire, Nathan Kurz, Christoph Rupp Stream VByte: Faster Byte‑Oriented Integer Compression Information Processing Letters 130, 2018 Compression d'entiers 41
  • 46. Stream VByte est utilisé par... Redis (au sein de RediSearch) https://redislabs.com upscaledb https://upscaledb.com Trinity https://github.com/phaistos‑networks/Trinity Compression d'entiers 46
  • 47. As you can see, Stream VByte is over 30% faster than the second fastest, (...) This is quite an impressive improvement in terms of query execution time, which is almost entirely dominated by postings list access time (i.e integers decoding speed). https://medium.com/@markpapadakis/trinity‑updates‑and‑ integer‑codes‑benchmarks‑6a4fa2eb3fd1 Compression d'entiers 47
  • 48. Pour en savoir plus... Blogue (2 fois/semaine) : https://lemire.me/blog/ GitHub: https://github.com/lemire Page personnelle : https://lemire.me/fr/ CRSNG : Faster Compressed Indexes On Next‑Generation Hardware (2017‑2022) Twitter @lemire @lemire 48