Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poll Manager should be initialized lazily #259

Closed
ItalyPaleAle opened this issue Jun 6, 2023 · 2 comments
Closed

Poll Manager should be initialized lazily #259

ItalyPaleAle opened this issue Jun 6, 2023 · 2 comments
Assignees
Labels

Comments

@ItalyPaleAle
Copy link

Describe the bug

This package includes an init() method which is executed when the package is imported, even if not used:

netpoll/poll_manager.go

Lines 44 to 51 in 4b09897

func init() {
var loops = runtime.GOMAXPROCS(0)/20 + 1
pollmanager = &manager{}
pollmanager.SetLoadBalance(RoundRobin)
pollmanager.SetNumLoops(loops)
setLoggerOutput(os.Stderr)
}

We import this package in Dapr to allow using Kitex as a binding. Using Kitex is optional, but because of this init() method allocating a poll manager, it causes additional goroutines (and more heap allocations) for every user.

To Reproduce

  1. Import the package
  2. Observe that a number of goroutines is automatically created

Expected behavior

Poll Manager should be initialized lazily, only when first needed.

@joway
Copy link
Member

joway commented Jun 7, 2023

@ItalyPaleAle Thanks for reporting. I think it's make sense. We will implement lazy initialization in next version.

@joway joway self-assigned this Jun 7, 2023
@joway joway added the feature label Jun 7, 2023
@joway
Copy link
Member

joway commented Feb 21, 2024

#306

@joway joway closed this as completed Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants