--
You received this message because you are subscribed to the Google Groups "seastar-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seastar-dev...@googlegroups.com.
To post to this group, send email to seast...@googlegroups.com.
Visit this group at http://groups.google.com/group/seastar-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/ea3b0914-6e00-44fc-a9d5-6dcfeddfc5d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Nadav,
On Sun, Nov 8, 2015 at 4:12 AM, Nadav Har'El <n...@scylladb.com> wrote:
> Beyond everything which Avi and others already wrote, I'd like two propose
> an additional idea, which depending on what you need might be good enough:
>
> Something you could fairly easily do is to run your library as a completely
> separate process (not a thread), which gets commands over, say, a TCP/IP
> socket, and does its stuff. Then, your Seastar code will communicate with
> this external process using the normal Seastar future-based TCP network API.
>
> If you do this, when you run the Seastar program and external program side
> by side, remember to tell Seastar to leave (at least) on CPU unused, and
> enough memory free, for your additional program to run well (if it uses very
> little CPU and memory, maybe the defaults will work too).
This would sidestep things nicely ... would such a thing work over a
named pipe as well?
Or perhaps with an mmaped() file?
The memory allocator would still be a problem, though. Could Seastar reserve some memory for the traditional threads?
The memory allocator would still be a problem, though. Could Seastar reserve some memory for the traditional threads?
Sure (see --memory). Since we intercept the memory allocation calls (malloc/new/etc.) we'd need a little extra glue to call into a traditional allocator when in a traditional context.
On Wednesday, December 9, 2015 at 1:21:14 AM UTC-7, Avi Kivity wrote:
On 12/09/2015 07:00 AM, aso...@gmail.com wrote:
I think that Andrew's problem is pretty common. There are far too many legacy libraries out there to convert. I have another idea for how to integrate legacy code, though I have no idea how hard it would be as I'm just getting started with Seastar:
I propose that in addition to Seastar's usual n^2 - n intercore queues, a program could create an extra n queues for communication between Seastar event processor threads and traditional threads. The traditional part of the program would have one pair of queues to communicate with each event processor thread. These queues' endpoints could even be shared amongst multiple traditional threads, with appropriate locking. In this way the high-performance, polling event processor threads could have non-blocking communication with traditional threads (the traditional threads might block, but the event processor threads would not). The programmer would be free to use any blocking API in the traditional threads, including creating and joining more threads.
This could work. One problem would be balancing, how many cores would you allocate to traditional code and how many to to seastar? Same with memory.
If those traditional libraries are not performance critical, then you can get away with just allocating a few cores for them.
Yeah. This technique would be most useful when the traditional libraries aren't performance critical. So reserving 1 or 2 cores should be fine. And after sleep mode gets merged, there won't be any need to reserve cores for traditional threads.
The memory allocator would still be a problem, though. Could Seastar reserve some memory for the traditional threads?
Sure (see --memory). Since we intercept the memory allocation calls (malloc/new/etc.) we'd need a little extra glue to call into a traditional allocator when in a traditional context.
That's what I thought. Alas, it's too hard for me to attempt until I get some more practice hacking on Seastar.
so i've implemented a queue that works for posting. from a seastar thread you can do a safepost() on your local engine(), get a future, and later when your third party thread comes through, you can call the callable and it will schedule back on the seastar thread, setting the promise and performing the next continuation. a simple test shows it work, but im not sure it will really work. i attached a diff in case anyone is interested. definitely its a work in progress as i get used to seastar.
to get around the memory allocator issue that avi mentioned, i used DEFAULT_ALLOCATOR when compiling seastar. does anyone have any better tips about how to handle this? i like the memory model of seastar, and using the DEFAULT_ALLOCATOR seems like the wrong choice.
Sure (see --memory). Since we intercept the memory allocation calls (malloc/new/etc.) we'd need a little extra glue to call into a traditional allocator when in a traditional context.
any thoughts on how to go about doing this? the hardest part right now for me is figuring out how to call a (possibly) overridden memory allocator like jemalloc or tcmalloc, from an overridden memory allocator seastar's memory.cc
regards,
michael
On Wednesday, December 9, 2015 at 7:50:38 AM UTC-8, Avi Kivity wrote:
On 12/09/2015 05:42 PM, aso...@gmail.com wrote:
On Wednesday, December 9, 2015 at 1:21:14 AM UTC-7, Avi Kivity wrote:
I think that Andrew's problem is pretty common. There are far too many legacy libraries out there to convert. I have another idea for how to integrate legacy code, though I have no idea how hard it would be as I'm just getting started with Seastar:
I propose that in addition to Seastar's usual n^2 - n intercore queues, a program could create an extra n queues for communication between Seastar event processor threads and traditional threads. The traditional part of the program would have one pair of queues to communicate with each event processor thread. These queues' endpoints could even be shared amongst multiple traditional threads, with appropriate locking. In this way the high-performance, polling event processor threads could have non-blocking communication with traditional threads (the traditional threads might block, but the event processor threads would not). The programmer would be free to use any blocking API in the traditional threads, including creating and joining more threads.
This could work. One problem would be balancing, how many cores would you allocate to traditional code and how many to to seastar? Same with memory.
If those traditional libraries are not performance critical, then you can get away with just allocating a few cores for them.
Yeah. This technique would be most useful when the traditional libraries aren't performance critical. So reserving 1 or 2 cores should be fine. And after sleep mode gets merged, there won't be any need to reserve cores for traditional threads.
It is merged.
The memory allocator would still be a problem, though. Could Seastar reserve some memory for the traditional threads?
Sure (see --memory). Since we intercept the memory allocation calls (malloc/new/etc.) we'd need a little extra glue to call into a traditional allocator when in a traditional context.
That's what I thought. Alas, it's too hard for me to attempt until I get some more practice hacking on Seastar.
Another option is to use an external process, which then gets to use its own allocator. We can share memory using memfd().
--
You received this message because you are subscribed to the Google Groups "seastar-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seastar-dev...@googlegroups.com.
To post to this group, send email to seast...@googlegroups.com.
Visit this group at https://groups.google.com/group/seastar-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/36668ac8-b338-4850-8c7d-4fb1e6d5cd57%40googlegroups.com.
38 ../sysdeps/unix/sysv/linux/x86_64/syscall.S: No such file or directory.
(gdb) bt
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007ffff7076ba3 in __cxa_guard_acquire () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x0000000000578a3d in ?? ()
#3 0x000000000057ae02 in ?? ()
#4 0x000000000057b458 in malloc ()
#5 0x000000000057b565 in calloc ()
#6 0x00007ffff4d85690 in _dlerror_run (operate=operate@entry=0x7ffff4d85130 <dlsym_doit>, args=args@entry=0x7fffffffe090) at dlerror.c:141
#7 0x00007ffff4d85198 in __dlsym (handle=<optimized out>, name=<optimized out>) at dlsym.c:70
#8 0x0000000000578a1d in ?? ()
#9 0x0000000000578a52 in ?? ()
#10 0x000000000057ae02 in ?? ()
#11 0x000000000057b458 in malloc ()
#12 0x00007ffff42f244d in __fopen_internal (filename=0x7ffff571886a "/proc/self/status", mode=0x7ffff5718854 "r", is32=1) at iofopen.c:73
#13 0x00007ffff5714108 in ?? () from /usr/lib/x86_64-linux-gnu/libnuma.so.1
#14 0x00007ffff7dea0fd in call_init (l=0x7ffff7fe5000, argc=argc@entry=1, argv=argv@entry=0x7fffffffe2a8, env=env@entry=0x7fffffffe2b8) at dl-init.c:64
#15 0x00007ffff7dea223 in call_init (env=<optimized out>, argv=<optimized out>, argc=<optimized out>, l=<optimized out>) at dl-init.c:36
#16 _dl_init (main_map=0x7ffff7ffe1c8, argc=1, argv=0x7fffffffe2a8, env=0x7fffffffe2b8) at dl-init.c:126
#17 0x00007ffff7ddb30a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#18 0x0000000000000001 in ?? ()
#19 0x00007fffffffe5a4 in ?? ()
#20 0x0000000000000000 in ?? ()
libs = -ljemalloc -laio -lboost_program_options -lboost_system -lboost_filesystem -lstdc++ -lm -lboost_unit_test_framework -lboost_thread -lcryptopp -lrt -lgnutls -lgnutlsxx -lxenstore -lhwloc -lnuma -lpciaccess -lxml2 -lz -ldl
i'm pretty lost at this point.. if anyone wants to take a look that would be super helpful, or i will continue to go deeper and deeper ;)
regards,
I shifted around the ordering of libraries and it doesn't seem to make a difference, it definitely wants to find the libc++ Malloc no matter what I do. Will investigate further.
ok, i gave this a try today... and its not working at all. i attached my latest try as a diff.
firsti added an if .. then, in allocate() and memory::free in memory.cc, and tried to do it a couple of ways...
on the first call to allocate()/free() from a non seastar context,1)i tried using dlopen(), and then using dlsym() on that handle. that doesn't appear to work, because being inside of a malloc and having dlopen() internally using malloc causes weird hangs. i'll try it again.
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/2bf15f2e-2728-47ad-9faa-92a2d86328de%40googlegroups.com.
ok i think i got the third party memory allocator part to work this weekend. in the attached patch, there is a third_party_allocator flag on configure.py now. so you can do configure.py --third_party_allocator=jemalloc if you have jemalloc installed.
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/aca6e6ff-85c8-44a7-80ae-5b8a9d4b09cd%40googlegroups.com.
after reading the seastar memory allocator code, im not sure i understand why requiring a third party memory allocator is strictly required...afaik, seastar memory will still be new'd and free'd correctly even if it is free'd on a thread on a thread which it was not new'd on...so is there strictly a requirement that using non-seastar threads actually require their own memory allocator?
551 void cpu_pages::free(void* ptr) {
552 auto obj_cpu = object_cpu_id(ptr);
553 if (obj_cpu != cpu_id) {
554 return free_cross_cpu(obj_cpu, ptr);
555 }
556 page* span = to_page(ptr);
557 if (span->pool) {
558 span->pool->deallocate(ptr);
559 } else {
560 free_large(ptr);
561 }
562 }
hey andrew, thats what i thought too, until i saw these lines of code in core/memory.cc
line 554 says if the cpu_id of the ptr doesnt match the current cpu_id, put it on the originating cpu's free list.
551 void cpu_pages::free(void* ptr) {
552 auto obj_cpu = object_cpu_id(ptr);
553 if (obj_cpu != cpu_id) {
554 return free_cross_cpu(obj_cpu, ptr);
555 }
556 page* span = to_page(ptr);
557 if (span->pool) {
558 span->pool->deallocate(ptr);
559 } else {
560 free_large(ptr);
561 }
562 }
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/CAHxARCG7XtF_g2Hr%2Bu2EVpu%3DdmVTTWMMh%3DpDh6ZiFcnji0aH-w%40mail.gmail.com.
...
heres a similar question, but a different situation.
lets say i've built an api using seastar's futures... so i have functions that return futures.
future<> doSomething() {
}
what if i have a non-seastar thread, that i want to use to synchronously call this doSomething(). yes, its blocking, but in some situations, such as tests, or third party libraries that expect synchronous execution.. this is something that could happen.
ideally, a syntax for this would look like
//in non-seastar thread (maybe a main test thread, maybe a third party library thread that we want to use to call into our seastar API).
future<int> bar = doSomething();int result = bar.blocking_wait();return result;
i know that boost promise and futures have a blocking get(). is there an analogous call in seastar? i did not see one. the closest thing is that future::get() calls wait(), but that does something with seastar threads, which i dont think applies here..
thoughts?
--
You received this message because you are subscribed to the Google Groups "seastar-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seastar-dev...@googlegroups.com.
To post to this group, send email to seast...@googlegroups.com.
Visit this group at https://groups.google.com/group/seastar-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/8d9a20ef-8343-44c7-8681-95065d08ba1f%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to seastar-dev+unsubscribe@googlegroups.com.
To post to this group, send email to seast...@googlegroups.com.
Visit this group at https://groups.google.com/group/seastar-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/d4318b29-795b-4ec5-853b-5f046a641aa6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "seastar-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seastar-dev+unsubscribe@googlegroups.com.
To post to this group, send email to seast...@googlegroups.com.
Visit this group at https://groups.google.com/group/seastar-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/f4c8db7b-fe36-102c-3869-839e432a6722%40scylladb.com.
some of the threads are not controlled by Seastar. How does one designate these non-Seastar threads?May I hope that one day somebody would document this feature in the Seastar tutorial?The alien::submit_to() feature seems interesting, but it doesn't quite begin to cover the issue of how to write an application where
How does memoryallocation work in them? And so on.
Both approaches work. But guess which approach I think is better, and will improve the adoption of Seastar?Or, Seastar features could be clearly explained in the tutorial.Yes, beginners can spend days scouring through the Seastar source code for every feature which they wish to learn.
On 2018-05-01 11:52, Nadav Har'El wrote:
some of the threads are not controlled by Seastar. How does one designate these non-Seastar threads?May I hope that one day somebody would document this feature in the Seastar tutorial?The alien::submit_to() feature seems interesting, but it doesn't quite begin to cover the issue of how to write an application where
You don't need to designate them.
How does memoryallocation work in them? And so on.
Hybrid applications should use the default allocator, the seastar allocator won't work well with them.
Both approaches work. But guess which approach I think is better, and will improve the adoption of Seastar?Or, Seastar features could be clearly explained in the tutorial.Yes, beginners can spend days scouring through the Seastar source code for every feature which they wish to learn.
No idea, a hint?
Not everything needs to be in the tutorial. Some things can be kept in the reference, or in a topic-specific example within the reference.
On Tue, May 1, 2018 at 12:09 PM, Avi Kivity <a...@scylladb.com> wrote:
On 2018-05-01 11:52, Nadav Har'El wrote:
some of the threads are not controlled by Seastar. How does one designate these non-Seastar threads?May I hope that one day somebody would document this feature in the Seastar tutorial?The alien::submit_to() feature seems interesting, but it doesn't quite begin to cover the issue of how to write an application where
You don't need to designate them.
Maybe I misunderstood you, or you misunderstood me, but I think you *do* need to designate some of the
cores/threads to NOT run Seastar. The threads running the Seastar reactor must never block, so the
"alien" code needs to run on different threads, no?
How does memoryallocation work in them? And so on.
Hybrid applications should use the default allocator, the seastar allocator won't work well with them.
Ok, that's an example of a point that needs to be explained somewhere. But more importantly, is
this strictly true? Is it true because this is what we have today, or is there a fundamental reason why
it must be true? Can't the hybrid application have *both* sharded memory, and, part of the memory shared?
I.e., malloc() on the "alien" code will be done from shared memory, and malloc() on the "seastar" code
be done from per-core memory? (Of course, free() needs to do the right thing, etc.)
Both approaches work. But guess which approach I think is better, and will improve the adoption of Seastar?Or, Seastar features could be clearly explained in the tutorial.Yes, beginners can spend days scouring through the Seastar source code for every feature which they wish to learn.
No idea, a hint?
Ok, here's a hint :-)
Not everyone appreciates having to spend a few days (!) researching a question - like how to create a hybrid Seastar/regular
application. In this and many other cases which aren't explained in the tutorial, you can find hints all over the mailing list ("default
allocator", "alien threads", etc.) and then you need to sit for hours reading Seastar code, its (very little) comments, and
various commit messages and mailing list messages to collect the information you need.
It's so frustrating when you know that other people know exactly how to do this, but this knowledge is not written down
anywhere.
Not everything needs to be in the tutorial. Some things can be kept in the reference, or in a topic-specific example within the reference.
What is this mythical "reference" you are talking about?
Maybe the file name "tutorial.md" is the wrong name (the word "tutorial" doesn't actually appear in the title of the document).
It's not meant to be a "getting started tutorial", if that's what you understood a "tutorial" to be.It's meant to be both a read-from-cover-to-cover tutorial, and a reference book for more experienced users who already know what feature they are searching for, but now want a clear, step-by-step explanation on how to use this feature.
The "doxygen" as a reference - if that's what you consider "reference" - is not good enough, because it explains each function separately. In this example, you would get an explanation of alien::submit_to(), but without the context, without the bigger picture of how to use it and a dozen other small things to write an application which combines. Yes, you can add various HTML files etc. to the doxygen to explain packages and various "global" stuff, but it's not a good format to find anything in. In this example, which "package" is supposed to contain an explanation on how to use alien::submit_to() together with default malloc() and a bunch of other details from all over the seastar namespace, to create hybrid applications?
On 2018-05-01 12:51, Nadav Har'El wrote:
Not everyone appreciates having to spend a few days (!) researching a question - like how to create a hybrid Seastar/regular
application. In this and many other cases which aren't explained in the tutorial, you can find hints all over the mailing list ("default
allocator", "alien threads", etc.) and then you need to sit for hours reading Seastar code, its (very little) comments, and
various commit messages and mailing list messages to collect the information you need.
It's so frustrating when you know that other people know exactly how to do this, but this knowledge is not written down
anywhere.
Not everything needs to be in the tutorial. Some things can be kept in the reference, or in a topic-specific example within the reference.
What is this mythical "reference" you are talking about?
http://docs.seastar.io.
Maybe the file name "tutorial.md" is the wrong name (the word "tutorial" doesn't actually appear in the title of the document).
It's not meant to be a "getting started tutorial", if that's what you understood a "tutorial" to be.It's meant to be both a read-from-cover-to-cover tutorial, and a reference book for more experienced users who already know what feature they are searching for, but now want a clear, step-by-step explanation on how to use this feature.
The "doxygen" as a reference - if that's what you consider "reference" - is not good enough, because it explains each function separately. In this example, you would get an explanation of alien::submit_to(), but without the context, without the bigger picture of how to use it and a dozen other small things to write an application which combines. Yes, you can add various HTML files etc. to the doxygen to explain packages and various "global" stuff, but it's not a good format to find anything in. In this example, which "package" is supposed to contain an explanation on how to use alien::submit_to() together with default malloc() and a bunch of other details from all over the seastar namespace, to create hybrid applications?
Of course, more context is needed. That is why we have modules in the reference, for example http://docs.seastar.io/master/group__thread-module.html. These provide (or should provide) a short description of the functionality being provided, followed by a detailed function-by-function description.
I think it is easier (if properly completed) to search for something in a reference, rather than having to read a long tutorial or a short book,
once you have the basics down (which the tutorial does a very good job of).
On Tue, May 1, 2018 at 1:00 PM, Avi Kivity <a...@scylladb.com> wrote:
On 2018-05-01 12:51, Nadav Har'El wrote:
Not everyone appreciates having to spend a few days (!) researching a question - like how to create a hybrid Seastar/regular
application. In this and many other cases which aren't explained in the tutorial, you can find hints all over the mailing list ("default
allocator", "alien threads", etc.) and then you need to sit for hours reading Seastar code, its (very little) comments, and
various commit messages and mailing list messages to collect the information you need.
It's so frustrating when you know that other people know exactly how to do this, but this knowledge is not written down
anywhere.
Not everything needs to be in the tutorial. Some things can be kept in the reference, or in a topic-specific example within the reference.
What is this mythical "reference" you are talking about?
http://docs.seastar.io.In particular, I want to see there a page-per-section HTML version of the tutorial (automatic result of "ninja doc/split").
I am hoping that maybe then Avi will no longer see the tutorial as just a book you need to read from cover to cover,and maybe he'll appreciate why it's a better format than doxygen's "module" feature.
The book reference is also useful for someone looking to dig deeper, but not necessarily when trying to accomplish something right now.
The online reference is useful for someone looking to accomplish something right now. It is the standard documentation - you want to know how to do X, you go to the X documentation, you don't read a chapter in a book that happens to describe X.
I still have some questions about seastar thread + traditional thread.From the patch and test code, seems traditional thread use alien::submit_to to talk with seastar thread and seastar thread use alien::smp::poll_queues to get the "message", how about inverse, if seastar thread need trigger the talk with traditional thread, which func to call?
if use the default memory allocator, then seastar thread and traditional thread will use the same allocator, right? we will lose the seastar allocator advantage and memory will not be reserved for seastar thread, right?
Thanks!
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/d889eced-78bc-46b7-b7cf-7116902419eb%40googlegroups.com.
On 2018-05-03 00:55, chunm...@intel.com wrote:
I still have some questions about seastar thread + traditional thread.From the patch and test code, seems traditional thread use alien::submit_to to talk with seastar thread and seastar thread use alien::smp::poll_queues to get the "message", how about inverse, if seastar thread need trigger the talk with traditional thread, which func to call?
It can use any method it wants, like std::condition_variable::notify_all() or std::async().
On Thursday, May 3, 2018 at 12:55:43 AM UTC-7, Avi Kivity wrote:
On 2018-05-03 00:55, chunm...@intel.com wrote:
I still have some questions about seastar thread + traditional thread.From the patch and test code, seems traditional thread use alien::submit_to to talk with seastar thread and seastar thread use alien::smp::poll_queues to get the "message", how about inverse, if seastar thread need trigger the talk with traditional thread, which func to call?
It can use any method it wants, like std::condition_variable::notify_all() or std::async().
Don't understand here, why traditional thread need alien::submit_to to talk with seastar thread, but inverse, seathread thread only need the normal method to talk with traditional thread?
Hi Mr.Avi,I intend to build a high throughput, low latency async TCP client base on Seastar core. My intend is to run Seastar in some cores and run the user Client task (where user can send requests and receive responses) in other cores.I would like to use allien::submit_to() to send requests from user thread in to reactor threads.