Berry: [Bug] Slower link w/ the nm linker

Created on 7 May 2020  路  19Comments  路  Source: yarnpkg/berry

  • [ ] I'd be willing to implement a fix

Describe the bug

A simple require does not work because of hoisting.

To Reproduce

git clone [email protected]:bertho-zero/yarn-bug-repro.git
cd yarn-bug-repro/packages/package-1
yarn start

Screenshots

image

Environment

  • OS: Linux
  • Node version v12.16.1
  • Yarn version 2.0.0-rc.33
bug node-modules reproducible

Most helpful comment

Reopening to keep track of the memory issue

All 19 comments

@bertho-zero Should be fixed via #1313 To try it out you can use
yarn set version from sources --branch 1313

Looks good ! :+1:

It works correctly in the reproduction project but I have an out of memory error in the initial project.
The link step never ends even when going back to the version I previously pushed on git.


Report


{
  "header": {
    "reportVersion": 1,
    "event": "Allocation failed - JavaScript heap out of memory",
    "trigger": "FatalError",
    "filename": "report.20200507.205700.27174.0.001.json",
    "dumpEventTime": "2020-05-07T20:57:00Z",
    "dumpEventTimeStamp": "1588877820137",
    "processId": 27174,
    "cwd": "/home/bertho/oa",
    "commandLine": [
      "/home/bertho/.nvm/versions/node/v12.16.1/bin/node",
      "/home/bertho/oa/.yarn/releases/yarn-sources.js"
    ],
    "nodejsVersion": "v12.16.1",
    "glibcVersionRuntime": "2.23",
    "glibcVersionCompiler": "2.23",
    "wordSize": 64,
    "arch": "x64",
    "platform": "linux",
    "componentVersions": {
      "node": "12.16.1",
      "v8": "7.8.279.23-node.31",
      "uv": "1.34.0",
      "zlib": "1.2.11",
      "brotli": "1.0.7",
      "ares": "1.15.0",
      "modules": "72",
      "nghttp2": "1.40.0",
      "napi": "5",
      "llhttp": "2.0.4",
      "http_parser": "2.9.3",
      "openssl": "1.1.1d",
      "cldr": "35.1",
      "icu": "64.2",
      "tz": "2019a",
      "unicode": "12.1"
    },
    "release": {
      "name": "node",
      "lts": "Erbium",
      "headersUrl": "https://nodejs.org/download/release/v12.16.1/node-v12.16.1-headers.tar.gz",
      "sourceUrl": "https://nodejs.org/download/release/v12.16.1/node-v12.16.1.tar.gz"
    },
    "osName": "Linux",
    "osRelease": "4.4.0-178-generic",
    "osVersion": "#208-Ubuntu SMP Sun Apr 5 23:45:10 UTC 2020",
    "osMachine": "x86_64",
    "cpus": [
      {
        "model": "Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz",
        "speed": 2558,
        "user": 280188000,
        "nice": 424300,
        "sys": 60995000,
        "idle": 2363522800,
        "irq": 0
      },
      {
        "model": "Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz",
        "speed": 2558,
        "user": 280279000,
        "nice": 455100,
        "sys": 62628500,
        "idle": 2354308600,
        "irq": 0
      },
      {
        "model": "Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz",
        "speed": 2550,
        "user": 269467800,
        "nice": 856900,
        "sys": 52310600,
        "idle": 2378996500,
        "irq": 0
      },
      {
        "model": "Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz",
        "speed": 2558,
        "user": 255697700,
        "nice": 368400,
        "sys": 59072700,
        "idle": 2393372600,
        "irq": 0
      }
    ],
    "networkInterfaces": [
      {
        "name": "lo",
        "internal": true,
        "mac": "00:00:00:00:00:00",
        "address": "127.0.0.1",
        "netmask": "255.0.0.0",
        "family": "IPv4"
      },
      {
        "name": "wlp2s0",
        "internal": false,
        "mac": "dc:85:de:ec:5a:77",
        "address": "192.168.8.100",
        "netmask": "255.255.255.0",
        "family": "IPv4"
      },
      {
        "name": "docker_gwbridge",
        "internal": false,
        "mac": "02:42:e1:7a:0f:2b",
        "address": "172.20.0.1",
        "netmask": "255.255.0.0",
        "family": "IPv4"
      },
      {
        "name": "br-56421ec307b3",
        "internal": false,
        "mac": "02:42:e8:d6:c3:33",
        "address": "172.19.0.1",
        "netmask": "255.255.0.0",
        "family": "IPv4"
      },
      {
        "name": "lo",
        "internal": true,
        "mac": "00:00:00:00:00:00",
        "address": "::1",
        "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
        "family": "IPv6",
        "scopeid": 0
      },
      {
        "name": "wlp2s0",
        "internal": false,
        "mac": "dc:85:de:ec:5a:77",
        "address": "fdf8:9a78:f289:bc00:85ba:c43d:23e0:c7c9",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 0
      },
      {
        "name": "wlp2s0",
        "internal": false,
        "mac": "dc:85:de:ec:5a:77",
        "address": "fdf8:9a78:f289:bc00:7d88:38f5:73da:870f",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 0
      },
      {
        "name": "wlp2s0",
        "internal": false,
        "mac": "dc:85:de:ec:5a:77",
        "address": "fdf8:9a78:f289:bc00:24fe:a10b:3ff7:94b0",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 0
      },
      {
        "name": "wlp2s0",
        "internal": false,
        "mac": "dc:85:de:ec:5a:77",
        "address": "fdf8:9a78:f289:bc00:346c:d9d2:a67e:8d30",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 0
      },
      {
        "name": "wlp2s0",
        "internal": false,
        "mac": "dc:85:de:ec:5a:77",
        "address": "fdf8:9a78:f289:bc00:611:c230:5bc3:8caf",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 0
      },
      {
        "name": "wlp2s0",
        "internal": false,
        "mac": "dc:85:de:ec:5a:77",
        "address": "fe80::c25:6647:1d89:827d",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 2
      },
      {
        "name": "docker_gwbridge",
        "internal": false,
        "mac": "02:42:e1:7a:0f:2b",
        "address": "fe80::42:e1ff:fe7a:f2b",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 4
      },
      {
        "name": "br-56421ec307b3",
        "internal": false,
        "mac": "02:42:e8:d6:c3:33",
        "address": "fe80::42:e8ff:fed6:c333",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 5
      },
      {
        "name": "veth029b8b2",
        "internal": false,
        "mac": "3e:43:07:2f:4d:56",
        "address": "fe80::3c43:7ff:fe2f:4d56",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 7
      },
      {
        "name": "vethf4ce57b",
        "internal": false,
        "mac": "56:1d:ed:74:f3:82",
        "address": "fe80::541d:edff:fe74:f382",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 13
      },
      {
        "name": "vethf16a24c",
        "internal": false,
        "mac": "36:ed:d4:11:6d:c2",
        "address": "fe80::34ed:d4ff:fe11:6dc2",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 21
      },
      {
        "name": "veth255fc49",
        "internal": false,
        "mac": "1e:9b:ba:8e:25:8c",
        "address": "fe80::1c9b:baff:fe8e:258c",
        "netmask": "ffff:ffff:ffff:ffff::",
        "family": "IPv6",
        "scopeid": 25
      }
    ],
    "host": "bertho-X751LB"
  },
  "javascriptStack": {
    "message": "No stack.",
    "stack": [
      "Unavailable."
    ]
  },
  "nativeStack": [
    {
      "pc": "0x0000000000b54701",
      "symbol": "report::TriggerNodeReport(v8::Isolate*, node::Environment*, char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, v8::Local<v8::String>) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x0000000000a1430c",
      "symbol": "node::OnFatalError(char const*, char const*) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x0000000000b8744e",
      "symbol": "v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x0000000000b876a2",
      "symbol": "v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x0000000000d47a95",
      "symbol": " [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x0000000000d48127",
      "symbol": "v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x0000000000d55712",
      "symbol": "v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x0000000000d5660e",
      "symbol": "v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x0000000000d5935d",
      "symbol": "v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x0000000000d1e32b",
      "symbol": "v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x000000000106de5e",
      "symbol": "v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    },
    {
      "pc": "0x00000000013f0199",
      "symbol": " [/home/bertho/.nvm/versions/node/v12.16.1/bin/node]"
    }
  ],
  "javascriptHeap": {
    "totalMemory": 2150658048,
    "totalCommittedMemory": 2149151088,
    "usedMemory": 2141169952,
    "availableMemory": 51231768,
    "memoryLimit": 2197815296,
    "heapSpaces": {
      "read_only_space": {
        "memorySize": 262144,
        "committedMemory": 33088,
        "capacity": 32808,
        "used": 32808,
        "available": 0
      },
      "new_space": {
        "memorySize": 4194304,
        "committedMemory": 3146168,
        "capacity": 2094912,
        "used": 115304,
        "available": 1979608
      },
      "old_space": {
        "memorySize": 2124300288,
        "committedMemory": 2124253032,
        "capacity": 2120749536,
        "used": 2120749536,
        "available": 0
      },
      "code_space": {
        "memorySize": 1216512,
        "committedMemory": 1034272,
        "capacity": 873664,
        "used": 873664,
        "available": 0
      },
      "map_space": {
        "memorySize": 2363392,
        "committedMemory": 2363120,
        "capacity": 1164080,
        "used": 1164080,
        "available": 0
      },
      "large_object_space": {
        "memorySize": 18272256,
        "committedMemory": 18272256,
        "capacity": 18231776,
        "used": 18231776,
        "available": 0
      },
      "code_large_object_space": {
        "memorySize": 49152,
        "committedMemory": 49152,
        "capacity": 2784,
        "used": 2784,
        "available": 0
      },
      "new_large_object_space": {
        "memorySize": 0,
        "committedMemory": 0,
        "capacity": 2094912,
        "used": 0,
        "available": 2094912
      }
    }
  },
  "resourceUsage": {
    "userCpuSeconds": 5105.6,
    "kernelCpuSeconds": 70.824,
    "cpuConsumptionPercent": 183.431,
    "maxRss": 2261565440,
    "pageFaults": {
      "IORequired": 15,
      "IONotRequired": 24107327
    },
    "fsActivity": {
      "reads": 2272,
      "writes": 7920
    }
  },
  "uvthreadResourceUsage": {
    "userCpuSeconds": 2541.04,
    "kernelCpuSeconds": 40.656,
    "cpuConsumptionPercent": 91.4846,
    "fsActivity": {
      "reads": 2264,
      "writes": 24
    }
  },
  "libuv": [
  ],
  "environmentVariables": {
    "OA_MYSQL_DEV_DATABASE": "oadev",
    "_system_version": "16.04",
    "USER": "bertho",
    "J2SDKDIR": "/usr/lib/jvm/java-8-oracle",
    "XDG_SEAT": "seat0",
    "SSH_AGENT_PID": "3390",
    "XDG_SESSION_TYPE": "x11",
    "OA_ELASTICSEARCH_134_DEV_HOST": "https://es1.kaore.openagenda.com",
    "TOOLBOX_VERSION": "1.17.6856",
    "J2REDIR": "/usr/lib/jvm/java-8-oracle/jre",
    "SHLVL": "1",
    "APPDIR": "/tmp/.mount_jetbrarQpIvr",
    "HOME": "/home/bertho",
    "OLDPWD": "/home/bertho/oa/packages/cibul-node",
    "LESS": "-R",
    "DESKTOP_SESSION": "default",
    "NVM_BIN": "/home/bertho/.nvm/versions/node/v12.16.1/bin",
    "OA_ELASTICSEARCH_533_DEV_HOST": "https://es5.kaore.openagenda.com",
    "rvm_stored_umask": "0002",
    "TERMINAL_EMULATOR": "JetBrains-JediTerm",
    "GIO_LAUNCHED_DESKTOP_FILE": "/home/bertho/.config/autostart/jetbrains-toolbox.desktop",
    "ZSH": "/home/bertho/.oh-my-zsh",
    "LSCOLORS": "Gxfxcxdxbxegedabagacad",
    "NVM_SYMLINK_CURRENT": "true",
    "NVM_INC": "/home/bertho/.nvm/versions/node/v12.16.1/include/node",
    "OA_ELASTICSEARCH_750_DEV_HOST": "https://es7.kaore.openagenda.com",
    "GTK_MODULES": "gail:atk-bridge",
    "QT_LINUX_ACCESSIBILITY_ALWAYS_ON": "1",
    "PAGER": "less",
    "rvm_user_install_flag": "1",
    "DBUS_SESSION_BUS_ADDRESS": "unix:abstract=/tmp/dbus-EQgV4jQ3Yz,guid=0b49e6886614669ecc01a3da5eb0322d",
    "OA_ELASTICSEARCH_134_DEV_PORT": "443",
    "GIO_LAUNCHED_DESKTOP_FILE_PID": "3964",
    "SASS_BINARY_PATH": "/home/bertho/OpenAgenda/node-sass/vendor/linux-x64-57/binding.node",
    "NVM_DIR": "/home/bertho/.nvm",
    "OA_ELASTICSEARCH_134_DEV_SSL_CERT": "/home/bertho/.ssh/es/user.crt",
    "MANDATORY_PATH": "/usr/share/gconf/default.mandatory.path",
    "OA_ELASTICSEARCH_533_DEV_PORT": "443",
    "LOGNAME": "bertho",
    "OA_ELASTICSEARCH_750_DEV_PORT": "443",
    "OWD": "/home/bertho",
    "DESKTOP_AUTOSTART_ID": "102937c565ad8dce158860548773001100000032610002",
    "rvm_bin_path": "/home/bertho/.rvm/bin",
    "OA_ELASTICSEARCH_533_DEV_SSL_CERT": "/home/bertho/.ssh/es/user.crt",
    "_": "/home/bertho/.yarn/bin/yarn",
    "DEFAULTS_PATH": "/usr/share/gconf/default.default.path",
    "OA_ELASTICSEARCH_750_DEV_SSL_CERT": "/home/bertho/.ssh/es/user.crt",
    "TERM": "xterm-256color",
    "USERNAME": "bertho",
    "XDG_SESSION_ID": "1",
    "GNOME_DESKTOP_SESSION_ID": "this-is-deprecated",
    "WINDOWPATH": "2",
    "PATH": "/home/bertho/.yarn/bin:/home/bertho/.config/yarn/global/node_modules/.bin:/home/bertho/.nvm/versions/node/v12.16.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/bertho/.local/bin:/home/bertho/.rvm/bin:Usage Error: The 'yarn global' commands have been removed in 2.x - consider using 'yarn dlx' or a third-party plugin instead\n\n$ yarn run [--inspect] [--inspect-brk] <scriptName> .../node_modules/.bin",
    "APPIMAGE": "/home/bertho/.local/share/JetBrains/Toolbox/bin/jetbrains-toolbox",
    "SESSION_MANAGER": "local/bertho-X751LB:@/tmp/.ICE-unix/3261,unix/bertho-X751LB:/tmp/.ICE-unix/3261",
    "__INTELLIJ_COMMAND_HISTFILE__": "/home/bertho/.config/JetBrains/PhpStorm2020.1/terminal/history/history-500",
    "DERBY_HOME": "/usr/lib/jvm/java-8-oracle/db",
    "XDG_MENU_PREFIX": "gnome-",
    "XDG_RUNTIME_DIR": "/run/user/1000",
    "OA_ELASTICSEARCH_134_DEV_SSL_KEY": "/home/bertho/.ssh/es/user.pem",
    "DISPLAY": ":1",
    "CENSYS_API_ID": "3c00f1fd-bdc6-4d4a-b8cb-5d01aba0cf83",
    "XDG_CURRENT_DESKTOP": "GNOME",
    "LANG": "fr_FR.UTF-8",
    "OA_MYSQL_DEV_PASSWORD": "*",
    "CENSYS_API_SECRET": "*",
    "XMODIFIERS": "@im=ibus",
    "XDG_SESSION_DESKTOP": "default",
    "XAUTHORITY": "/run/user/1000/gdm/Xauthority",
    "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:",
    "OA_ELASTICSEARCH_533_DEV_SSL_KEY": "/home/bertho/.ssh/es/user.pem",
    "SSH_AUTH_SOCK": "/run/user/1000/keyring/ssh",
    "OA_ELASTICSEARCH_750_DEV_SSL_KEY": "/home/bertho/.ssh/es/user.pem",
    "OA_ELASTICSEARCH_134_DEV_USE_SSL": "1",
    "SHELL": "/bin/zsh",
    "OA_MYSQL_DEV_HOST": "localhost",
    "rvm_prefix": "/home/bertho",
    "rvm_loaded_flag": "1",
    "QT_ACCESSIBILITY": "1",
    "GDMSESSION": "default",
    "AWS_ACCESS_KEY_ID": "AKIAJCTNQBIZSAPX7HUQ",
    "OA_MYSQL_DEV_USER": "root",
    "_system_type": "Linux",
    "AWS_SECRET_ACCESS_KEY": "*",
    "OA_ELASTICSEARCH_533_DEV_USE_SSL": "1",
    "OA_ELASTICSEARCH_750_DEV_USE_SSL": "1",
    "rvm_version": "1.28.0 (master)",
    "QT_IM_MODULE": "ibus",
    "_system_arch": "x86_64",
    "XDG_VTNR": "2",
    "PWD": "/home/bertho/oa",
    "JAVA_HOME": "/usr/lib/jvm/java-8-oracle",
    "XDG_DATA_DIRS": "/usr/share/default:/usr/share/gnome:/usr/local/share/:/usr/share/",
    "XDG_CONFIG_DIRS": "/etc/xdg/xdg-default:/etc/xdg",
    "NVM_CD_FLAGS": "-q",
    "_system_name": "Ubuntu",
    "rvm_path": "/home/bertho/.rvm",
    "EDITOR": "gedit"
  },
  "userLimits": {
    "core_file_size_blocks": {
      "soft": 0,
      "hard": "unlimited"
    },
    "data_seg_size_kbytes": {
      "soft": "unlimited",
      "hard": "unlimited"
    },
    "file_size_blocks": {
      "soft": "unlimited",
      "hard": "unlimited"
    },
    "max_locked_memory_bytes": {
      "soft": 65536,
      "hard": 65536
    },
    "max_memory_size_kbytes": {
      "soft": "unlimited",
      "hard": "unlimited"
    },
    "open_files": {
      "soft": 1048576,
      "hard": 1048576
    },
    "stack_size_bytes": {
      "soft": 8388608,
      "hard": "unlimited"
    },
    "cpu_time_seconds": {
      "soft": "unlimited",
      "hard": "unlimited"
    },
    "max_user_processes": {
      "soft": 47068,
      "hard": 47068
    },
    "virtual_memory_kbytes": {
      "soft": "unlimited",
      "hard": "unlimited"
    }
  },
  "sharedObjects": [
    "/lib/x86_64-linux-gnu/libdl.so.2",
    "/usr/lib/x86_64-linux-gnu/libstdc++.so.6",
    "/lib/x86_64-linux-gnu/libm.so.6",
    "/lib/x86_64-linux-gnu/libgcc_s.so.1",
    "/lib/x86_64-linux-gnu/libpthread.so.0",
    "/lib/x86_64-linux-gnu/libc.so.6",
    "/lib64/ld-linux-x86-64.so.2"
  ]
}

@bertho-zero I see. I have noticed that even on your reproduction project the link step takes way too long (23 seconds), for your project size it should take less than a second. So definitely this is not normal. I will be able to look into this problem later, hopefully next week, and will keep you informed. You can try to workaround this issue in the meantime via deduplicate plugin or via resolutions:
https://github.com/eps1lon/yarn-plugin-deduplicate

@bertho-zero One question, does out of memory happens, when you use released berry? Not the berry from my PR? Is it the PR that leads to out of memory?

Yes it's also slow with released berry, in the reproduction repo I can see an improvement if in the root package.json I update jest from version 25 to 26.

With released berry:
42 seconds for link step with jest@^25 in root package.json
16 seconds for link step with jest@^26 in root package.json

With branch 1313:
40 seconds for link step with jest@^25 in root package.json
16 seconds for link step with jest@^26 in root package.json
2 minutes for link step without jest in root package.json

If I use Jest@^26 in my real project I have a rather fast link and no out of memory.

@bertho-zero Alright, so to summarise:

  1. Out of memory happens on your real project with both released berry and branch 1313. So branch 1313 does not make things worser
  2. Branch 1313 does not affect link step timings, stays roughly the same, but it links packages correctly.
  3. Link step can be extraordinary slow and in the end lead to out of memory on some dependency trees, but that can be workaround if the dependency tree is somehow changed.

The point 3 needs serious investigation, you have provided enough info for this investigation to happen. I myself will be able to look into this hopefully starting next week.

Reopening to keep track of the memory issue

I don't know if this is any value, but I have tried to move a monorepo with 20+ packages to berry a few times. Today I got stuck because of a library not having a peerDependency set. So I switched to pnpMode: loose. Before switching linking completed in 8 seconds. After switching I'm getting a memory error after 10+ minutes. (Node 12.13) FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

That's a different issue; this one is only about the nm linker.

Thanks @arcanis. Is it a known or tracked issue?

@eigilsagafos @arcanis Well, I believe these issues have the same cause and I'm working to fix it. It will take some time though, because of hoisting problem complexity.

@eigilsagafos @bertho-zero Could you check if using yarn from the linked PR fixes your issues with out of memory / super long linking time? You can do so by executing
yarn set version from sources --branch 1429 inside your project. It would be great if you can provide feedback, thanks!

@larixer Confirmed to work. Without loose mode link step takes 14.58s. With loose mode it now finished in 23.25s.

@eigilsagafos Thank you!

In the repro repo I go from 28s to 11 seconds (without cache) and 1.7 seconds the second time. In my real repo the link is between 45s and 60s.

It works great!

@eigilsagafos You might want to rebuild yarn from the PR, the loose mode link time should be only 1 or 2 seconds more than strict pnp link time

Looking good @larixer! Cached I'm now seeing 5.55 seconds vs 6.46 seconds in loose mode (edit: I'm on a new laptop so that might have resulted in overall faster linking compared to my previous results)

Was this page helpful?
0 / 5 - 0 ratings