yjbanov / barista2 Goto Github PK
View Code? Open in Web Editor NEWA WASM PoC
A WASM PoC
I did npm install
but when I do npm run build
I get tons of TS compiler errors complaining about missing inferno
module
First it tries to copy not-existant util.js
. Then it tries to zip a file that does not exist gzip: can't stat: giant.asm.js (giant.asm.js): No such file or directory
There's currently an issue where we can't async-compile, but we appear to be able to async-instantiate.
To unblock IDB demo, consider using WebAssembly.instantiate. See the overload that takes bytes and returns the (module, instance) pair.
diff --git a/api.cpp b/api.cpp
index d09e275..ff22fe7 100644
--- a/api.cpp
+++ b/api.cpp
@@ -30,7 +30,9 @@ bool _canUpdate(shared_ptr<RenderNode> node, shared_ptr<Node> configuration) {
return node->GetConfiguration()->GetKey() == configuration->GetKey();
}
-RenderNode::RenderNode(shared_ptr<Tree> tree) : _tree(tree) { }
+int RenderNode::__nodes = 0;
+
+RenderNode::RenderNode(shared_ptr<Tree> tree) : _tree(tree) { __nodes++; }
void RenderNode::Update(shared_ptr<Node> newConfiguration, ElementUpdate& update) {
assert(newConfiguration != nullptr);
diff --git a/api.h b/api.h
index 1d0567b..5f9c755 100644
--- a/api.h
+++ b/api.h
@@ -37,6 +37,7 @@ class Event;
class Node {
public:
Node() { }
+
virtual string GetKey() { return _key; }
virtual void SetKey(string key) { _key = key; }
virtual shared_ptr<RenderNode> Instantiate(shared_ptr<Tree> t) = 0;
@@ -49,6 +50,10 @@ typedef function<void(shared_ptr<RenderNode>)> RenderNodeVisitor;
class RenderNode {
public:
+ static int __nodes;
+
+ virtual ~RenderNode() { __nodes--; }
+
RenderNode(shared_ptr<Tree> tree);
virtual shared_ptr<Node> GetConfiguration() { return _configuration; }
virtual shared_ptr<RenderParent> GetParent() { return _parent.lock(); }
diff --git a/test_giant.cpp b/test_giant.cpp
index 91fb48a..8340d60 100644
--- a/test_giant.cpp
+++ b/test_giant.cpp
@@ -56,6 +56,7 @@ TEST(TestBootstrapGiantApp)
auto after_flip = system_clock::now();
duration<double> delta = after_flip - before_flip;
cout << "Flip #" << flip << " took: " << delta.count() * 1000 << "ms; tree size: " << html.size() << " chars" << endl;
+ cout << "Node: " << RenderNode::__nodes << endl;
}
END_TEST
apply patch and see:
$ ./test_giant
Start tests
=============================================
TestBootstrapGiantApp
In main 1490799706085
Bootstrap time: 9.201ms; tree size: 89113 chars
Flip #1 took: 0.025ms; tree size: 35 chars
Node: 1834
Flip #2 took: 7.679ms; tree size: 89218 chars
Node: 3666
Flip #3 took: 0.01ms; tree size: 35 chars
Node: 3666
Flip #4 took: 8.058ms; tree size: 89235 chars
Node: 5498
Flip #5 took: 0.025ms; tree size: 35 chars
Node: 5498
Flip #6 took: 8.494ms; tree size: 89235 chars
Node: 7330
Flip #7 took: 0.014ms; tree size: 35 chars
Node: 7330
Flip #8 took: 7.345ms; tree size: 89235 chars
Node: 9162
Flip #9 took: 0.011ms; tree size: 35 chars
Node: 9162
Flip #10 took: 8.16ms; tree size: 89235 chars
Node: 10994
Success
End tests
Reported by @mraleph. Reading the code, there should be a memory leak when detaching a sub-tree of RenderNode
s. Despite Detach()
nulling out _parent
for the top-most detached child, the cycles inside the sub-tree should still prevent the destructors from being called. A quick speculative fix is to override Detach()
in RenderMultiChildParent
and call Detach()
recursively on all live children.
Requested by @ferhatb
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.