Skip to content

Commit

Permalink
close #88: now honoring stack memory option
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-noga committed Dec 31, 2023
1 parent 12a9c16 commit 181eff6
Show file tree
Hide file tree
Showing 4 changed files with 337 additions and 308 deletions.
4 changes: 2 additions & 2 deletions cmd/nightlight/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Flags:
}

// create context
c := ops.NewContext(logWriter, stats.LSEstimatorMode(*lsEst))
c := ops.NewContext(logWriter, int(*stMemory), stats.LSEstimatorMode(*lsEst))

// glob filename arguments into an opLoadMany operator
var err error
Expand All @@ -300,7 +300,7 @@ Flags:
switch args[0] {
case "serve":
rest.MakeSandbox(*chroot, int(*setuid))
rest.Serve(int(*port))
rest.Serve(int(*port), int(*stMemory))

case "stats":
opSeq := ops.NewOpSequence(opLoadMany, opPreProc)
Expand Down
4 changes: 2 additions & 2 deletions internal/ops/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ type Context struct {
StatsBufWriter *bufio.Writer `json:"-"` // buffered writer for the output file. use this
}

func NewContext(log io.Writer, lsEstimatorMode stats.LSEstimatorMode) *Context {
func NewContext(log io.Writer, stMemory int, lsEstimatorMode stats.LSEstimatorMode) *Context {
memoryMB := int(memory.TotalMemory() / 1024 / 1024)
return &Context{
Log: log,
LSEstimatorMode: lsEstimatorMode,
MemoryMB: memoryMB,
StackMemoryMB: memoryMB * 7 / 10,
StackMemoryMB: stMemory,
MaxThreads: runtime.GOMAXPROCS(0),
}
}
Expand Down
Loading

0 comments on commit 181eff6

Please sign in to comment.