Skip to content

Optimize tags usage and Distribution map - #1653

Open
badetitou wants to merge 2 commits into
developmentfrom
distribution-map-optimization
Open

badetitou wants to merge 2 commits into
developmentfrom
distribution-map-optimization

Conversation

@badetitou

@badetitou badetitou commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

I discovered that using tag with large distribution map is very inefficient. This PR aims to improve it.

Improvment explanation

The previous code:

isApplicableTo: anEntity

	^ self taggedEntities anySatisfy: [ :e | e = anEntity ]

Was

  1. iterate over the all model then for each entity
  2. Search if it has the tags self and return the collection of entities with tag self
  3. Check if the collection includes anEntity

The correction propose to check directly in anEntity tag, if the tag self is present.

bench

"setup bench"
model := FamixTagTestModel new.
helloTag := model createTagNamed: 'hello'.
1 to: 10000 do: [ :idx | 
	|clazz|
	clazz := FamixTagTestClass named: 'aClass1' model: model.
	idx even ifTrue: [ clazz tagWith: helloTag ] 
	].
classes := (model allWithType: FamixTagTestClass).

"bench"

[classes do: [ :class | helloTag isApplicableTo: class ]] bench.

"Before optimization"
"3 iterations in 6 seconds 542 milliseconds. 0.459 per second"

"After optimization"
"1,474 iterations in 5 seconds 2 milliseconds. 294.682 per second"

First test

First test with time profiler and trying unsafe improvment of isApplicableTo: shows this (from 110 761 ms to 5 977 ms)

image

I'll add tests and investigate more

Might need further investigation

  • I don't achieve to create dynamic Tag and transmit it to the Distribution map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant