From: Stephen D. <sd...@gm...> - 2006-04-05 19:33:27
|
What's the use case for these commands? I looked at the existing usage in e.g. ACS back when I added this and it seems that people are calling _get, and if it's not there, then calling _set. But this looks like a race condition to me. Does _eval not cover everything? On 4/5/06, Vlad Seryakov <ser...@us...> wrote: > Update of /cvsroot/naviserver/naviserver/nsd > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24426/nsd > > Modified Files: > tclcache.c tclcmds.c > Log Message: > Added 2 new cache commands ns_cache_get and ns_cache_set for easier cache= manipulation > > > Index: tclcmds.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/naviserver/naviserver/nsd/tclcmds.c,v > retrieving revision 1.34 > retrieving revision 1.35 > diff -C2 -d -r1.34 -r1.35 > *** tclcmds.c 28 Feb 2006 20:02:37 -0000 1.34 > --- tclcmds.c 5 Apr 2006 17:52:31 -0000 1.35 > *************** > *** 73,76 **** > --- 73,78 ---- > NsTclCacheCreateObjCmd, > NsTclCacheEvalObjCmd, > + NsTclCacheGetObjCmd, > + NsTclCacheSetObjCmd, > NsTclCacheFlushObjCmd, > NsTclCacheIncrObjCmd, > *************** > *** 259,262 **** > --- 261,266 ---- > {"ns_cache_create", NULL, NsTclCacheCreateObjCmd}, > {"ns_cache_eval", NULL, NsTclCacheEvalObjCmd}, > + {"ns_cache_get", NULL, NsTclCacheGetObjCmd}, > + {"ns_cache_set", NULL, NsTclCacheSetObjCmd}, > {"ns_cache_flush", NULL, NsTclCacheFlushObjCmd}, > {"ns_cache_incr", NULL, NsTclCacheIncrObjCmd}, > > Index: tclcache.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/naviserver/naviserver/nsd/tclcache.c,v > retrieving revision 1.2 > retrieving revision 1.3 > diff -C2 -d -r1.2 -r1.3 > *** tclcache.c 23 Jan 2006 15:57:33 -0000 1.2 > --- tclcache.c 5 Apr 2006 17:52:31 -0000 1.3 > *************** > *** 285,288 **** > --- 285,378 ---- > } > > + /* > + *---------------------------------------------------------------------= - > + * > + * NsTclCacheGetObjCmd -- > + * > + * Returns entry value if entry exists in the cache and not expire= d yet > + * > + * Results: > + * TCL result with entry value or empty result > + * > + * Side effects: > + * None. > + * > + *---------------------------------------------------------------------= - > + */ > + > + int > + NsTclCacheGetObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_O= bj *CONST objv[]) > + { > + Ns_Cache *cache; > + Ns_Entry *entry; > + char *key; > + > + Ns_ObjvSpec args[] =3D { > + {"cache", ObjvCache, &cache, arg}, > + {"key", Ns_ObjvString, &key, NULL}, > + {NULL, NULL, NULL, NULL} > + }; > + if (Ns_ParseObjv(NULL, args, interp, 1, objc, objv) !=3D NS_OK) { > + return TCL_ERROR; > + } > + Ns_CacheLock(cache); > + if ((entry =3D Ns_CacheFindEntry(cache, key)) !=3D NULL) { > + Tcl_SetStringObj(Tcl_GetObjResult(interp), > + Ns_CacheGetValue(entry), Ns_CacheGetSize(entry= )); > + } > + Ns_CacheUnlock(cache); > + return TCL_OK; > + } > + > + /* > + *---------------------------------------------------------------------= - > + * > + * NsTclCacheSetObjCmd -- > + * > + * Set new value of the cache entry > + * > + * Results: > + * TCL result. > + * > + * Side effects: > + * None. > + * > + *---------------------------------------------------------------------= - > + */ > + > + int > + NsTclCacheSetObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_O= bj *CONST objv[]) > + { > + NsInterp *itPtr =3D arg; > + Ns_Cache *cache; > + Ns_Entry *entry; > + char *key, *value =3D 0; > + int new, timeout =3D -1, ttl =3D 0; > + > + Ns_ObjvSpec opts[] =3D { > + {"-timeout", Ns_ObjvInt, &timeout, NULL}, > + {"-ttl", Ns_ObjvInt, &ttl, NULL}, > + {"--", Ns_ObjvBreak, NULL, NULL}, > + {NULL, NULL, NULL, NULL} > + }; > + Ns_ObjvSpec args[] =3D { > + {"cache", ObjvCache, &cache, arg}, > + {"key", Ns_ObjvString, &key, NULL}, > + {"value", Ns_ObjvString, &value, NULL}, > + {NULL, NULL, NULL, NULL} > + }; > + if (Ns_ParseObjv(opts, args, interp, 1, objc, objv) !=3D NS_OK) { > + return TCL_ERROR; > + } > + if ((entry =3D CreateEntry(itPtr, cache, key, &new, timeout)) =3D= =3D NULL) { > + return TCL_ERROR; > + } > + Tcl_SetStringObj(Tcl_GetObjResult(interp), value, -1); > + SetEntry(interp, entry, NULL, ttl); > + Ns_CacheUnlock(cache); > + > + return TCL_OK; > + } > + > > /* > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > naviserver-commits mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-commits > |
From: Vlad S. <vl...@cr...> - 2006-04-05 19:50:57
|
Yes, i use cache and in my case i do need to use get and set in different situations, for example i need to set cache entry regardless of what is there, eval will return me existing value, so i need to flush it first which gets to the same race condition issue. Same with get, i just need to get value if it exists without issuing exists first and then eval, if it is not there i do not want to set it, eval will set it. Stephen Deasey wrote: > What's the use case for these commands? I looked at the existing > usage in e.g. ACS back when I added this and it seems that people are > calling _get, and if it's not there, then calling _set. But this > looks like a race condition to me. > > Does _eval not cover everything? > > > > On 4/5/06, Vlad Seryakov <ser...@us...> wrote: >> Update of /cvsroot/naviserver/naviserver/nsd >> In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24426/nsd >> >> Modified Files: >> tclcache.c tclcmds.c >> Log Message: >> Added 2 new cache commands ns_cache_get and ns_cache_set for easier cache manipulation >> >> >> Index: tclcmds.c >> =================================================================== >> RCS file: /cvsroot/naviserver/naviserver/nsd/tclcmds.c,v >> retrieving revision 1.34 >> retrieving revision 1.35 >> diff -C2 -d -r1.34 -r1.35 >> *** tclcmds.c 28 Feb 2006 20:02:37 -0000 1.34 >> --- tclcmds.c 5 Apr 2006 17:52:31 -0000 1.35 >> *************** >> *** 73,76 **** >> --- 73,78 ---- >> NsTclCacheCreateObjCmd, >> NsTclCacheEvalObjCmd, >> + NsTclCacheGetObjCmd, >> + NsTclCacheSetObjCmd, >> NsTclCacheFlushObjCmd, >> NsTclCacheIncrObjCmd, >> *************** >> *** 259,262 **** >> --- 261,266 ---- >> {"ns_cache_create", NULL, NsTclCacheCreateObjCmd}, >> {"ns_cache_eval", NULL, NsTclCacheEvalObjCmd}, >> + {"ns_cache_get", NULL, NsTclCacheGetObjCmd}, >> + {"ns_cache_set", NULL, NsTclCacheSetObjCmd}, >> {"ns_cache_flush", NULL, NsTclCacheFlushObjCmd}, >> {"ns_cache_incr", NULL, NsTclCacheIncrObjCmd}, >> >> Index: tclcache.c >> =================================================================== >> RCS file: /cvsroot/naviserver/naviserver/nsd/tclcache.c,v >> retrieving revision 1.2 >> retrieving revision 1.3 >> diff -C2 -d -r1.2 -r1.3 >> *** tclcache.c 23 Jan 2006 15:57:33 -0000 1.2 >> --- tclcache.c 5 Apr 2006 17:52:31 -0000 1.3 >> *************** >> *** 285,288 **** >> --- 285,378 ---- >> } >> >> + /* >> + *---------------------------------------------------------------------- >> + * >> + * NsTclCacheGetObjCmd -- >> + * >> + * Returns entry value if entry exists in the cache and not expired yet >> + * >> + * Results: >> + * TCL result with entry value or empty result >> + * >> + * Side effects: >> + * None. >> + * >> + *---------------------------------------------------------------------- >> + */ >> + >> + int >> + NsTclCacheGetObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) >> + { >> + Ns_Cache *cache; >> + Ns_Entry *entry; >> + char *key; >> + >> + Ns_ObjvSpec args[] = { >> + {"cache", ObjvCache, &cache, arg}, >> + {"key", Ns_ObjvString, &key, NULL}, >> + {NULL, NULL, NULL, NULL} >> + }; >> + if (Ns_ParseObjv(NULL, args, interp, 1, objc, objv) != NS_OK) { >> + return TCL_ERROR; >> + } >> + Ns_CacheLock(cache); >> + if ((entry = Ns_CacheFindEntry(cache, key)) != NULL) { >> + Tcl_SetStringObj(Tcl_GetObjResult(interp), >> + Ns_CacheGetValue(entry), Ns_CacheGetSize(entry)); >> + } >> + Ns_CacheUnlock(cache); >> + return TCL_OK; >> + } >> + >> + /* >> + *---------------------------------------------------------------------- >> + * >> + * NsTclCacheSetObjCmd -- >> + * >> + * Set new value of the cache entry >> + * >> + * Results: >> + * TCL result. >> + * >> + * Side effects: >> + * None. >> + * >> + *---------------------------------------------------------------------- >> + */ >> + >> + int >> + NsTclCacheSetObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) >> + { >> + NsInterp *itPtr = arg; >> + Ns_Cache *cache; >> + Ns_Entry *entry; >> + char *key, *value = 0; >> + int new, timeout = -1, ttl = 0; >> + >> + Ns_ObjvSpec opts[] = { >> + {"-timeout", Ns_ObjvInt, &timeout, NULL}, >> + {"-ttl", Ns_ObjvInt, &ttl, NULL}, >> + {"--", Ns_ObjvBreak, NULL, NULL}, >> + {NULL, NULL, NULL, NULL} >> + }; >> + Ns_ObjvSpec args[] = { >> + {"cache", ObjvCache, &cache, arg}, >> + {"key", Ns_ObjvString, &key, NULL}, >> + {"value", Ns_ObjvString, &value, NULL}, >> + {NULL, NULL, NULL, NULL} >> + }; >> + if (Ns_ParseObjv(opts, args, interp, 1, objc, objv) != NS_OK) { >> + return TCL_ERROR; >> + } >> + if ((entry = CreateEntry(itPtr, cache, key, &new, timeout)) == NULL) { >> + return TCL_ERROR; >> + } >> + Tcl_SetStringObj(Tcl_GetObjResult(interp), value, -1); >> + SetEntry(interp, entry, NULL, ttl); >> + Ns_CacheUnlock(cache); >> + >> + return TCL_OK; >> + } >> + >> >> /* >> >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by xPML, a groundbreaking scripting language >> that extends applications into web and mobile media. Attend the live webcast >> and join the prime developer group breaking into this new coding territory! >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 >> _______________________________________________ >> naviserver-commits mailing list >> nav...@li... >> https://lists.sourceforge.net/lists/listinfo/naviserver-commits >> > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Stephen D. <sd...@gm...> - 2006-04-15 22:48:36
|
On 4/5/06, Vlad Seryakov <vl...@cr...> wrote: > Yes, i use cache and in my case i do need to use get and set in > different situations, for example i need to set cache entry regardless > of what is there, eval will return me existing value, so i need to flush > it first which gets to the same race condition issue. > Same with get, i just need to get value if it exists without issuing > exists first and then eval, if it is not there i do not want to set it, > eval will set it. So ns_cache_exists is redundant? Can we remove that? What's the real problem your solving here? Do you have some custom code for invalidating cache entries or something? |
From: Vlad S. <vl...@cr...> - 2006-04-16 01:02:59
|
No, ns_cache_exists should be kept, it is useful sometimes to check if the entry there, for read-only caches for example. It's hard to tell exactly the real problem, once your application is over 100K lines of Tcl code which implements the whole company's OSS/backoffice, there are a lot of specific tasks i have to solve. The more flexible and feature rich API is the easier the task is. Stephen Deasey wrote: > On 4/5/06, Vlad Seryakov <vl...@cr...> wrote: >> Yes, i use cache and in my case i do need to use get and set in >> different situations, for example i need to set cache entry regardless >> of what is there, eval will return me existing value, so i need to flush >> it first which gets to the same race condition issue. >> Same with get, i just need to get value if it exists without issuing >> exists first and then eval, if it is not there i do not want to set it, >> eval will set it. > > > So ns_cache_exists is redundant? Can we remove that? > > > What's the real problem your solving here? Do you have some custom > code for invalidating cache entries or something? > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Stephen D. <sd...@gm...> - 2006-04-16 15:00:45
|
On 4/16/06, Vlad Seryakov <vl...@cr...> wrote: > No, ns_cache_exists should be kept, it is useful sometimes to check if > the entry there, for read-only caches for example. There's no point checking for existence unless you're also going to do something with it -- that's a separate operation and that's a race condition. A read only cache doesn't make any sense to me. If you're not entering values at runtime, you're not using the cache feature of purging which is the only thing differentiating it from an nsv. Just use nsv's in this case. > It's hard to tell exactly the real problem, once your application is > over 100K lines of Tcl code which implements the whole company's > OSS/backoffice, there are a lot of specific tasks i have to solve. > The more flexible and feature rich API is the easier the task is. It's a trade off. In this case the problem I have is that these extra features encourage broken usage. I really think it's important to find the real solution to the problem, which I'm happy to help you do. I'm not keen to add broken features to the code base because yours is too big to figure out though. Hope that doesn't sound too harsh, it's not meant to be. \ |
From: Vlad S. <vl...@cr...> - 2006-04-16 17:20:09
|
> > There's no point checking for existence unless you're also going to do > something with it -- that's a separate operation and that's a race > condition. If the cache is used to keep some flag about somehting, other thread can just check if flag is set then do something. > A read only cache doesn't make any sense to me. If you're not > entering values at runtime, you're not using the cache feature of > purging which is the only thing differentiating it from an nsv. Just > use nsv's in this case. When i said readonly i did not mean pure readonly, but not very frequently updated cache. > It's a trade off. In this case the problem I have is that these extra > features encourage broken usage. I really think it's important to > find the real solution to the problem, which I'm happy to help you do. > I'm not keen to add broken features to the code base because yours is > too big to figure out though. Hope that doesn't sound too harsh, it's > not meant to be. No offense taken but why is this broken usage, if naviserver would propose only one way of doing things it would be very limited and not many developers would use it because it would be hard to implement different applications. It is not used by many now anyway so this is not the point but our application is very different from OpenACS for example, it is not only web app but true server backend which implements device provisioning, network monitoring and other pretty complicated logic. Having ability to do different thing different depending on the task is very powerful. If i would have nsv_ arrays only i would never be able to implement our system effectively, there is no one right way of developing different applications. Using Ns_Tls in C looks very usafull, why not having the same in Tcl as well? -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Zoran V. <zv...@ar...> - 2006-04-18 08:57:02
|
On 16.04.2006, at 19:20, Vlad Seryakov wrote: > > Using Ns_Tls in C looks very usafull, why not having the same in > Tcl as well? I belive what you did not "sell" correctly is the ability to have C and Tcl interface to same data in a "simple" manner. Because in my eyes, this is the major "pro". Normally, I would not buy ns_tls interface if it were just a replacement for setting a global variable in Tcl. Because you can very simply setup a tiny Tcl wrapper: proc ns_tls_set {key val} set private::tls($key) $val } proc ns_tls_get {key} set private::tls($key) } (add some more simple code if you'd be using [interp create] or such...) But the fact that you can access the same things from C code makes ns_tls worth considering (still, you need to have some conventions in place about data-types...) A good example of this dual interface is ns_config. It can be used from C and Tcl, which is why I was contemplating of adding more features there (perhaps allowing read/write operations after server startup). I haven't check the implementation but you need to be careful if you plan to store Tcl_Obj's references there. I can't recall eactly but there might be problems when you make some Tcl_Obj's jump the interpreters... Cheers Zoran |
From: Vlad S. <vl...@cr...> - 2006-04-18 13:52:27
|
You convinced me that at this moment ns_tls is not appropriate, i will remove it Zoran Vasiljevic wrote: > > On 16.04.2006, at 19:20, Vlad Seryakov wrote: > >> >> Using Ns_Tls in C looks very usafull, why not having the same in Tcl >> as well? > > I belive what you did not "sell" correctly is the ability > to have C and Tcl interface to same data in a "simple" manner. > Because in my eyes, this is the major "pro". > > Normally, I would not buy ns_tls interface if it were just > a replacement for setting a global variable in Tcl. Because > you can very simply setup a tiny Tcl wrapper: > > proc ns_tls_set {key val} > set private::tls($key) $val > } > proc ns_tls_get {key} > set private::tls($key) > } > > (add some more simple code if you'd be using > [interp create] or such...) > > But the fact that you can access the same things > from C code makes ns_tls worth considering (still, you need > to have some conventions in place about data-types...) > > A good example of this dual interface is ns_config. > It can be used from C and Tcl, which is why I was contemplating > of adding more features there (perhaps allowing read/write operations > after server startup). > > I haven't check the implementation but you need to be careful > if you plan to store Tcl_Obj's references there. I can't recall eactly > but there might be problems when you make some Tcl_Obj's jump the > interpreters... > > Cheers > Zoran > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Zoran V. <zv...@ar...> - 2006-04-18 14:42:57
|
On 18.04.2006, at 15:52, Vlad Seryakov wrote: > You convinced me that at this moment ns_tls is not appropriate, i > will remove it Oh?! How did I do that? Apart from giving a trivial alternative, I think that this interface is ok per-se. It allows "unified" access from Tcl and C code. That is, one should be able to do the "same" from C and Tcl. Isn't it so? Cheers Zoran |
From: Vlad S. <vl...@cr...> - 2006-04-18 14:48:11
|
Not you exactly but both of you and Stephen:-))) Global Tcl vars is more cleaner Tcl-only solution but i agree interoperability between C and Tcl using ns-tls would be a good feature. Internally ns_tls keeps Ns_set, so getting this from C would be just gettting pointer to Ns_Set structure. It just requires more C-level calls something like Ns_GetTclTls()/Ns_SetTclTcls() Zoran Vasiljevic wrote: > > On 18.04.2006, at 15:52, Vlad Seryakov wrote: > >> You convinced me that at this moment ns_tls is not appropriate, i will >> remove it > > Oh?! How did I do that? Apart from giving a trivial > alternative, I think that this interface is ok per-se. > It allows "unified" access from Tcl and C code. > That is, one should be able to do the "same" from C > and Tcl. Isn't it so? > > Cheers > Zoran > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Stephen D. <sd...@gm...> - 2006-04-18 20:48:49
|
An API that allows easy sharing between C and Tcl code is an interesting idea, e.g. a filter written in C storing data for a page written in Tcl. But that's not what's been implemented. As it stands, it's possible for C code to call down to Tcl and grab a global variable, it's impossible to get at the tls data as the tls key is a private variable in the nsd/tclinit.c file. One bug with the current implementation is that virtual servers will stomp on each others data. On 4/18/06, Vlad Seryakov <vl...@cr...> wrote: > Not you exactly but both of you and Stephen:-))) > > Global Tcl vars is more cleaner Tcl-only solution but i agree > interoperability between C and Tcl using ns-tls would be a good feature. > Internally ns_tls keeps Ns_set, so getting this from C would be just > gettting pointer to Ns_Set structure. It just requires more C-level > calls something like Ns_GetTclTls()/Ns_SetTclTcls() > > Zoran Vasiljevic wrote: > > > > On 18.04.2006, at 15:52, Vlad Seryakov wrote: > > > >> You convinced me that at this moment ns_tls is not appropriate, i will > >> remove it > > > > Oh?! How did I do that? Apart from giving a trivial > > alternative, I think that this interface is ok per-se. > > It allows "unified" access from Tcl and C code. > > That is, one should be able to do the "same" from C > > and Tcl. Isn't it so? > > > > Cheers > > Zoran |
From: Zoran V. <zv...@ar...> - 2006-04-18 21:30:17
|
On 18.04.2006, at 22:48, Stephen Deasey wrote: > An API that allows easy sharing between C and Tcl code is an > interesting idea, e.g. a filter written in C storing data for a page > written in Tcl. But that's not what's been implemented. Too bad. I thought it is something in this direction. > > As it stands, it's possible for C code to call down to Tcl and grab a > global variable, it's impossible to get at the tls data as the tls key > is a private variable in the nsd/tclinit.c file. > > One bug with the current implementation is that virtual servers will > stomp on each others data. > Even worse. Hm... in that case I'd put this out of the server and into the module. Normally I do not have anything against extending core server but the more things we put into, the more things need to be maintained, tested, understood, etc... So on one side I'd love to see more features and on another I have headaches when thinking about what we already have inside and what we alone do not grasp. Temptation is strong to add something ad-hoc to solve an immediate problem but we should really make our life little bit more difficult on the short term by writing an RFE first and then discuss, eventually bless it and then integrate it in the core. I know this sounds somehow buerocratic but this little burden will pay off for sure on the long term. For the current tls issue: ideally I'd see something like simple way of handling stuff from Tcl and from C code which I thought ns_tls is (would be). A Ns_Set seems OK as it has both C and Tcl api. And, sets can be shared (thread-wide) and thread private, so instead of pulling yet-another data-structure inside, why not see if Ns_Set is enough for what Vlad is needing? Cheers Zoran > > > On 4/18/06, Vlad Seryakov <vl...@cr...> wrote: >> Not you exactly but both of you and Stephen:-))) >> >> Global Tcl vars is more cleaner Tcl-only solution but i agree >> interoperability between C and Tcl using ns-tls would be a good =20 >> feature. >> Internally ns_tls keeps Ns_set, so getting this from C would be just >> gettting pointer to Ns_Set structure. It just requires more C-level >> calls something like Ns_GetTclTls()/Ns_SetTclTcls() >> >> Zoran Vasiljevic wrote: >>> >>> On 18.04.2006, at 15:52, Vlad Seryakov wrote: >>> >>>> You convinced me that at this moment ns_tls is not appropriate, =20 >>>> i will >>>> remove it >>> >>> Oh?! How did I do that? Apart from giving a trivial >>> alternative, I think that this interface is ok per-se. >>> It allows "unified" access from Tcl and C code. >>> That is, one should be able to do the "same" from C >>> and Tcl. Isn't it so? >>> >>> Cheers >>> Zoran > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting =20 > language > that extends applications into web and mobile media. Attend the =20 > live webcast > and join the prime developer group breaking into this new coding =20 > territory! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=110944&bid$1720&dat=121642= > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel |
From: Vlad S. <vl...@cr...> - 2006-04-18 21:38:29
|
I suggest get it out of the core for now, i will live with global Tcl vars, that was immediate fix Zoran Vasiljevic wrote: > > On 18.04.2006, at 22:48, Stephen Deasey wrote: > >> An API that allows easy sharing between C and Tcl code is an >> interesting idea, e.g. a filter written in C storing data for a page >> written in Tcl. But that's not what's been implemented. > > Too bad. I thought it is something in this direction. > >> >> As it stands, it's possible for C code to call down to Tcl and grab a >> global variable, it's impossible to get at the tls data as the tls key >> is a private variable in the nsd/tclinit.c file. >> >> One bug with the current implementation is that virtual servers will >> stomp on each others data. >> > > Even worse. Hm... in that case I'd put this out of the server > and into the module. > > Normally I do not have anything against extending core > server but the more things we put into, the more things > need to be maintained, tested, understood, etc... So > on one side I'd love to see more features and on another > I have headaches when thinking about what we already have > inside and what we alone do not grasp. Temptation is strong > to add something ad-hoc to solve an immediate problem but we > should really make our life little bit more difficult on the > short term by writing an RFE first and then discuss, eventually > bless it and then integrate it in the core. I know this sounds > somehow buerocratic but this little burden will pay off for sure > on the long term. > > For the current tls issue: ideally I'd see something like > simple way of handling stuff from Tcl and from C code which > I thought ns_tls is (would be). A Ns_Set seems OK as it has > both C and Tcl api. And, sets can be shared (thread-wide) and > thread private, so instead of pulling yet-another data-structure > inside, why not see if Ns_Set is enough for what Vlad is needing? > > Cheers > Zoran > >> >> >> On 4/18/06, Vlad Seryakov <vl...@cr...> wrote: >>> Not you exactly but both of you and Stephen:-))) >>> >>> Global Tcl vars is more cleaner Tcl-only solution but i agree >>> interoperability between C and Tcl using ns-tls would be a good feature. >>> Internally ns_tls keeps Ns_set, so getting this from C would be just >>> gettting pointer to Ns_Set structure. It just requires more C-level >>> calls something like Ns_GetTclTls()/Ns_SetTclTcls() >>> >>> Zoran Vasiljevic wrote: >>>> >>>> On 18.04.2006, at 15:52, Vlad Seryakov wrote: >>>> >>>>> You convinced me that at this moment ns_tls is not appropriate, i will >>>>> remove it >>>> >>>> Oh?! How did I do that? Apart from giving a trivial >>>> alternative, I think that this interface is ok per-se. >>>> It allows "unified" access from Tcl and C code. >>>> That is, one should be able to do the "same" from C >>>> and Tcl. Isn't it so? >>>> >>>> Cheers >>>> Zoran >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by xPML, a groundbreaking scripting >> language >> that extends applications into web and mobile media. Attend the live >> webcast >> and join the prime developer group breaking into this new coding >> territory! >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 >> _______________________________________________ >> naviserver-devel mailing list >> nav...@li... >> https://lists.sourceforge.net/lists/listinfo/naviserver-devel > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Vlad S. <vl...@cr...> - 2006-04-18 21:30:52
|
I agree, the question is: remove it completely or make it better C/Tcl sharing API? As for static tls key, i would create 2 public functions that return and set TLS data, this way key can still be private. Also, we run cleanups on connection close, so we can cleanup this data as well. Stephen Deasey wrote: > An API that allows easy sharing between C and Tcl code is an > interesting idea, e.g. a filter written in C storing data for a page > written in Tcl. But that's not what's been implemented. > > As it stands, it's possible for C code to call down to Tcl and grab a > global variable, it's impossible to get at the tls data as the tls key > is a private variable in the nsd/tclinit.c file. > > One bug with the current implementation is that virtual servers will > stomp on each others data. > > > > On 4/18/06, Vlad Seryakov <vl...@cr...> wrote: >> Not you exactly but both of you and Stephen:-))) >> >> Global Tcl vars is more cleaner Tcl-only solution but i agree >> interoperability between C and Tcl using ns-tls would be a good feature. >> Internally ns_tls keeps Ns_set, so getting this from C would be just >> gettting pointer to Ns_Set structure. It just requires more C-level >> calls something like Ns_GetTclTls()/Ns_SetTclTcls() >> >> Zoran Vasiljevic wrote: >>> On 18.04.2006, at 15:52, Vlad Seryakov wrote: >>> >>>> You convinced me that at this moment ns_tls is not appropriate, i will >>>> remove it >>> Oh?! How did I do that? Apart from giving a trivial >>> alternative, I think that this interface is ok per-se. >>> It allows "unified" access from Tcl and C code. >>> That is, one should be able to do the "same" from C >>> and Tcl. Isn't it so? >>> >>> Cheers >>> Zoran > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Stephen D. <sd...@gm...> - 2006-04-19 17:10:07
|
On 4/18/06, Vlad Seryakov <vl...@cr...> wrote: > > As for static tls key, i would create 2 public functions that return and > set TLS data, this way key can still be private. > > Also, we run cleanups on connection close, so we can cleanup this data > as well. Hmm, clean up on connection close? It doesn't sound like your describing Thread Local Storage to me -- more like Ns_Cls*. This needs to be thought through a bit more. Exactly what problems is this solving, and how? |
From: Vlad S. <vl...@cr...> - 2006-04-19 18:00:15
|
It is thread storage but in case of conn thread which never ends, cleanup needs to be performs as with Ns_Cls* But yes, i will think about it more, for now we close this topic because it is removed already from the core Stephen Deasey wrote: > On 4/18/06, Vlad Seryakov <vl...@cr...> wrote: >> As for static tls key, i would create 2 public functions that return and >> set TLS data, this way key can still be private. >> >> Also, we run cleanups on connection close, so we can cleanup this data >> as well. > > > Hmm, clean up on connection close? It doesn't sound like your > describing Thread Local Storage to me -- more like Ns_Cls*. > > This needs to be thought through a bit more. Exactly what problems is > this solving, and how? > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > -- Vlad Seryakov 571 262-8608 office vl...@cr... http://www.crystalballinc.com/vlad/ |
From: Stephen D. <sd...@gm...> - 2006-04-19 19:18:48
|
On 4/19/06, Vlad Seryakov <vl...@cr...> wrote: > It is thread storage but in case of conn thread which never ends, > cleanup needs to be performs as with Ns_Cls* Hmm, an eviction policy -- sounds like a thread local Ns_Cache... Or, if cleanup is performed at the end of conn processing, as with Ns_Cls, and a conn runs in a single thread until completion, how is it different to Ns_Cls? If any one's interested in looking into thread local caches: I was thinking that this could be pushed down into the C API. But I don't know if this makes sense. More checking of how the ADP code uses thread local caches for Tcl code needs to be done. We could add a flags option NS_CACHE_THREAD_LOCAL or whatever to Ns_CacheCreate(). Ns_CacheLock/Unlock could depend on this flag. One thing I looked at is gathering stats in the thread local cache and then periodically flushing them to some common structure. I think there's an example of this in the cache code I posted to the SF tracker. Unfortunately you can't keep it completely in the C layer, as you'd like to optimise Tcl by storing Tcl objects directly, rather than stringifying them. |
From: Zoran V. <zv...@ar...> - 2006-04-19 20:09:58
|
On 19.04.2006, at 21:18, Stephen Deasey wrote: > > If any one's interested in looking into thread local caches: So we are back to thread local caches, storing objects directly i.e. w/o shimmering... I believe this is simpler to do as thread-wide stuff as there is no locking involved, or? Zoran > > I was thinking that this could be pushed down into the C API. But I > don't know if this makes sense. More checking of how the ADP code > uses thread local caches for Tcl code needs to be done. > > We could add a flags option NS_CACHE_THREAD_LOCAL or whatever to > Ns_CacheCreate(). Ns_CacheLock/Unlock could depend on this flag. > > One thing I looked at is gathering stats in the thread local cache and > then periodically flushing them to some common structure. I think > there's an example of this in the cache code I posted to the SF > tracker. > > Unfortunately you can't keep it completely in the C layer, as you'd > like to optimise Tcl by storing Tcl objects directly, rather than > stringifying them. > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, =20 > security? > Get stuff done quickly with pre-integrated technology to make your =20 > job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache =20 > Geronimo > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=120709&bid&3057&dat=121642= > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel |
From: Stephen D. <sd...@gm...> - 2006-04-22 20:39:50
|
On 4/19/06, Zoran Vasiljevic <zv...@ar...> wrote: > > On 19.04.2006, at 21:18, Stephen Deasey wrote: > > > > > If any one's interested in looking into thread local caches: > > > So we are back to thread local caches, storing objects > directly i.e. w/o shimmering... > I believe this is simpler to do as thread-wide stuff as > there is no locking involved, or? I just didn't want to put a lot of special case code in there for the two different cache types. Yet at the same time, I wanted to hide the guts of cache usage to make it easier. If you look at the nscache module it's a real mess. There's more code there than the current C and Tcl implementations combined. There's also nice to have stuff, like accurate stats which combine the stats from the individual threads to some master stats table, for example. But yeah, it's certainly possible. |