Skip to content

feature: improve performance if the element of the Value of *Model does not implement the AfterFindable interface. #799

Closed
@seedeed

Description

@seedeed

Description

I found that the afterFind method of *Model would create a log of goroutines via *errgroup.Group.Go(...) even if the element of the Value of *Model does not implement the AfterFindable interface, which might cause a lot of unneeded CPU cost. To avoid this, I think we could move the AfterFindable interface checking out of the Go function. If this's really a problem, I think I could submit a PR to fix it.

pop/callbacks.go

Lines 32 to 43 in 17f09c0

for i := 0; i < rv.Len(); i++ {
func(i int) {
wg.Go(func() error {
y := rv.Index(i)
y = y.Addr()
if x, ok := y.Interface().(AfterFindable); ok {
return x.AfterFind(c)
}
return nil
})
}(i)
}

Additional Information

No response

Activity

github-actions

github-actions commented on Dec 27, 2022

@github-actions

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment. Otherwise, this will be closed in 7 days.

github-actions

github-actions commented on Jan 3, 2023

@github-actions

This issue was closed because it has been stalled for 30+7 days with no activity.

added
s: triageSome tests need to be run to confirm the issue
and removed on Jan 6, 2023
reopened this on Jan 6, 2023
added a commit that references this issue on Jan 13, 2023
89774fa
sio4

sio4 commented on Jan 13, 2023

@sio4
Member

Hi @seedeed, Thank you for reporting this issue. I agree with you, the block could spend unnecessary resources.

The block was recently touched with a new thing, and I opened a PR for your issue after that. The PR is #805, and the specific commit is 89774fa. Please take a look at the PR and/or the commit and give me feedback if the direction is the same as your idea, or please let me know your idea if you have another good way.

Thanks in advance!

added this to the v6.1.1 milestone on Jan 13, 2023
self-assigned this
on Jan 13, 2023
removed
s: triageSome tests need to be run to confirm the issue
on Jan 13, 2023

4 remaining items

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

Metadata

Metadata

Assignees

Labels

s: acceptedThis proposal was accepted. Someone can start working on it.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    feature: improve performance if the element of the Value of *Model does not implement the AfterFindable interface. · Issue #799 · gobuffalo/pop