Date: Sat, 06 Dec 2014 18:25:35 -0800 From: Peter Grehan <grehan@freebsd.org> To: Tinker <tinkr@openmailbox.org> Cc: freebsd-virtualization@freebsd.org Subject: Re: Can a host OS user process create a zillion BHyVe VM:s and microcontrol them? Message-ID: <5483BA9F.2000905@freebsd.org> In-Reply-To: <5fa49b79a601363b471babbfc577590d@openmailbox.org> References: <CAG=rPVccq7R5%2Bcbm6nR1WCZDM=-xwwkmF=cw8PCuk58oHPA-gQ@mail.gmail.com> <1423616F-F44D-47E5-8595-DE862DC04464@bsdimp.com> <546A34C8.6060004@freebsd.org> <CAG=rPVeEEuK874g6%2BfVpHa5J_4V%2BA%2BQNbB5bCpXiS86jZW_U3Q@mail.gmail.com> <546C8812.2070904@FreeBSD.org> <20141119195923.GS24601@funkthat.com> <CAG=rPVdrjim_28ntxUv6qJxb-_bGhGabZipFyYzNuydZ2XPm5Q@mail.gmail.com> <69A8C06F-A7F6-49EC-8601-91AC4CDBFB13@FreeBSD.org> <547364EB.7090505@freebsd.org> <CAG=rPVeAM2_EEVYyhQiuXV7i%2Bpvw-uPYRBbjXeZhZKbrZzHRMg@mail.gmail.com> <547AEB93.3050600@freebsd.org> <CAF05609-FCB4-4CB6-9533-A1F32A7F3F22@neville-neil.com> <alpine.BSF.2.11.1412041456190.87680@fledge.watson.org> <5fa49b79a601363b471babbfc577590d@openmailbox.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> Can the following under any circumstance be done with BHyVe? Depends on how you define "any" :) > BHyVe_sandbox* s = BHyVe_createSandbox(100KB RAM, 2 CPU cores,void* > pointer to the audio codec binary code,int size of the same code); > > and then pass in data for procedure invocation like BHyVe_call(s, > "encoder_iterate", my arguments); bhyve provides what looks like a bare-metal system. While you can inject code and register state (ala bhyveload/grub-bhyve), the code has to be essentially an operating system, since the only interface provided is hardware. For example, to run with > 1 CPUs, you would have to program APIC registers to startup up additional CPUs - very much less friendly than pthread_create() in a POSIX environment. > And I'd have 50 000 of these running simultaneously on one machine, but > their respective heap size is 100KB each so that's only 5GB RAM in total. > > As I get more data to encode from the network from any of the 50 000 > audio streams I'm listening to, I feed the respective audio encoder > instance with the respective data with it, reactively. > > Key characteristics here are > * How light a BHyVe instance is (like, does a BHyVe instance require > allocation of any device file or FD otherwise), and Not too much. It requires an amount of kernel memory for guest data structures, maybe in the order of 10s of KBs. > * How lightweight trampolines between OS host process and guest code is, You have to do a VT-x context switch into the guest each time you'd want to run it - that's a few thousand cycles. > * I guess, if an OS scheduler context switch is needed for switching > between my host "my_audio_encoding_service_program.c" code and the guest > library code - can this be done like 100 000 times in a second. It could be done, but perhaps something like FreeBSD's capsicum sandboxing would be a better fit for this type of task than a VM. That's not to day it couldn't be done, just that it's a lot of work to get there. later, Peter.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5483BA9F.2000905>