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

Make DUB compatible with Common Gateway Interface #1750

Closed
BoQsc opened this issue Aug 7, 2019 · 5 comments
Closed

Make DUB compatible with Common Gateway Interface #1750

BoQsc opened this issue Aug 7, 2019 · 5 comments

Comments

@BoQsc
Copy link

BoQsc commented Aug 7, 2019

System information

  • dub version: (e.g. dub 1.3.0)
  • OS Platform and distribution: (e.g. Windows 10, Linux Ubuntu 16.04)
  • compiler version (e.g. dmd-2.074.1)

Bug Description

This is a general problem with DUB,
It seems that DUB is recompiling/building a project every time it runs a .d script.

This is enormous problem when using DUB with CGI, since CGI is calling .d script every time a web page request happens.

DUB wastes lots of processor time, overall computer resources.

How to reproduce?

Expected Behavior

Would love to see DUB checking if .d script was already compiled/run before. (Just like in RDMD)
If it was compiled/ran previously - do not compile/build. Run the previous compiled script version.

Logs

@andre2007
Copy link
Contributor

I fully agree with you that this behaviour should be fixed. For your actual use case I am not sure wheter, even if the bug is fixed, single file packages (.d script) is a good idea.

On every http request you still have the overhead of calling dub, creating different hashes, checking wheter the executable was already built and finally calling the executable.
I would prefer to compile an executable, without debug information and with maximum optimization switched on for best performance.

@bachmeil
Copy link

I recommend that this be closed. This is only an issue if you're recompiling on every request. The standard way to use CGI with D or any other compiled language is to compile the binary once. We don't want to add a new feature to accommodate nonstandard/suboptimal use cases.

@rikkimax
Copy link
Contributor

Assuming this is for individual D files that act as a dub package, what I assume is happening is that it is not caching the output. But even so, dub is slow. Its well out of scope of the given implementation to fire CGI requests via it.

If you want to do it via the individual file route, I would recommend putting your own program above it (or even use dub as a library) and let it handle the caching for your use case if this is for POSIX. On Windows this would be a fools goal given process cost to startup.

@andre2007
Copy link
Contributor

PR #1811

@andre2007
Copy link
Contributor

Fixed in master

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

4 participants