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

Jester uses more memory per page load #15749

Closed
ITwrx opened this issue Oct 27, 2020 · 3 comments
Closed

Jester uses more memory per page load #15749

ITwrx opened this issue Oct 27, 2020 · 3 comments

Comments

@ITwrx
Copy link

ITwrx commented Oct 27, 2020

as reported in dom96/jester#270, Jester uses more memory per page load. Currently testing with:

import jester, strutils
include Views/index

routes:
  get "/":
    resp INDEX_HTML.format("")

and for Views/index.nim:

const INDEX_HTML = """
  <html>                                                                                                                                                      
  <head>
  <meta name="title" content="ITwrx-Jester" />  
  </head>
  <body>
  <h1>Responding with html from separate file with Jester.</h1>                                                                                                <body>                                                                                                                                                      
  <p>This is only a test. If this were a real paragraph, it would be much more interesting.</p>                                                               
  </body>                                                                                                                                                     
  </html>
  """

with the above html-only testing code it takes 5-10 page loads to notice a bump of 0.1-0.2 MB of ram increase. If the page has images, css or videos, the mem usage will climb in proportion to the amount of data being served. For example, if you add an html5 video tag with a video file asset, it will climb 30MB (or was it 3MB?, I can't recall) at a time (depends on vid size). With css and a background image of about 60k combined, it climbs about 0.3MB per page load.

Jester compiled with: -d:useStdlib and either the default GC, --gc:boem, --gc:markAndSweep, --gc:orc, or --gc:orc -d:useMalloc.

I haven't tried with any other http frameworks yet.

Tried with nim versions: 1.0.10, 1.2.8, and 1.4.0

OS is fedora32, if that matters any.

Thanks

@Araq
Copy link
Member

Araq commented Oct 28, 2020

If --gc:boehm reproduces the problem it is a stdlib problem or a jester problem. Please provide an example that doesn't use Jester.

@ITwrx
Copy link
Author

ITwrx commented Oct 28, 2020

first, i decided to go ahead and spell --gc:boehm correctly and rerun my jester example. :) It still used more ram per request. so i created a simple test with asynchttpserver and it did not use more ram per request with --gc:boehm or --gc:orc.

import asynchttpserver, asyncdispatch, strutils

include Views/index

var server = newAsyncHttpServer()
proc cb(req: Request) {.async.} =
  #await req.respond(Http200, "Hello World")
  await req.respond(Http200, INDEX_HTML.format(""))

waitFor server.serve(Port(8080), cb)

So, it seems it's a jester problem. Thanks for the help, and sorry for the noise. I didn't think i knew how to make a asynchttpserver test, but on second look, it was easy.

@ITwrx ITwrx closed this as completed Oct 28, 2020
@dom96
Copy link
Contributor

dom96 commented Oct 28, 2020

I mean... just because Jester reproduces it doesn't mean it's a Jester problem :)

But sure, let's continue investigation in the Jester issue.

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

No branches or pull requests

3 participants