diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index b07ea8c76..f0df695aa 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -19,9 +19,14 @@ limitations under the License. // This is a leaf package, without dependencies. package constants -// MaxBlobSize is the size of a single blob in Camlistore. -// -// TODO: formalize this in the specs. This value of 16 MB is less than -// App Engine's 32 MB request limit, much more than Venti's limit, and -// much more than the ~64 KB & 256 KB chunks that the FileWriter make +// MaxBlobSize is the max size of a single blob in Camlistore, in bytes. const MaxBlobSize = 16 << 20 + +// DefaultMaxResizeMem is the default maximum number of bytes that +// will be allocated at peak for uncompressed pixel data while +// generating thumbnails or other resized images. +// +// If a single image is larger than the configured size for an +// ImageHandler, we'll never successfully resize it. 256M is a max +// image of ~9.5kx9.5k*3. +const DefaultMaxResizeMem = 256 << 20 diff --git a/pkg/server/image.go b/pkg/server/image.go index 7b7533e94..398b99e4f 100644 --- a/pkg/server/image.go +++ b/pkg/server/image.go @@ -44,17 +44,7 @@ import ( _ "camlistore.org/third_party/github.com/nf/cr2" ) -const ( - imageDebug = false - // This is the default maximum concurrent number of bytes we allocate for - // uncompressed pixel data while generating thumbnails. - // If a single image is larger than the configured size for an - // ImageHandler, we'll never successfully resize it. - // 256M is a max image of ~9.5kx9.5k*3. - // TODO(wathiede) move to pkg/constants when https://camlistore.org/r/1536 - // lands. - defaultMaxResizeBytes = 256 << 20 -) +const imageDebug = false var ( imageBytesServedVar = expvar.NewInt("image-bytes-served") diff --git a/pkg/server/publish.go b/pkg/server/publish.go index ee881b267..8600887d0 100644 --- a/pkg/server/publish.go +++ b/pkg/server/publish.go @@ -38,7 +38,8 @@ import ( "camlistore.org/pkg/auth" "camlistore.org/pkg/blob" "camlistore.org/pkg/blobserver" - "camlistore.org/pkg/client" // just for NewUploadHandleFromString. move elsewhere? + "camlistore.org/pkg/client" + "camlistore.org/pkg/constants" // just for NewUploadHandleFromString. move elsewhere? "camlistore.org/pkg/fileembed" "camlistore.org/pkg/httputil" "camlistore.org/pkg/jsonconfig" @@ -101,7 +102,7 @@ func newPublishFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Han bootstrapSignRoot := conf.OptionalString("devBootstrapPermanodeUsing", "") rootNode := conf.OptionalList("rootPermanode") ph.sourceRoot = conf.OptionalString("sourceRoot", "") - ph.resizeSem = syncutil.NewSem(int64(conf.OptionalInt("maxResizeBytes", defaultMaxResizeBytes))) + ph.resizeSem = syncutil.NewSem(int64(conf.OptionalInt("maxResizeBytes", constants.DefaultMaxResizeMem))) if err = conf.Validate(); err != nil { return } diff --git a/pkg/server/ui.go b/pkg/server/ui.go index 1026cbab1..7f0cef13d 100644 --- a/pkg/server/ui.go +++ b/pkg/server/ui.go @@ -31,6 +31,7 @@ import ( "camlistore.org/pkg/blob" "camlistore.org/pkg/blobserver" + "camlistore.org/pkg/constants" "camlistore.org/pkg/fileembed" "camlistore.org/pkg/httputil" "camlistore.org/pkg/jsonconfig" @@ -120,7 +121,7 @@ func uiFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Handler, er JSONSignRoot: conf.OptionalString("jsonSignRoot", ""), sourceRoot: conf.OptionalString("sourceRoot", ""), resizeSem: syncutil.NewSem(int64(conf.OptionalInt("maxResizeBytes", - defaultMaxResizeBytes))), + constants.DefaultMaxResizeMem))), } pubRoots := conf.OptionalList("publishRoots") cachePrefix := conf.OptionalString("cache", "")