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

Dart VM has large memory usage relative to Node.js, Dart2js even worse. #18129

Closed
DartBot opened this issue Apr 9, 2014 · 8 comments
Closed
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.

Comments

@DartBot
Copy link

DartBot commented Apr 9, 2014

This issue was originally filed by c.brian.stu...@gmail.com


What steps will reproduce the problem?
1.Run the programs below and use "top" or other tool to monitor memory usage.

What is the expected output? What do you see instead?
Node.js uses about 135Megs (RES)
Dart uses about 240 Megs
Dart2js version running in nodejs uses about 460 Megs!!!

Dart clearly needs to give some thought to memory usage.

What version of the product are you using? On what operating system?
Dart VM version: 1.2.0 (Tue Feb 25 07:34:09 2014) on "linux_x64"
Running on Linux Mint.

Please provide any additional information below.
-- Program 1, run in dart --
import 'dart:io';
import 'dart:convert';

main() {
var rec = { "_id" : { "_oid" : "4d2295fb908e49485b000001" }, "shipping_email_address" : "", "pays_fc_sales_tax" : false, "po_payment_type" : "Check", "tc_email_address" : "", "billing_email_address" : "", "pays_larimer_sales_tax" : false, "pays_co_sales_tax" : false, "order_type" : "Check", "is_bill_same_as_ship" : true, "is_drop_shipment" : false, "tc_name" : "Mrs. Butterworth", "has_cash_discount" : false, "_obj" : "Order", "email_note" : "", "customer_name" : "Name Removed", "amount_paid" : { "_v" : 13495, "_obj" : "Money" }, "payment_ref_num" : "", "billing_address" : "", "registration_name" : "Name Removed", "po_payment_date" : null, "pc_name" : "", "po_payment" : { "_v" : 0, "_obj" : "Money" }, "order_date" : { "_date" : 775958400000 }, "amount_forgiven" : { "_v" : 0, "_obj" : "Money" }, "pc_phone_number" : "", "internal_note" : "(617) 252-0052 - U.S. unit ordering for a UK unit.", "items" : [ { "product" : "ATRLS", "price" : { "_v" : 4000, "_obj" : "Money" }, "is_taxable" : true, "discount" : 0, "_obj" : "OrderItem", "quantity" : 3 }, { "product" : "ATRLS_MEDIA", "price" : { "_v" : 495, "_obj" : "Money" }, "is_taxable" : true, "discount" : 0, "_obj" : "OrderItem", "quantity" : 1 }, { "product" : "WTFEE", "price" : { "_v" : 1000, "_obj" : "Money" }, "is_taxable" : false, "discount" : 0, "_obj" : "OrderItem", "quantity" : 1 } ], "pc_email_address" : "", "customer_order_ref_num" : "010010", "shipping_address" : "Name Removed\nAddress Obscured\nCambridge, MA 02142\n", "country" : "USA", "order_number" : 172 };

var i;
var l = [];
for (i=0; i<20000; i++) {
  l.add(JSON.decode(JSON.encode(rec)));
}
print('Hit return to exit');
stdin.readLineSync();
}
-- Program 2, run in node.js --
var sleep = require('sleep');

rec = { "_id" : { "$oid" : "4d2295fb908e49485b000001" }, "shipping_email_address" : "", "pays_fc_sales_tax" : false, "po_payment_type" : "Check", "tc_email_address" : "", "billing_email_address" : "", "pays_larimer_sales_tax" : false, "pays_co_sales_tax" : false, "order_type" : "Check", "is_bill_same_as_ship" : true, "is_drop_shipment" : false, "tc_name" : "Mrs. Butterworth", "has_cash_discount" : false, "_obj" : "Order", "email_note" : "", "customer_name" : "Name Removed", "amount_paid" : { "_v" : 13495, "_obj" : "Money" }, "payment_ref_num" : "", "billing_address" : "", "registration_name" : "Name Removed", "po_payment_date" : null, "pc_name" : "", "po_payment" : { "_v" : 0, "_obj" : "Money" }, "order_date" : { "$date" : 775958400000 }, "amount_forgiven" : { "_v" : 0, "_obj" : "Money" }, "pc_phone_number" : "", "internal_note" : "(617) 252-0052 - U.S. unit ordering for a UK unit.", "items" : [ { "product" : "ATRLS", "price" : { "_v" : 4000, "_obj" : "Money" }, "is_taxable" : true, "discount" : 0, "_obj" : "OrderItem", "quantity" : 3 }, { "product" : "ATRLS_MEDIA", "price" : { "_v" : 495, "_obj" : "Money" }, "is_taxable" : true, "discount" : 0, "_obj" : "OrderItem", "quantity" : 1 }, { "product" : "WTFEE", "price" : { "_v" : 1000, "_obj" : "Money" }, "is_taxable" : false, "discount" : 0, "_obj" : "OrderItem", "quantity" : 1 } ], "pc_email_address" : "", "customer_order_ref_num" : "010010", "shipping_address" : "Name Removed\nAddress Obscured\nCambridge, MA 02142\n", "country" : "USA", "order_number" : 172 }

var i;
var l = [];
for (i=0; i<20000; i++) {
  l.push(JSON.parse(JSON.stringify(rec)));
}
//console.log(rec);
sleep.sleep(600);
-- Program 3 --
// Run this Dart script through dart2js, edit out.js, add at top:
// var sleep = require('sleep');
// At the end add:
// sleep.sleep(600);
// Do a npm install sleep and run resulting out.js via nodejs
main() {
var rec = { "_id" : { "_oid" : "4d2295fb908e49485b000001" }, "shipping_email_address" : "", "pays_fc_sales_tax" : false, "po_payment_type" : "Check", "tc_email_address" : "", "billing_email_address" : "", "pays_larimer_sales_tax" : false, "pays_co_sales_tax" : false, "order_type" : "Check", "is_bill_same_as_ship" : true, "is_drop_shipment" : false, "tc_name" : "Mrs. Butterworth", "has_cash_discount" : false, "_obj" : "Order", "email_note" : "", "customer_name" : "Name Removed", "amount_paid" : { "_v" : 13495, "_obj" : "Money" }, "payment_ref_num" : "", "billing_address" : "", "registration_name" : "Name Removed", "po_payment_date" : null, "pc_name" : "", "po_payment" : { "_v" : 0, "_obj" : "Money" }, "order_date" : { "_date" : 775958400000 }, "amount_forgiven" : { "_v" : 0, "_obj" : "Money" }, "pc_phone_number" : "", "internal_note" : "(617) 252-0052 - U.S. unit ordering for a UK unit.", "items" : [ { "product" : "ATRLS", "price" : { "_v" : 4000, "_obj" : "Money" }, "is_taxable" : true, "discount" : 0, "_obj" : "OrderItem", "quantity" : 3 }, { "product" : "ATRLS_MEDIA", "price" : { "_v" : 495, "_obj" : "Money" }, "is_taxable" : true, "discount" : 0, "_obj" : "OrderItem", "quantity" : 1 }, { "product" : "WTFEE", "price" : { "_v" : 1000, "_obj" : "Money" }, "is_taxable" : false, "discount" : 0, "_obj" : "OrderItem", "quantity" : 1 } ], "pc_email_address" : "", "customer_order_ref_num" : "010010", "shipping_address" : "Name Removed\nAddress Obscured\nCambridge, MA 02142\n", "country" : "USA", "order_number" : 172 };

var i;
var l = [];
for (i=0; i<20000; i++) {
  l.add(JSON.decode(JSON.encode(rec)));
}

@DartBot
Copy link
Author

DartBot commented Apr 9, 2014

This comment was originally written by c.brian.sturgill...@gmail.com


I just checked this out under 1.3... problem still exists.

@kevmoo
Copy link
Member

kevmoo commented Apr 9, 2014

Added Area-VM, Triaged labels.

@DartBot
Copy link
Author

DartBot commented May 12, 2014

This comment was originally written by dariusz.ost...@gmail.com


On Ubuntu 12.04 amd64, running HelloWorld http server example yields 479MB:
/opt/dart/current/dart-sdk/bin/dart bin/httpserver/hello_world_server.dart

pmap -x 5596
5596: /opt/dart/current/dart-sdk/bin/dart bin/httpserver/hello_world_server.dart
...


total kB 479964 11468 7232

@iposva-google
Copy link
Contributor

I just verified that on the VM we are now consuming about 136MB, which seems to be inline with expectations.


Added Fixed label.

@DartBot DartBot added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. labels May 29, 2014
@lukepighetti
Copy link

Just deployed my first Dart microservice (route-only aqueduct) and it's using 300 mb while my comparable TypeScript Node services are using 100 mb.

@mraleph
Copy link
Member

mraleph commented Jan 11, 2019

@lukepighetti two questions:

  • did you deploy it from source or did you snapshot it? running from source has large overhead especially if you are using aqueduct, which spawns multiple isolates
  • how many isolates do you spawn an aqueduct? did you spawn similar amount of workers in your node services?

Also consider sending messages to misc@dartlang.org or vm-dev@dartlang.org instead of leaving comments on closed issues, which might or might not be related to the problem you are facing.

@lukepighetti
Copy link

Thanks for the heads up about emails. I did see that this was closed but I figured I'd just add the related anecdote in case this question came up again. The Dockerfile I am using deploys from source and it is running 2 isolates. I will try snapshots and 1 isolate to compare apples-to-apples. Thanks.

@lukepighetti
Copy link

@mraleph snapshots and 1 isolate cut the memory usage into a third. Thanks for the heads up. I noticed that the Snapshots guide in the Dart wiki does not mention memory use being reduced with a snapshot, perhaps that is a docs PR?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

5 participants