Overall Improvements!
This commit is contained in:
parent
aead4d7624
commit
24263cf5f7
3 changed files with 56 additions and 52 deletions
2
index.js
2
index.js
|
|
@ -15,7 +15,7 @@ const serial = require("./serial");
|
||||||
const parallel = require("./parallel");
|
const parallel = require("./parallel");
|
||||||
|
|
||||||
app.get("/", (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
res.render(path.join(__dirname, "pages/main.ejs"));
|
res.sendFile(path.join(__dirname, "pages/main.html"));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/primes", (req, res) => {
|
app.post("/primes", (req, res) => {
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Jose's Parallel Node Service</title>
|
<title>Jose's Parallel Node Service</title>
|
||||||
|
<script src="/modal.js"></script>
|
||||||
<link rel="stylesheet" href="/main-light.css">
|
<link rel="stylesheet" href="/main-light.css">
|
||||||
|
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
@ -25,6 +26,14 @@
|
||||||
max-width: 1024px;
|
max-width: 1024px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.5em;
|
||||||
|
left: 0.5em;
|
||||||
|
font-size: 2em;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -86,6 +95,9 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div class="info" for-modal="info">
|
||||||
|
<i class="fa fa-info-circle"></i>
|
||||||
|
</div>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<div class="centered container">
|
<div class="centered container">
|
||||||
<h2>
|
<h2>
|
||||||
|
|
@ -113,6 +125,48 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="info" class="modal">
|
||||||
|
<div class="modal-content" style="max-width: 1024px;">
|
||||||
|
<span class="close">
|
||||||
|
<i class="fa fa-times"></i>
|
||||||
|
</span>
|
||||||
|
<h3 class="header">
|
||||||
|
About this Website
|
||||||
|
</h3>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
This website was built using NodeJS and the library <span class="code">webworker-threads</span> for
|
||||||
|
NodeJS. This library allows me to spin off additional threads as threads, "workers" or in a
|
||||||
|
threadpool. This site utilizes the threadpool feature to generate a list of primes (based on your
|
||||||
|
selection). Upon hitting "Submit" the button will be disabled, the data will be sent to my server
|
||||||
|
and the primes will be generated in serial and in parallel with the specified number of threads.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Once it's done processing, a portion will show up in the bottom showing the serial and paralell
|
||||||
|
run-times. Obviously I'd like to show the resulting array, but after about 9 hours of work I could
|
||||||
|
not get the array returned back out of the threadpool. I could access the array within the
|
||||||
|
threadpool but not outside of it (which is where the rest of this server is running..), but overall
|
||||||
|
this was not easy to implement in the first place so I'm thrilled it works.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
My greatest takeaway is that this couldn't have been easy to implement for the developers of the
|
||||||
|
NodeJS
|
||||||
|
parallel libraries discussed <a href="https://ieeexplore.ieee.org/abstract/document/8671573"
|
||||||
|
target="_blank">in this paper</a>, based on the clear limitations and difficulties in
|
||||||
|
implementation. Clearly NodeJS itself needs a massive redesign as it lacks many of the creature
|
||||||
|
comforts that make parallelism intuitive to use.
|
||||||
|
</p>
|
||||||
|
<div class="divider"> </div>
|
||||||
|
<p>
|
||||||
|
One random thing: this website is using a themekit I designed. If you like it and want to use it,
|
||||||
|
please do! You can see a real demo <a href="https://oitsjustjose.com/JuiceUI"
|
||||||
|
target="_blank">here</a> and you can grab it and use it <a
|
||||||
|
href="https://github.com/oitsjustjose/JuiceUI" target="_blank">here</a>!
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Jose's Parallel Node Service</title>
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/main-light.css">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flex-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: 100vw;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
form {
|
|
||||||
max-width: 1024px;
|
|
||||||
margin: auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
window.addEventListener("DOMContentLoaded", (evt) => {
|
|
||||||
let results = document.getElementById("results");
|
|
||||||
let resJSON = location.href.substring(location.href.indexOf("results?json=") + 13, location.href.length);
|
|
||||||
results.innerText = JSON.stringify(resJSON);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="flex-container">
|
|
||||||
<h2>
|
|
||||||
Multi-Threaded NodeJS Server Results
|
|
||||||
</h2>
|
|
||||||
<code class="centered code" id="results">
|
|
||||||
hi
|
|
||||||
</code>
|
|
||||||
<button class="blue" onclick="location.href='/'">Back</button>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
Loading…
Reference in a new issue