Giter VIP home page Giter VIP logo

Comments (8)

djberg96 avatar djberg96 commented on July 17, 2024 1

I tried Ubuntu & Debian images with jemalloc + a bundle install, and they worked fine, so it's something to do with our environment (and our images in particular).

Anyway, back to the original issue, I'll go ahead and close it out since you don't want to split it out and there's a workaround that end users can use.

Thanks!

from nio4r.

tarcieri avatar tarcieri commented on July 17, 2024

FYI: the pure Ruby version is the worst implementation. I don’t think it should be split out (especially if it’s polluting the same namespace trying to provide the same API), although perhaps there could be some way to disable building the C extension

The problem I'm facing in the wild is Docker on an M1 Mac, as it essentially hangs for at least an hour on my system while it tries to build nio4r.

That sounds like an environmental issue. On my M1 Mac it’s roughly a minute inside of a Docker container

from nio4r.

djberg96 avatar djberg96 commented on July 17, 2024

That sounds like an environmental issue. On my M1 Mac it’s roughly a minute inside of a Docker container

Could be, but it's an environment I don't control. Maybe I can narrow it down for our devops folks, I assume there's some sort of compatibility magic happening between M1 and x86-64.

from nio4r.

tarcieri avatar tarcieri commented on July 17, 2024

Are you using something like bind mounts or volumes with Docker? They're ludicrously slow on macOS

from nio4r.

djberg96 avatar djberg96 commented on July 17, 2024

Are you using something like bind mounts or volumes with Docker? They're ludicrously slow on macOS

Note that I see, so I think it's something to do with our image or the environment in general. That, or libjemalloc is the culprit.

I tried adding this to the Gemfile:

Gem.pre_install do |installer|
  if installer.spec.name == 'nio4r'
    installer.spec.extensions = nil
  end
end

That basically works, but bundler just gets stuck on something else later (not even an extension).

from nio4r.

djberg96 avatar djberg96 commented on July 17, 2024

@tarcieri Upon further review, I think this has something to do with libjemalloc and our (Ubuntu, Ruby 2.7) image. Are there any known issues with jemalloc and nio4r? Otherwise it's something on my/our end.

from nio4r.

tarcieri avatar tarcieri commented on July 17, 2024

Nope, but if you're having trouble compiling code quickly, it almost certainly speaks to something with your Docker environment

from nio4r.

djberg96 avatar djberg96 commented on July 17, 2024

@tarcieri I know I'm OT here, but I think you simulate what I'm seeing locally like so:

# Dockerfile.ruby
FROM ruby:2.7 AS base

RUN apt-get update \
    && apt-get install --no-install-recommends -y \
    build-essential \
    curl \
    git \
    libpq-dev \
    libjemalloc-dev \
    libsqlite3-dev \
    libssl-dev \
    openssl

RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf /usr/share/doc
RUN rm -rf /usr/share/man
RUN apt-get clean

RUN groupadd -g 1000 ruby
RUN useradd --create-home --no-log-init -u 1000 -g 1000 ruby

ENV LD_PRELOAD=$LD_PRELOAD:/usr/lib/x86_64-linux-gnu/libjemalloc.so

WORKDIR /app
RUN chown ruby:ruby -R /app

COPY --chown=ruby:ruby Gemfile .

USER ruby
RUN gem install bundler
RUN bundle install

CMD ["bash"]

The Gemfile is just:

source 'https://rubygems.org'
gem 'rails'
gem 'nio4r'

And the command to build: docker build -t ruby27 -f Dockerfile.ruby --platform x86_64 .

from nio4r.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.