Coder Social home page Coder Social logo

Comments (26)

davedoesdev avatar davedoesdev commented on September 26, 2024 1

@z-hao-wang that looks a lot neater and is completely different from the squid code, thanks.

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024 1

OK I limited the tests to number of CPUs and merged #6
@z-hao-wang thanks again

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

Hi @z-hao-wang
I don't have access to a Mac to test. Can you run the tests on a Mac?

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

I'm trying to get it working on Travis CI OSX runners

from shared-memory-disruptor.

z-hao-wang avatar z-hao-wang commented on September 26, 2024

Looks like it throw an error when doing npm ci

../src/disruptor.cc:380:5: error: static_assert failed due to requirement 'std::is_same<decltype(errmsg), char *>::value' "strerror_r must return char*"
    static_assert(std::is_same<decltype(errmsg), char*>::value,
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/disruptor.cc:383:43: error: incompatible operand types ('int' and 'std::__1::string' (aka 'basic_string<char, char_traits<char>, allocator<char> >'))
        std::string(msg) + ": " + (errmsg ? errmsg : std::to_string(errnum)));

my env is python 2.7.16, OS 10.14.6
node 12.14
npm 6.13.4

from shared-memory-disruptor.

z-hao-wang avatar z-hao-wang commented on September 26, 2024

I made some changes (z-hao-wang@0cd33c6) to let it compile in mac OS. but it failed the tests. The changes I made still passes tests in linux (ubuntu 18).

grunt test
Running "mochaTest:src" (mochaTest) task


  multi-process many-to-many (producers: 1, consumers: 1, elements to write: 1)
    ✓ should transfer data (128ms)

  multi-process many-to-many (producers: 1, consumers: 1, elements to write: 2)
    1) should transfer data


  1 passing (138ms)
  1 failing

  1) multi-process many-to-many (producers: 1, consumers: 1, elements to write: 2)
       should transfer data:
     Error: Failed to open shared memory object: 22
    at new Disruptor2 (lib/disruptor.js:16:9)
    at Context.<anonymous> (test/multi_process.js:15:10)
    at processImmediate (internal/timers.js:439:21)
    at process.topLevelDomainCallback (domain.js:130:23)
  

I think there are something broken when reading data from shared memory. But I don't have an idea on where to look into. Any help would be appreciated.

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

@z-hao-wang thanks. Can you pull master and try that please? I've made similar changes but get EINVAL from shm_open

from shared-memory-disruptor.

z-hao-wang avatar z-hao-wang commented on September 26, 2024

Thanks @davedoesdev for the quick fix.
I just pulled master a110085 but still getting same error in testing. Error: Failed to open shared memory object: 22

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

@z-hao-wang you should be getting Error: Failed to open shared memory object: Invalid argument
as per https://travis-ci.org/davedoesdev/shared-memory-disruptor/jobs/630463623

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

For some reason shm_open is failing. I had thought it was the Travis CI environment but maybe not. Are you using a physical machine?

from shared-memory-disruptor.

z-hao-wang avatar z-hao-wang commented on September 26, 2024

yes, I am testing on physical macbook pro. yes I am getting exact same error Error: Failed to open shared memory object: Invalid argument

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

I have to leave this for a day or so now but feel free to play with the arguments to see if one of them is causing EINVAL. I'm wondering if it's O_TRUNC (http://lists.squid-cache.org/pipermail/squid-dev/2016-January/004832.html and https://stackoverflow.com/questions/25502229/ftruncate-not-working-on-posix-shared-memory-in-mac-os-x?lq=1). However, the shared memory shouldn't already exist so I don't see why that's an issue.
Maybe the name shouldn't start with a / on OSX, I don't know.

from shared-memory-disruptor.

z-hao-wang avatar z-hao-wang commented on September 26, 2024

Thanks for the help. made PR to fix this #6

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

@z-hao-wang thanks. The logic looks fine but I'm going to check the latest squid sources to see what code they ended up merging. I might check Chromium too to see if they do something similar.

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

Squid code is here: https://github.com/squid-cache/squid/blob/75aadeb9cc1128bb50adf8fc629d3957e9a88f2f/src/ipc/mem/Segment.cc#L89

They seem to have rewritten from the original patch to make it neater.

from shared-memory-disruptor.

z-hao-wang avatar z-hao-wang commented on September 26, 2024

yeah, the squid code is definitely cleaner. it looks like we can just use that path for both linux and mac os.
I'm happy to do some clean ups to make it similar like the squid code.

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

@z-hao-wang note that squid is GPL so I think we need to implement our own version or find another project which has implemented similar workarounds.

from shared-memory-disruptor.

z-hao-wang avatar z-hao-wang commented on September 26, 2024

@davedoesdev I'm not directly copy pasting their code. besides, our logic is slightly different anyway.
just updated the PR #6.

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

I'll wait for the tests to complete then merge. Thanks for your help, appreciate it.

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

Looks like the Travis OSX runners are slow so the test timed out.
I'll take a look later today or tomorrow but the code seems to work.

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

@z-hao-wang do the tests pass for you on your Mac? How long do they take?
They seem to be taking way too long on the Travis OSX runners, almost like something's wrong.

from shared-memory-disruptor.

z-hao-wang avatar z-hao-wang commented on September 26, 2024

Tests (grunt test) passed on my mac, took 53s. I have 4 core 16GB RAM.
Maybe Travis is just too slow for this. Or the test runs better with multi core cpu?

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

That's consistent with my Linux laptop. Something's a bit wrong with Travis.

from shared-memory-disruptor.

z-hao-wang avatar z-hao-wang commented on September 26, 2024

I'm guessing Travis is single core cpu, and this test spin up 6 child processes.
multi-process many-to-many (producers: 4, consumers: 2, elements to write: 10000)
It's pretty intensive, this may cause the cpu to have 100% usage.

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

I think it has two vCPUs: https://docs.travis-ci.com/user/reference/overview/
But CircleCI (which I use for Linux tests) also has two vCPUs. Maybe Linux multitasks better or something.

from shared-memory-disruptor.

davedoesdev avatar davedoesdev commented on September 26, 2024

Published as version 3.0.3

from shared-memory-disruptor.

Related Issues (7)

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.