Re: When can we make Squid using multi-CPU?

2009-01-07 Thread Alex Rousskov
On Sun, 2009-01-04 at 10:03 +0800, ShuXin Zheng wrote:
 Hi, Squid current can only use one CPU, but multi-CPU hardware
 machines are so popular. These are so greatly wastely. How can we use
 the multi-CPU? Can we separate some parallel sections which are CPU
 wasting to run on different CPU? OMP(http://openmp.org/wp/) gives us
 some thinking about using multi-CPU, so can we use these technology in
 Squid?

SMP support has been earmarked for Squid v3.2 but there is currently not
enough resources to make it happen (AFAICT) so it may have to wait until
v3.3 or later.

FWIW, I think that multi-core scalability in many environments would not
require another Squid rewrite, especially if initial support does not
have to do better than running multiple Squids.

You can monitor this project progress at
http://wiki.squid-cache.org/Features/SmpScale

Thank you,

Alex.




Re: When can we make Squid using multi-CPU?

2009-01-07 Thread Adrian Chadd
2009/1/8 Alex Rousskov rouss...@measurement-factory.com:

 SMP support has been earmarked for Squid v3.2 but there is currently not
 enough resources to make it happen (AFAICT) so it may have to wait until
 v3.3 or later.

 FWIW, I think that multi-core scalability in many environments would not
 require another Squid rewrite, especially if initial support does not
 have to do better than running multiple Squids.

Well, people are already doing that where its suitable. Whats really
missing for those sorts of setups is a simple(!) storage-only backend
and some smarts in Squid to be able to push and pull stuff out of a
shared storage backend, rather than relaying through it.

The trouble, as I've found here, is if you're trying to aggregate a
bunch of forward proxy squid instances on one box through one backend
squid instance - all of a sudden you end up with lots of RAM wastage
and things die at high loads with all the duplicate data floating
around in socket buffers. :/



Adrian


Re: When can we make Squid using multi-CPU?

2009-01-05 Thread Adrian Chadd
I've been looking into what would be needed to thread squid as part of
my cacheboy squid-2 fork.

Basically, I've been working on breaking out a bunch of the core code
into libraries, which I can then check and verify are thread-safe. I
can then use these bits in threaded code.

My first goal was probably to break out the ACL and internal URL
rewriter code into threads, but the current use of the callback data
setup in Squid makes passing cbdata pointers into other threads quite
uhm, tricky.

The basic problem is that although a given chunk of memory backing a
cbdata pointer will remain valid for as long as the reference exists,
the -data itself- may not be valid at any point. So if thread A
creates a cbdata pointer and passes it into thread B to do something
(say an ACL lookup), there's no way (at the moment) for thread B to
guarantee at any/all points during its execution that the data in B
will stay valid without a whole lot of pissing around with locking,
which I'd absolutely like to avoid doing in a high performance network
application even the apparent wonderful performance current hardware
has w/ lots of locking. :)

So for the time being, I'm looking at what would be needed for a basic
inter-thread batch event/callback message queue, sort of like
AsyncCalls in squid-3 but minus 100% of the legacy cruft; and then
I'll see what kind of tasks can be pushed out to the threads.

Hopefully a bunch of stuff can be easily pushed out to threads with a
minimum amount of effort, such as some/all of the ACL lookups, some
URL rewriting, some GZIP and other kind of basic content mainpulation,
and the freakishly simple (comparitively) server-side HTTP code
(src/http.c). But doing that requires making sure a bunch of the low
level code is suitably re-enterant/thread-safe/etc, and this includes
a -lot- of stuff (lib/, debug, logging, memory allocation, some
statistics gathering, chunks of the HTTP parsing and packing routines,
the packer routines, membufs, etc.)

Thankfully (in Cacheboy) I've broken out almost all of the needed
stuff into top-level libraries which can be independently audited for
thread-happiness. There's just some loose ends which need tidying up.
For example, almost all of the code in libhttp/ in cacheboy (ie, basic
http header and header entry stuff, parsing, range request headers,
cc, headers, etc) are thread-safe, but the functions -they- call (such
as the base64 functions) use static buffers which may or may not be
thread-safe. Stuff which calls the legacy non-safe inet_* routines, or
perhaps the non thread-safe strtok() and other string.h functions, all
need to be fixed.

Threading the rest of it would take a lot, -lot- more time. A
thread-aware storage backend (disk, memory, store index) is definitely
an integral part of making a threaded Squid, and a whole lot more code
modularity and reorganisation would have to take place for that to
occur.

Want to help? :)


Adrian

2009/1/4 ShuXin Zheng zhengshu...@gmail.com:
 I've ever do this to run multi-squid on one machine which can use multi-CPU,
 but can't share the same store-fs, and must configure multi-IP on the same
 machine. Can we rewrite squid as follow:

 thread0(client side, no block, can accept many connections)  thread1
 ..threadn(n=CPU number)
   |
  |
   v
 v
 access check
   access check
  |
 |
  v
v
 http header parse
   http header parse
  |
 |
  v
v
 acl filter
   acl filter
  |
 |
  v
v
 check local cache
  check local cache
  |
 |
  v
v
 ---
  |
 neighbor| ||-ufs
 webserver--|--- forward - |store fs |-aufs
| |
 |-coss
 ---
  |(thread0)
  |(thread1) ..
  v
 v
  ...




 2009/1/4  anest...@cisdi.com:

 I've found the best way is to run multiple copies of squid on a single
 machine, and use LVS to load balance between the squid processes.

 -- Joe

 Quoting Adrian Chadd adr...@squid-cache.org:

 when someone decides to either help code it up, or donate towards the
 effort.



 adrian

 2009/1/3 ShuXin Zheng zhengshu...@gmail.com:

 Hi, Squid current can only use one CPU, but multi-CPU hardware
 machines are so popular. These are so greatly wastely. How can we use
 the multi-CPU? Can we separate some parallel sections which are CPU
 wasting to run on different CPU? OMP(http://openmp.org/wp/) gives us
 some thinking about using multi-CPU, so can we use these technology in
 Squid?

 Thanks

 

Re: When can we make Squid using multi-CPU?

2009-01-04 Thread ShuXin Zheng
I've ever do this to run multi-squid on one machine which can use multi-CPU,
but can't share the same store-fs, and must configure multi-IP on the same
machine. Can we rewrite squid as follow:

thread0(client side, no block, can accept many connections)  thread1
...threadn(n=CPU number)
   |
  |
   v
 v
access check
   access check
  |
 |
  v
v
http header parse
   http header parse
  |
 |
  v
v
acl filter
   acl filter
  |
 |
  v
v
check local cache
  check local cache
  |
 |
  v
v
---
  |
neighbor| ||-ufs
webserver--|--- forward - |store fs |-aufs
| |
|-coss
---
  |(thread0)
  |(thread1) ..
  v
 v
 ...




2009/1/4  anest...@cisdi.com:

 I've found the best way is to run multiple copies of squid on a single
 machine, and use LVS to load balance between the squid processes.

 -- Joe

 Quoting Adrian Chadd adr...@squid-cache.org:

 when someone decides to either help code it up, or donate towards the
 effort.



 adrian

 2009/1/3 ShuXin Zheng zhengshu...@gmail.com:

 Hi, Squid current can only use one CPU, but multi-CPU hardware
 machines are so popular. These are so greatly wastely. How can we use
 the multi-CPU? Can we separate some parallel sections which are CPU
 wasting to run on different CPU? OMP(http://openmp.org/wp/) gives us
 some thinking about using multi-CPU, so can we use these technology in
 Squid?

 Thanks

 --
 zsxxsz










-- 
zsxxsz


When can we make Squid using multi-CPU?

2009-01-03 Thread ShuXin Zheng
Hi, Squid current can only use one CPU, but multi-CPU hardware
machines are so popular. These are so greatly wastely. How can we use
the multi-CPU? Can we separate some parallel sections which are CPU
wasting to run on different CPU? OMP(http://openmp.org/wp/) gives us
some thinking about using multi-CPU, so can we use these technology in
Squid?

Thanks

-- 
zsxxsz


Re: When can we make Squid using multi-CPU?

2009-01-03 Thread Adrian Chadd
when someone decides to either help code it up, or donate towards the effort.



adrian

2009/1/3 ShuXin Zheng zhengshu...@gmail.com:
 Hi, Squid current can only use one CPU, but multi-CPU hardware
 machines are so popular. These are so greatly wastely. How can we use
 the multi-CPU? Can we separate some parallel sections which are CPU
 wasting to run on different CPU? OMP(http://openmp.org/wp/) gives us
 some thinking about using multi-CPU, so can we use these technology in
 Squid?

 Thanks

 --
 zsxxsz