benoitc / erlang-idna

Erlang IDNA lib
MIT License
43 stars 29 forks source link

Could it use less memory when compiling? #8

Closed henrik closed 8 years ago

henrik commented 9 years ago

I had problems deploying a Phoenix app to my VPS (compiling on the server) – it seemed to be that the idna package needed a lot of memory during compilation.

I figured this out because someone else had the same problem before: https://github.com/elixir-lang/elixir/issues/3857

In that discussion, José Valim suggests that maybe the compilation could be made more efficient. What do you think?

benoitc commented 8 years ago

another way would be compressing the data, and decompress it on load. I will have a look on it

henrik commented 8 years ago

@benoitc Oh, awesome. Thank you so much!

benoitc commented 8 years ago

@henrik let me knows if the above change works for you.

henrik commented 8 years ago

@benoitc I tried this gh8 branch locally, adding this to my mix.exs:

{:idna, "> 0.0.0", github: "benoitc/erlang-idna", branch: "gh8"},

When trying to compile the dependency I get this:

$ mix deps.compile
Could not compile :idna, no "mix.exs", "rebar.config" or "Makefile" (pass :compile as an option to customize compilation, set it to "false" to do nothing)

Seems I can fix that by doing

{:idna, "> 0.0.0", github: "benoitc/erlang-idna", branch: "gh8", compile: true},

but maybe it would make sense to include one of those files.

benoitc commented 8 years ago

hrm interresting. I Wonder why mix is needed a specific file. fixing it.

On Fri, Nov 27, 2015 at 9:52 PM Henrik Nyh notifications@github.com wrote:

@benoitc https://github.com/benoitc I tried this gh8 branch locally, adding this to my mix.exs:

{:idna, "> 0.0.0", github: "benoitc/erlang-idna", branch: "gh8"},

When trying to compile the dependency I get this:

$ mix deps.compile Could not compile :idna, no "mix.exs", "rebar.config" or "Makefile" (pass :compile as an option to customize compilation, set it to "false" to do nothing)

— Reply to this email directly or view it on GitHub https://github.com/benoitc/erlang-idna/issues/8#issuecomment-160202206.

benoitc commented 8 years ago

@henrik 6e6becd730b4bf7a64c035f71f8f77c65eee5bbe should fix it

henrik commented 8 years ago

@benoitc Seems it did fix it :thumbsup: It's a little tricky for me to verify the memory thing since it happened on a server and depends on what else is happening at the same time, but now that this compiles, maybe it could be folded into master?

tallakt commented 8 years ago

I had the same issue on a virtualbox ubuntu guest, and the problem was solved when setting memory from 512 to 1024 MB. FYI

christhekeele commented 8 years ago

Even split up this dies on a 512MB DigitalOcean droplet for me.

I'm running a Dokku droplet (Ubuntu Dokku v0.5.6 on 14.04) on the smallest plan (512MB) with the HashNuke buildback. Everything is out-of-the-box, no custom config.

My deps are:

defp deps, do: [
    plug: "~> 1.1.4",
    cowboy: "~> 1.0.4",
    websocket_client: "~> 1.1.0",
    httpoison: "~> 0.8.3",
    exjsx: "~> 3.2.0",
]

My logs on git push dokku look like:

       * MIX_ENV=prod
-----> Using cached Erlang 18.2.1
-----> Installing Erlang 18.2.1

-----> Using cached Elixir v1.2.3
-----> Installing Elixir v1.2.3
-----> Installing Hex
       * creating /app/.mix/archives/hex-0.12.0.ez
-----> Installing rebar
       * creating /app/.mix/rebar
       * creating /app/.mix/rebar3
-----> Fetching app dependencies with mix
      Running dependency resolution
       * Getting httpoison (Hex package)
       Checking package (https://repo.hex.pm/tarballs/httpoison-0.8.3.tar)
       Fetched package
       * Getting exjsx (Hex package)
       Checking package (https://repo.hex.pm/tarballs/exjsx-3.2.0.tar)
       Fetched package
       * Getting jsx (Hex package)
       Checking package (https://repo.hex.pm/tarballs/jsx-2.6.2.tar)
       Fetched package
       * Getting hackney (Hex package)
       Checking package (https://repo.hex.pm/tarballs/hackney-1.6.0.tar)
       Fetched package
       * Getting ssl_verify_fun (Hex package)
       Checking package (https://repo.hex.pm/tarballs/ssl_verify_fun-1.1.0.tar)
       Fetched package
       * Getting mimerl (Hex package)
       Checking package (https://repo.hex.pm/tarballs/mimerl-1.0.2.tar)
       Fetched package
       * Getting metrics (Hex package)
       Checking package (https://repo.hex.pm/tarballs/metrics-1.0.1.tar)
       Fetched package
       * Getting idna (Hex package)
       Checking package (https://repo.hex.pm/tarballs/idna-1.2.0.tar)
       Fetched package
       * Getting certifi (Hex package)
       Checking package (https://repo.hex.pm/tarballs/certifi-0.4.0.tar)
       Fetched package
-----> Copying hex from /app/.mix/archives/hex-0.12.0.ez
-----> Compiling
==> idna (compile)
       Compiled src/idna_ucs.erl
       Compiled src/punycode.erl
       Compiled src/idna.erl
       Compiled src/idna_unicode.erl
       Compiled src/idna_unicode_data2.erl
       Killed
christhekeele commented 8 years ago

Upping it to 1GB RAM succeeds. Maybe it could be split up further?

benoitc commented 8 years ago

i will find another way ro ship the data. Expect an update on monday :) On Sat, 21 May 2016 at 01:41, Christopher Keele notifications@github.com wrote:

Upping it to 1GB succeeds. Maybe it could be split up further?

— You are receiving this because you modified the open/close state.

Reply to this email directly or view it on GitHub https://github.com/benoitc/erlang-idna/issues/8#issuecomment-220742899

lucasvmiguel commented 8 years ago

I upgraded my droplet, but didn't work, this compilation needs a lot of memory