Giter VIP home page Giter VIP logo

cl-gserver's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cl-gserver's Issues

Blackbird-base:promise instead of result (on emacs slime repl)

Hi,
if I run this on my emacs-slime repl:

(future:on-completed (act:ask *answerer* "Buzz") (lambda (result) (format t "Received result: ~a~%" result)))

I get something like this:
#<BLACKBIRD-BASE:PROMISE name: "attach: PROMISE" finished: NIL errored: NIL forward: NIL {10025761C3}>

(if I hit enter again I get ;no value)

And if I run something like this:
(act:tell *answerer* "hello")
I get :STOPPED as result.

Is there a problem or should I use another method to capture the result?
Thanks!

Pass a copy of the state to the message handlers

In order to avoid handlers changing the state of a GServer as a side-effect, only a copy of the state object should be passed in to the message handlers (handle-cast, handle-call, receive).

Abstract logging

Don't lock the user in to log4cl. Let the user chose the logging library.

round-robin strategy for router is broken

In a heavy multi-threaded environment, as in the mp-test, the index variable and the update of it is not atomic enough.
Looking for a better way. stmx or atomics (cas) maybe, but that'd pull another dependency.

Allow no cons result from behavior function / add sender to receive context

Returning a cons can be a bit of a pain when nothing is to be returned to the caller.

So it should be possible to not return a cons.
The state can be modified by other means, i.e. accessing act-cell:state directly, or by a convenience accessor.
While doing that within the receive function it's still thread-safe.
Sending a response to a caller must be done manually in that case but the sender has to be exposed then to the receive function context.

Some questions about atomic in cl-gserver

Hi,

As I checked some codes of cl-gserver, there're several files use atomic operation.

  1. atomic.lisp, which defines atomic-cas, in this method definition, (when cas-result (setf ....) is really redundant, cas can make sure it's been set if cas succeeds. Furthermore, the setf after cas may be dangerous, this is usually a trap and is hard to debug.
  2. router.lisp, which defines make-round-robin-strategy, this function returns a lambda which always returns the new value, however, the cas operation may fail and leave the atomic-integer not changed, this might make the returned value not what you want.
  3. actor-context.lisp, in the definition of %add-actor, cas can make sure that a new actor will be successfully added in a loop. And finally, in the definition of %remove-actor, a single cas can not make sure it's removed successfully without a loop.

Since I just grepped the lisp file with atomic, and you may have some codes in other files which make sure all these are OK. But if you can confirm that these functions should get enhancement, I'm glad to make a patch.

Creating and asking actors inside another actor never completes all the asks.

I am most probably abusing cl-gserver here but I was trying to test breaking up a long running task into many actors but all the sub actors dont complete their futures. Is it a bug or am I really messing up. (Just as a note I tried to create the sub actors as actors of the system or as actors of the main actor and the result is the same.)

There is a break in the code to show where things get stuck.

(defparameter *system* (asys:make-actor-system))

(defun blocking-task-spread-work ()
  ;;Message processing is blocked untill the main task is returned, 
  ;;The actual work is split between many actors and we wait for all of them
  ;;to finish
  
  (let ((blocking-actor
	  (ac:actor-of
	   *system*
	   (lambda ()
	     (act:make-actor 
	      (lambda (self msg state)
                                     
		(let ((output (get-universal-time)))
				       
		  (format t "~a : ~a : ~a~%" (act-cell:name self) msg output)
		  (if state
		      (cons output state)
		      (progn
		
			(let ((futures))
			  
			  (dotimes (i 5)
			    (push 
			     (act:ask
			      (ac:actor-of (act:context self) 
					   (lambda ()
					     (act:make-actor
					      (lambda (child-self msg state)
						(declare (ignore child-self))
						(let ((output msg))
						  (format t "~a : ~a~%" (act-cell:name self) output)
						  (sleep 1)
						  (cons output state)))
					      :name (format nil "child-~A" i))))
				      "Load Shard")
			     futures))

			  (loop do (break "~A" futures)
				until (every #'future:complete-p futures)))
			
			(cons output t)))))
	      :name "long-task")))))

    (future:on-completed
     (act:ask blocking-actor "Load shards" )
     (lambda (result)
	 (format t "Received final result: ~a~%" result)))
    
    (ac:stop *system* blocking-actor)))

(blocking-task-spread-work)

add `:no-reply` as a possible `car` result...

..to allow computing a result using a thread pool, to not block the message queue handling.
In this case though a sender must be available in case a response is expected.
So this will only work for tell and async-ask.

Implement remoting

Remoting in the sense of having actor systems on different hosts where sending messages is location transparent.
Meaning actor A in system A can send and receive message to/from actor B in system B.

The path of the actor thus has to be extended to specify an URI, like: clg://<host>/<actor-system-name>/<actor-path>

consider wrap bt:condition-wait in a loop

Hi, this issue may relate to bordeaux-threads' issue 29, where you left an discussion and you said APIv2 worked.

In cl-gserver, bt:condition-wait was used directly (src/queue/queue.lisp), however, according to my tests, spurious wakeups may occur even with APIv2. I raised an issue for bordeaux-threads with my test code, and the author confirmed that it's right to use condition-wait in a loop.

I don't know why the same test code failed in my laptop and why it passed in the author's laptop, however, I think it's better to wrap condition-wait within a loop. The missed signals and spurious wakeups of condition variable wasted me a lot of time when I used it in a thread pool as they occured very very rarely.

Abstract the interface to the threading of the mailbox

Right now lparallel is used directly in the GServer to handle the incoming messages and such.
This should be abstracted behind an interface.
This interface may have different implementations: lparallel, BT, green-threads.

Add support for CLisp

Current limitation are the atomics which have no support for CLisp.
But there may be a specialized implementations based on locks instead.

Add event stream

An event stream can be used for event based notifications within the actor system.

Actor can subscribe to events, which are completely defineable by users and may just be atoms.
When an actor did subscribe to an event and the event is raised, then in order to receive the notification the actor has to listen to it in the receive/behavior function.

Provide pre-configured agent for alists and plists

As for #34, it would make sense to unify the 2 data structure agents considering how similar they are.

But the CL standard uses different APIs for the two: assoc for alists and getf for plists.

If we are going to follow CL, then we can make serarate agents.
If not, we can unify the interfaces. But then, why not unify the plist/alist interface with that of hash-tables?

Provide pre-configured agent for lists and arrays

Since they are index-based, it makes sense to have a common interface for them. But CL uses nth for lists and elt for vectors, so it would not follow the standard here (which is my opinion not very convenient).

Otherwise they can be separate interfaces.

Hangs during build

When I try to build the latest cl-gserver, i get this during build:

<WARN> [10:54:29] cl-gserver gserver.lisp (handle-message fun5) - Error condition was raised on message processing: CL-GSERVER::C: #<UNDEFINED-FUNCTION NIL {100D520B13}>

It stalls from there and does not time out or proceed.

ask-s with timeout fails on ABCL


ASK-S--SHARED--TIMEOUT in ACTOR-TESTS [Tests for ask-s timeout.]:
Unexpected Error: #<SIMPLE-ERROR {63800EA7}>
Attempt to release lock not held by calling thread..

rename 'ask' and 'async-ask'.

'async-ask' should be 'ask'.
and 'ask' should be 'ask-s' for 'synchronous'.

Since the old 'async-ask' is implemented using 'tell' both 'tell' and 'async-ask' do support the 'sender'.

Provide pre-configured facades for common objects, such as hash tables

Agents and facades are a great abstraction for concurrent access to any kind of data.
It'd be great to provide an abstraction to commonly used data, such as hash tables and maybe lists, plists, vectors, etc.

Example:

(setf *facade* (make-facade-hash-table))
  
; then

(facade-get *facade* INDEX)
(facade-set *facade* INDEX VALUE)

This could be done pretty cleanly and safely by declaring the facades in separate packages.

Thoughts?

Provide a mix-in to class based models to allow deep copies

cl-gserver currently only sets (setf) the value of state in (cons back-msg state) to the actor state. It does not make a deep copy to maintain immutable environments. This is up to the user.
However, it could provide at least a model mix-in that defines a generic function make-copy which implementer scan implement to make a deep copy of a component that cl-gserver could automatically use when setfing the state.

Incompatibility with SBCL 2.2.6

Loads of error like these:

While computing the class precedence list of the class named CL-GSERVER.ACTOR:ACTOR.
The class named #:ACTOR-CELL is a forward referenced class.
The class named #:ACTOR-CELL is a direct superclass of the class named CL-GSERVER.ACTOR:ACTOR..

failed on ABCL

cl-gserver can't be deployed on ABCL.

System info:
Macbook pro 2019, core i7, 16GB ram, big sur 11.3.1
ABCL 1.8.0

It seems that "cl-murmurhash" has a problem.


`[package cl-murmurhash]
; in (DEFMACRO ~> ...)

; Caught STYLE-WARNING:
; ; Note: deleting unused local function FLET ENLIST

...........................
...........
#<THREAD "interpreter" {4EFAFE9}>: Debugger invoked on condition of type STORAGE-CONDITION
Stack overflow.
Restarts:
0: RETRY Retry compiling #<ASDF/LISP-ACTION:CL-SOURCE-FILE "cl-murmurhash" "cl-murmurhash">.
`

Missing Git tags

1.7.3 and 1.7.4 are not on the public repo if I'm not mistaken.

Could you push them? It makes it easier for packagers to package the right version (e.g. in Nix and Guix).

question about "ask-s" with "time-out"

Suppose there are A1, A2, ..., A10, 10 actors, they ask-s B1, B2, ..., B10 with "time-out" in the same time.
And B1, B2, B10 are all time-out, and they throw 10 handler-error in the same time. How does the handler deal with this situation? Or ask-s should not throw exception, and just return a "fail" value?

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.