mbenkmann / limux-gosa

GOsa² is a web based adminstration tool for user accounts, groups, servers, clients, and many other things.
18 stars 5 forks source link

use meta-information to optimize LDIFToHash memory usage #110

Closed mbenkmann closed 9 years ago

mbenkmann commented 9 years ago

From matthias...@gmail.com on April 02, 2013 16:41:13

type AttributeInfo struct { base64 bool // attribute's text is always encoded base64 name String // static string to use for attribute's name }

var LDIFToHashInfo map[[]byte]AttributeInfo

The map maps names as the occur in LDIFs like "Template" and "Templates" to an AttributeInfo. This serves 2 purposes:

a) This mapping is done before extracting the attibute name as a string and therefore prevents the creation of 10000 copies of a string like "Template" because only the 1 static string will be used.

b) If base64 is true and the LDIF value is already base64 encoded, then it will not be decoded. If it is not encoded, it will be encoded. This means that the call to EncodeBase64 in db/hooks.go:PackageListHook() can be eliminated and again we save the creation of multiple intermediate buffers.

Original issue: http://code.google.com/p/go-susi/issues/detail?id=110

mbenkmann commented 9 years ago

From matthias...@gmail.com on April 17, 2013 12:13:43

Implemented in 5605c82c5d34

Status: Done
Labels: Milestone-4