Seren1. SEREN
Sérialisation
& magie noire
1
3. SEREN ?
• La sérialisation est utilisée partout
• Efficace et robuste
• Mais elle peut être améliorée !
• … Automatiquement ?
3
4. SEREN ?
• SEREN : Serialization Enhancer
• Agent Java
• Bytecode engineering
• Améliore vos POJO !
4
5. • Se branche sur le mécanisme TECH
standard de sérialisation
• Génère des méthodes optimisées
writeObject & readObject
writeReplace writeObject
10010101
01010101
01010100
10010101
01011001
01010100
readResolve readObject
5
6. TECH
• Sérialiser un Objet est coûteux
• Ecrire seulement les données utiles
• Wrappers numériques & Strings
6
7. TECH
• Wrappers numériques
- booléen pour gérer "null"
- valeur primitive
• Strings
- booléen pour gérer "null"
- caractères UTF8
7
8. TECH
• Quelles classes ?
• ClassFilters
- PackageList
- PackagePattern
- ClassPattern
- Annotation
- Custom !
8
9. TECH
• Quels champs ?
• Non-transient
Non static
• Champs "final"
- Reflexion ?
- Unsafe ?
- Assignation directe
9
10. • Classpath USAGE
- javassist.jar
- seren.properties
• Option de JVM
-javaagent:seren.jar
• Votre code
Aucune modification !
10
11. Seren.properties USAGE
// Seren configuration
seren.filter=byPackageList
seren.verbose=true
// Filter definition
filter.byPackageList=seren.filter.PackageListFilter
filter.byPackageList.packages=com.company.project.model
11
12. • Graphe d'objets PERFS
• Champs
• Optimisations existantes
• Destination du flux
12
13. 500
PERFS
450
400
String, fixe
350
Java : 380 ms
300
250
200
Seren : 425 ms
150
100
50 Boost : x 0.9
0
13
14. 1000
PERFS
900
800
String, aléatoire
700
Java : 920 ms
600
500
400
Seren : 510 ms
300
200
100 Boost : x 1.8
0
14
15. 500
PERFS
450
400
Integer < 128
350
Java : 400 ms
300
250
200
Seren : 345 ms
150
100
50 Boost : x 1.15
0
15
16. 1000
PERFS
900
800
Integer >= 128
700
Java : 880 ms
600
500
400
Seren : 350 ms
300
200
100 Boost : x 2.5
0
16
17. POJO
3000
2500 - Long id PERFS
- String firstName
2000
- String lastName
1500
1000
Java : 2090 ms
Seren : 690 ms
500
0
Boost : x 3
17
18. 3000
POJO
- Long id
2500
- String firstName
PERFS
2000
- String lastName
- Date birthDate
1500
1000 Java : 2930 ms
500
Seren : 1220 ms
0
Boost : x 2.4
18
19. 60000
50000 PERFS
40000
thrift-protobuf-compare
30000 .googlecode.com
20000
Boost : x 1.04 – 1.09
10000
0
19
20. • Code
http://github.com/oliviercroisier/seren
• Licence & MORE...
3-Clause BSD Licence
• Merci à
- Heinz Kabutz
- Thomas Darimont
- Thomas Segismont
20