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

Test tour.dlang.org as alternative backend #1647

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

wilzbach
Copy link
Member

@wilzbach wilzbach commented May 7, 2017

Proof of concept PR (it's ugly!) to switch over to the DLang Tour as code executor for the executable blocks on dlang.org

However, unfortunately DLang Tour doesn't support STDIN nor ARGS, so it would only work for the runnable code block in the documentation.

@JackStouffer
Copy link
Member

Why?

@wilzbach
Copy link
Member Author

wilzbach commented May 7, 2017

Why?

'Cause DPaste is down a lot of time (like now) and we have no control over it (i.e. can't fix it), which means all executable blocks on dlang.org don't work...

The DTour already exposes an API to executable runnable examples, so this was a proof-of-concept PR to investigate whether we could switch to the DTour as API backend.

@wilzbach wilzbach changed the title [DO NOT MERGE] Switch to use tour.dlang.org instead of DPaste Switch to use tour.dlang.org instead of DPaste Jun 28, 2017
@wilzbach wilzbach removed the Blocked label Jun 28, 2017
@CyberShadow
Copy link
Member

and we have no control over it (i.e. can't fix it),

This is no longer true - DPaste's frontend and backend is hosted on my server.

The only thing that's not under our control is the domian. I suggest we fix that by making in redirect to paste.dlang.io instead of the other way around.

@wilzbach wilzbach changed the title Switch to use tour.dlang.org instead of DPaste Test tour.dlang.org as alternative backend Jun 28, 2017
@wilzbach
Copy link
Member Author

This is no longer true - DPaste's frontend and backend is hosted on my server.

Oh it seems that I forgot to post the motivation here. There are many problems with DPaste and I don't think it's easy to fix all of them:

  • segfaults (people care/complain about this, e.g. this post on the NG or the bugzilla issue)
  • no permission to write files
  • no caching
  • frequent downtimes
  • slow
  • no dmd-nightly (to be fair, currently the dlang-tour doesn't support this either, but it's just one pull request away for me)

A good "real life" example can be found on dlang/phobos#5517 (comment) as well.
I don't think anyone cares which backend is used in the background as long as they can run code smoothly on dlang.org.
This PR just changes the backend provider for all Phobos examples.

The only thing that's not under our control is the domian. I suggest we fix that by making in redirect to paste.dlang.io instead of the other way around.

It's not like I haven't tried to improve DPaste in the past, even the rebranding: nazriel/dpaste-frontend#4

@CyberShadow you still have access to dlang.io via NameCheap right? Feel free to set up a A / CNAME record for paste.dlang.io (I guess that will be nicer than a redirect?)

#perf matters

DPaste:

image

DTour:

image

Note that it didn't cache the request as this is currently not activated (-> dlang-tour/core#545).

@CyberShadow
Copy link
Member

I don't think anyone cares which backend is used in the background as long as they can run code smoothly on dlang.org.

Agreed.

This PR just changes the backend provider for all Phobos examples.

I'm fine with going forward with this PR if you consider things to be ready here and on the backend's side.

@CyberShadow you still have access to dlang.io via NameCheap right? Feel free to set up a A / CNAME record for paste.dlang.io (I guess that will be nicer than a redirect?)

If there is no interest in maintaining DPaste, then a better solution would be a migration plan to upgrade the tour backend with DPaste's critical features (saving pastes and supporting its set of compilers), migrating its database of pastes, and replacing / decommissioning it.

@CyberShadow
Copy link
Member

CC @nazriel

@wilzbach
Copy link
Member Author

I'm fine with going forward with this PR if you consider things to be ready here and on the backend's side.

Yep, I do. As shown, even without the caching PR, the tour backend is still a lot faster :)
Also it has a nice & clean API and allows plugging in new backends (e.g. Linux LXC containers, ...) easily.

If there is no interest in maintaining DPaste, then a better solution would be a migration plan to upgrade the tour backend with DPaste's critical features (saving pastes and supporting its set of compilers), migrating its database of pastes, and replacing / decommissioning it.

Could you please fill all required tasks at the DTour repo?
https://github.com/dlang-tour/core/issues

We might also want to take inspirations from the playgrounds of other languages, e.g.

https://play.rust-lang.org/
https://try.kotlinlang.org/#/Examples/Hello,%20world!/Simplest%20version/Simplest%20version.kt
https://play.golang.org/

@CyberShadow
Copy link
Member

I think this breaks the front page examples but I'm not sure how. I can only see that they don't work on dtest.dlang.io, even though the master branch works.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some tips to help speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@wilzbach
Copy link
Member Author

I think this breaks the front page examples but I'm not sure how.

DPaste sends formencoded requests, while I set the default to json. However, this means that the request is "preflighted" (see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests), which DPaste doesn't support:

XMLHttpRequest cannot load https://dpaste.dzfl.pl/request/. Response for preflight is invalid

Another good resource: https://www.soasta.com/blog/options-web-performance-with-single-page-applications.
I will look into accepting text/plain;charset=UTF-8 payloads as well to avoid the double latency due to the OPTIONS preflight request.

@wilzbach
Copy link
Member Author

wilzbach commented Jun 28, 2017

I will look into accepting text/plain;charset=UTF-8 payloads as well to avoid the double latency due to the OPTIONS preflight request.

Okay, it's in the queue

-> dlang-tour/core#507

This should make things even faster when merged and deployed.

I think this breaks the front page examples

Should be fixed now - let's better wait and have a look at Dtest though ;-)

@CyberShadow
Copy link
Member

Could you please fill all required tasks at the DTour repo?

OK, I filed the ones that came up so far.

Should be fixed now - let's better wait and have a look at Dtest though ;-)

Seems to work!

@dlang-bot dlang-bot merged commit 0c1af99 into dlang:master Jun 28, 2017
@CyberShadow
Copy link
Member

BTW, I noticed something a little weird - the "Reset" button is visible by default, but it goes away after you click it once.

@wilzbach wilzbach deleted the use-tour-dlang-org branch June 28, 2017 17:52
@wilzbach
Copy link
Member Author

OK, I filed the ones that came up so far.

Thanks. I will work on them over the next weeks - you will be notified ;-)

BTW, I noticed something a little weird - the "Reset" button is visible by default, but it goes away after you click it once.

-> #1779

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants