Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@guptadevagya
Copy link
Contributor

No description provided.

Copy link
Member

@tylerharter tylerharter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@@ -23,22 +23,13 @@ func SandboxPoolFromConfig(name string, sizeMb int) (cf SandboxPool, err error)
return nil, fmt.Errorf("invalid sandbox type: '%s'", common.Conf.Sandbox)
}

func fillMetaDefaults(meta *SandboxMeta) *SandboxMeta {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why get rid of this? Isn't it more convenient to populate everything in meta instead of having a separate memLimitMB in SOCKContainer? I don't want to add a bunch of fields to SOCKContainer as we have more resource types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed fillMetaDefaults because I wanted the resource defaults to be resolved closer to sandbox creation, and thought it might be cleaner to pass everything through Limits. That said, I see your concern about duplicating fields in SOCKContainer. I can reintroduce fillMetaDefaults and avoid the extra field so we don’t scatter defaults across places.

CPUPercent int
Installs []string
Imports []string
Limits *common.Limits // Optional resource limits to override worker defaults.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think things we be cleaner if we make it not optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I kept it optional was to allow distinguishing between “use worker defaults” vs “explicitly set to 0.” But I agree it adds complexity, and it should be cleaner if we always populate Limits. I’ll update this so Limits is non-optional and always available.

}

t2 := common.T0("ImportCache.createChildSandboxFromNode:childSandboxPool.Create")
// Use the meta object from the function invocation, which contains the correct limits.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need the comment. Is it correct? Or could the child sandbox we're creating be another zygote, not associated with the current function request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right - the comment isn’t entirely accurate because the child sandbox could itself be a zygote.

maxRuntime = time.Duration(linst.lfunc.Meta.Config.MaxRuntimeSec) * time.Second
}

// make the request in a goroutine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to create a new goroutine for this? Client already has a Timeout field https://pkg.go.dev/net/http#Client. Timeout is probably something we need to look at more closely, but as a separate PR. I think we should look at Go contexts and see if they can help us do timeout more elegantly (https://pkg.go.dev/context#example-WithTimeout).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I added the goroutine approach because I wanted per-lambda runtime limits independent of the global client timeout. But I agree that Client.Timeout or contexts would be a better long-term solution. Happy to drop the goroutine for now and explore contexts in a follow-up PR.

sb, err = f.lmgr.ZygoteProvider.Create(f.lmgr.sbPool, true, linst.codeDir, scratchDir, meta, f.rtType)
if err != nil {
f.printf("failed to get Sandbox from import cache")
f.printf("failed to get Sandbox from import cache: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use %w for errors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - I’ll switch to %w for proper error wrapping.

pkg = packages.NormalizePkg(pkg)
sandboxMeta.Installs = append(sandboxMeta.Installs, pkg)

if file != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can move some of this to a separate parseRequirementsTxt to keep parseMeta simpler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I’ll refactor requirements parsing into a parseRequirementsTxt helper so parseMeta stays focused.

Triggers Triggers `yaml:"triggers"` // List of HTTP triggers
// Additional configurations can be added here.
Limits Limits `yaml:"limits,omitempty"`
MaxRuntimeSec int `yaml:"max_runtime_sec,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if MaxRuntimeSec should be part of Limits?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it in LambdaConfig separately since it felt more like a behavior toggle than a resource limit. I’m open to moving it under Limits to keep configs consistent!

@guptadevagya guptadevagya force-pushed the feature/per-lambda-limits branch from 83f263c to 3ac5525 Compare September 22, 2025 23:32
Copy link
Member

@tylerharter tylerharter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emailed some thoughts, but most important is that this should be multiple, smaller PRs. E.g., all the improved error message stuff should be separate.

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.

2 participants