Skip to content

Commit

Permalink
append improvment + update
Browse files Browse the repository at this point in the history
  • Loading branch information
ptmt committed May 13, 2012
1 parent 44d46fb commit 6b86f36
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 147 deletions.
14 changes: 6 additions & 8 deletions Kevo.Benchmarks/PerformanceTests.fs
Expand Up @@ -24,7 +24,7 @@ let inline testStraightWildcardSearch<'t> query =
//Kevo.Store.findByQuery<'t> query |> List.collect (fun x -> x.Syn)
let inline testDeserializeFromProtoBuf<'t> =
let c = Kevo.Core.getDictionary<'t>
//let k = Kevo.ProtoBuf.deserialize<'t>
//let k = Kevo.ProtoBuf.deserialize<'t>
Kevo.ProtoBuf.serialize<Dictionary<int, 't>> c (string typeof<'t>.GUID)
Kevo.JsonNet.serialize<Dictionary<int, 't>> c
let b = Kevo.JsonNet.deserialize<Dictionary<int, 't>>
Expand All @@ -37,17 +37,14 @@ let inline testAppend c =
[0..c] |> List.map (fun x -> Kevo.Store.append<string>(x, (string x), None)) |> ignore
let perf = float c / timer.Elapsed.TotalMilliseconds
printfn "%i; %f" c perf
Kevo.MemoryCache.clearCache Kevo.Core.cacheIndex<string>
printfn "%A" Kevo.Core.getDictionary<string>.Count


let inline testUpdate c =
let timer = new System.Diagnostics.Stopwatch()
timer.Start()
[0..c] |> List.map (fun x -> Kevo.Store.update<string>(x, (string x))) |> ignore
let perf = float c / timer.Elapsed.TotalMilliseconds
printfn "%i; %f" c perf
Kevo.MemoryCache.clearCache Kevo.Core.cacheIndex<string>
printfn "%A" Kevo.Core.getDictionary<string>.Count



let testAppendLoop lmax step type_of_append=
Expand All @@ -67,9 +64,10 @@ let testAppendLoop lmax step type_of_append=


let testWrapper<'t> query =
//testAppendLoop 100000 10000

testAppendLoop 100000 10000 "insert"
printfn "update"
testAppendLoop 100000 10000 "update"

printfn "ok"


Binary file modified Kevo.Benchmarks/screenshot1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Kevo.Core/Core.fs
Expand Up @@ -15,7 +15,7 @@ let getDictionary<'t> =
match a with
| null -> let b = deserialize<Dictionary<int, 't>> cacheIndex<'t>
(addToCache cacheIndex<'t> b)
printfn "%A added to cache" cacheIndex<'t>
//printfn "%A added to cache" cacheIndex<'t>
b
| _ -> a :?> Dictionary<int, 't>

Expand Down
4 changes: 2 additions & 2 deletions Kevo.Core/ProtoBuf.fs
Expand Up @@ -14,7 +14,7 @@ let serialize<'t> what where =
file.SetLength(file.Position); // fix truncated
file.Close())
stopWatch.Stop()
printfn "Protobuf serialization complete in %f ms" stopWatch.Elapsed.TotalMilliseconds
//printfn "Protobuf serialization complete in %f ms" stopWatch.Elapsed.TotalMilliseconds


let deserialize<'t> from =
Expand All @@ -24,7 +24,7 @@ let deserialize<'t> from =
let c = Serializer.Deserialize<'t>(file);
file.Close()
stopWatch.Stop()
printfn "Protobuf deserialization complete in %f ms" stopWatch.Elapsed.TotalMilliseconds
//printfn "Protobuf deserialization complete in %f ms" stopWatch.Elapsed.TotalMilliseconds
c
else
let t = System.Activator.CreateInstance(typeof<'t>)
Expand Down
33 changes: 22 additions & 11 deletions README.md
@@ -1,9 +1,9 @@
#KeVo

Damn Easy Key-Value Store written in F# 3.0.
KeVo is a Damn Easy Key-Value Store written in F# 3.0. It is in-memory store using System.Runtime.MemoryCache with full synchronized append log.

It serialize all objects in Protocol Buffers (Json.NET or binary serialization optional)

- serializing all Object in Protocol Buffers or Json.NET
- using System.Runtinme.MemoryCache

##Getting Started

Expand All @@ -13,13 +13,20 @@ Damn Easy Key-Value Store written in F# 3.0.

val findByQuery : ('t -> bool) -> 't list

And function for insert items:
insert items:

val append<'t> : int * 't * (unit -> unit) option -> unit

update

val update<'t> : int * 't -> unit

##Create/insert

By default if storage is not exist
By default if storage is not exist `append` function create new file. For example, to insert any string in Dictionary<int, string> just use `append` function:

let add_string index =
Kevo.Store.append<string>(index, (index x), None)

##Read

Expand All @@ -42,21 +49,25 @@ To find any item by id, use findById:
Use predicate function for search by any templates:

let query (x:WordItem) =
x.Wordst.Contains("ñëîâî")
x.Wordst.Contains("Local Street")
Kevo.Store.findByQuery<Address> query |> printfn "%A"


##Benchmarks

Few tests from: `Kevo.Benchmark`
Few tests from `Kevo.Benchmark`.

For Intel Core i5 2500K / 16gb RAM:
Test machine configuration is Intel Core i5 2500K / 16gb RAM:


Protobuf deserialization complete in 1431.623400 ms
Protobuf serialization complete in 311.327300 ms
Json.Net serialization complete in 1770.890400 ms
Json.Net deserialization complete in 3060.234400 ms
"Kevo.PerformanceTests+testWrapper@24[Kevo.Performance+WordItem]" Ellapsed Time: 2291.827700 ms
Json.Net deserialization complete in 3060.234400 ms
testReadSumAllNones 564674759
"Kevo.PerformanceTests+testWrapper@25-3[Kevo.Performance+WordItem]" Ellapsed Time: 66.317000 ms


### Append/Update


![benchmark screenshot](https://github.com/unknownexception/kevo/raw/master/Kevo.Benchmarks/screenshot1.png)
68 changes: 0 additions & 68 deletions kevo.test/Kevo.Tests.fsproj

This file was deleted.

52 changes: 0 additions & 52 deletions kevo.test/KevoTests.fs

This file was deleted.

4 changes: 0 additions & 4 deletions kevo.test/packages.config

This file was deleted.

2 changes: 1 addition & 1 deletion kevo.tests/KevoTests.fs
Expand Up @@ -37,7 +37,7 @@ let ``kevo should be able to commit int into memory and flush to disk`` () =

let random_value = System.Random(100).Next()
Kevo.AppendLog.appendSync<int> length_before random_value
//System.Threading.Thread.Sleep(1000)

Kevo.AppendLog.commit<int> |> shouldBeTrue

// all files must be deleted
Expand Down

0 comments on commit 6b86f36

Please sign in to comment.