Skip to content

Commit

Permalink
Improved Gonk usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Nov 9, 2022
1 parent 395ca55 commit 0ab9fd1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ require (
github.com/jfcg/sixb v1.3.5 // indirect
github.com/jfcg/sorty/v2 v2.0.8 // indirect
github.com/k-sone/ipmigo v0.0.0-20190922011749-b22c7a70e949 // indirect
github.com/lkarlslund/gonk v0.0.0-20221102145256-2b4b4974a471 // indirect
github.com/lkarlslund/gonk v0.0.0-20221109093557-268a62c7ce0b // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/open-networks/go-msgraph v0.3.1 // indirect
github.com/open2b/scriggo v0.56.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/peterrk/slices v0.0.0-20220825100938-df6f4b667142 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/tealeg/xlsx v1.0.5 // indirect
golang.org/x/exp v0.0.0-20221028150844-83b7d23a625f // indirect
golang.org/x/exp v0.0.0-20221108223516-5d533826c662 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/tools v0.2.0 // indirect
gopkg.in/gcfg.v1 v1.2.3 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ github.com/lkarlslund/go-win64api v0.0.0-20211005130710-d4f2d07ed091 h1:6y0mbZnT
github.com/lkarlslund/go-win64api v0.0.0-20211005130710-d4f2d07ed091/go.mod h1:JFCoCajhTrJw5YFNm/Xm0o+lt5jhY974icELnvnVFdc=
github.com/lkarlslund/gonk v0.0.0-20221102145256-2b4b4974a471 h1:G9NVrY4Rm1p4Jbsina4hImNACxeYYJ4iE2jGEUKT3K0=
github.com/lkarlslund/gonk v0.0.0-20221102145256-2b4b4974a471/go.mod h1:UDXqvYw0IMD1tS9gAdVJwgavVjKZqOpMJx1YOpB8L7A=
github.com/lkarlslund/gonk v0.0.0-20221109093557-268a62c7ce0b h1:hS4mnPgbhQnIg3NHz0+wnbzQ2hOsD/589cKPp4zSy6U=
github.com/lkarlslund/gonk v0.0.0-20221109093557-268a62c7ce0b/go.mod h1:JVKgbXi+vkcXfvUFj4mbyOP51EZRptWVxQOqVHOsDTw=
github.com/lkarlslund/ldap/v3 v3.4.4-1 h1:dcVlqedaugh0UtxgvgHMn83g4ARrmCupHvJiJ7SQb4c=
github.com/lkarlslund/ldap/v3 v3.4.4-1/go.mod h1:0wE7xreiGneIlOw9d76AykHNfq/8lNpV8ZO0A/2xnmc=
github.com/lkarlslund/stringdedup v0.6.2 h1:IcoGuXAuZxjntVnxTi7/C+RFh+gVc5wCyt4gkHp9FxA=
Expand Down Expand Up @@ -560,6 +562,8 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
golang.org/x/exp v0.0.0-20221028150844-83b7d23a625f h1:Al51T6tzvuh3oiwX11vex3QgJ2XTedFPGmbEVh8cdoc=
golang.org/x/exp v0.0.0-20221028150844-83b7d23a625f/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp v0.0.0-20221108223516-5d533826c662 h1:QIza2Vre5WI+NE5AQ6Wi2nGDgDOckLCHJdhcM/kxcfw=
golang.org/x/exp v0.0.0-20221108223516-5d533826c662/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
1 change: 1 addition & 0 deletions modules/engine/attributevaluemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (ave AttributeValuesEvaluator) LessThan(ave2 AttributeValuesEvaluator) bool
}

func (avm *AttributeValueMap) init(preloadAttributes int) {
avm.m.Init(preloadAttributes)
// avm.m = haxmap.New[Attribute, AttributeValues](1)
// avm.m = make(map[Attribute]AttributeValues)
// avm.m = xsync.NewTypedMapOf[Attribute, AttributeValues](func(a Attribute) uint64 {
Expand Down
23 changes: 16 additions & 7 deletions modules/engine/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/lkarlslund/adalanche/modules/dedup"
"github.com/lkarlslund/adalanche/modules/ui"
"github.com/lkarlslund/adalanche/modules/windowssecurity"
"github.com/lkarlslund/gonk"
"github.com/lkarlslund/stringdedup"
)

Expand Down Expand Up @@ -53,7 +54,7 @@ var IgnoreBlanks = "_IGNOREBLANKS_"

func NewObject(flexinit ...interface{}) *Object {
var result Object
result.init(1)
result.init(0)
result.setFlex(flexinit...)

return &result
Expand Down Expand Up @@ -139,7 +140,6 @@ func (target *Object) AbsorbEx(source *Object, fast bool) {
// Keep normies out
target.lockwith(source)

ongoingAbsorbs.Store(source, target)
if !source.status.CompareAndSwap(1, 2) {
// We're being absorbed, nom nom
panic("Can only absorb valid objects")
Expand All @@ -162,7 +162,12 @@ func (target *Object) AbsorbEx(source *Object, fast bool) {

// fmt.Println("----------------------------------------")
absorbCriticalSection.Lock()
ongoingAbsorbs.Store(source, target)
source.edges[Out].Range(func(outgoingTarget *Object, edges EdgeBitmap) bool {
if source == outgoingTarget {
panic("Pointing at myself")
}

// Load edges from target, and merge with source edges
target.edges[Out].setEdges(outgoingTarget, edges)
source.edges[Out].del(outgoingTarget)
Expand Down Expand Up @@ -265,6 +270,8 @@ func (target *Object) AbsorbEx(source *Object, fast bool) {
}
source.parent = nil
}

ongoingAbsorbs.Delete(source)
absorbCriticalSection.Unlock()

// Move the securitydescriptor, as we dont have the attribute saved to regenerate it (we throw it away at import after populating the cache)
Expand All @@ -284,7 +291,6 @@ func (target *Object) AbsorbEx(source *Object, fast bool) {
if !source.status.CompareAndSwap(2, 3) {
panic("Unpossible absorption mutation occurred")
}
ongoingAbsorbs.Delete(source)

target.unlockwith(source)
}
Expand Down Expand Up @@ -908,12 +914,15 @@ func (o *Object) Meta() map[string]string {

func (o *Object) init(preloadAttributes int) {
o.id = ObjectID(atomic.AddUint32(&idcounter, 1))
if preloadAttributes == 0 {
preloadAttributes = 1
}
o.edges[In].init()
o.edges[Out].init()
o.values.init(preloadAttributes)
if preloadAttributes > 0 {
o.values.init(preloadAttributes)
o.values.m.GrowStrategy(gonk.FourItems)
} else {
o.values.m.GrowStrategy(gonk.HalfMax2048)
}
o.values.m.ReindexStrategy(gonk.OnGet)
o.status.Store(1)
// onAddObject(o)
}
Expand Down

0 comments on commit 0ab9fd1

Please sign in to comment.