Re: cachetools v.0.3.1

2019-08-13 Thread ikod via Digitalmars-d-announce

On Tuesday, 13 August 2019 at 17:18:23 UTC, ag0aep6g wrote:

On 13.08.19 11:34, ikod wrote:

What is it?

cachetools - package with @safe and @nogc cache and containers 
implementations.

[...]

Project page: https://github.com/ikod/cachetools
docs: https://ikod.github.io/cachetools/


They don't seem to actually be @safe. An example:


import cachetools.containers.lists;
import std.stdio;
void main() @safe
{
DList!int dl;
dl.insert_first(42);
auto r = dl.range;
dl.clear();
writeln(r.front); /* Prints garbage, because it's accessing 
`free`d memory. */

}


As far as I can I see, that compiles because you have a bad 
@trusted here:


Probably this @trusted is not a problem (std.container.dlist also 
contain @trusted code). I mistakenly  ignored this case.


Thanks for your report, and  I'll create issue on github.


.

Other containers probably have similar problems.





Re: cachetools v.0.3.1

2019-08-13 Thread ag0aep6g via Digitalmars-d-announce

On 13.08.19 11:34, ikod wrote:

What is it?

cachetools - package with @safe and @nogc cache and containers 
implementations.

[...]

Project page: https://github.com/ikod/cachetools
docs: https://ikod.github.io/cachetools/


They don't seem to actually be @safe. An example:


import cachetools.containers.lists;
import std.stdio;
void main() @safe
{
DList!int dl;
dl.insert_first(42);
auto r = dl.range;
dl.clear();
writeln(r.front); /* Prints garbage, because it's accessing `free`d 
memory. */

}


As far as I can I see, that compiles because you have a bad @trusted 
here: 
.


Other containers probably have similar problems.


Re: cachetools v.0.3.1

2019-08-13 Thread ikod via Digitalmars-d-announce
On Tuesday, 13 August 2019 at 10:12:45 UTC, Martin Tschierschke 
wrote:

On Tuesday, 13 August 2019 at 09:34:48 UTC, ikod wrote:

Hello

cachetools version 0.3.1 released


[...]
Looking at your performance numbers, I am wondering should your 
work in the end result in a better std AA implementation?


Regards mt.


I'm not sure if I can say too much here. And I can be wrong, but 
looks like std AA allocate table bucket entry on every insert. 
This can hurt performance when you have mixed insert/lookup use 
case. If this is the case then fix will require rewrite of AA 
code.


Thanks and regards,
Igor


Re: cachetools v.0.3.1

2019-08-13 Thread Martin Tschierschke via Digitalmars-d-announce

On Tuesday, 13 August 2019 at 09:34:48 UTC, ikod wrote:

Hello

cachetools version 0.3.1 released


[...]
Looking at your performance numbers, I am wondering should your 
work in the end result in a better std AA implementation?


Regards mt.



Re: cachetools v.0.3.1

2019-08-13 Thread ikod via Digitalmars-d-announce

Hello

cachetools version 0.3.1 released

Changelog:

"Set" container added (based on hashtable)
Const-ness problems for hashtable fixed.

What is it?

cachetools - package with @safe and @nogc cache and containers  
implementations.


It inherits @nogc and @safe property from key toHash and opEquals 
methods and can store immutable keys and values (with 
restrictions).


Currently implemented:

caches: LRU, 2Q (with TTL)

containers: HashMap, OrderedHashMap, unrolled list, dlist, slist, 
set


Project page: https://github.com/ikod/cachetools
docs: https://ikod.github.io/cachetools/

Some performance test results:
https://github.com/ikod/cachetools/tree/master/testhash