mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-02-24 15:33:39 +00:00
Adds duration to repostore logs for getBlock and putBlock
This commit is contained in:
parent
0cffa02748
commit
35a93cc40d
2
.github/workflows/docker-dist-tests.yml
vendored
2
.github/workflows/docker-dist-tests.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
||||
name: Build and Push
|
||||
uses: ./.github/workflows/docker-reusable.yml
|
||||
with:
|
||||
nimflags: '-d:disableMarchNative -d:codex_enable_api_debug_peers=true -d:codex_enable_proof_failures=true -d:codex_enable_log_counter=true -d:verify_circuit=true'
|
||||
nimflags: '-d:disableMarchNative -d:codex_enable_api_debug_peers=true -d:codex_enable_proof_failures=true -d:codex_enable_log_counter=true -d:verify_circuit=true -d:codex_enable_repostore_timinglogs=true'
|
||||
nat_ip_auto: true
|
||||
tag_latest: ${{ github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/') }}
|
||||
tag_suffix: dist-tests
|
||||
|
||||
@ -27,6 +27,12 @@ import ../../logutils
|
||||
import ../../merkletree
|
||||
import ../../utils
|
||||
|
||||
const
|
||||
codex_enable_repostore_timinglogs* {.booldefine.} = false
|
||||
|
||||
when codex_enable_repostore_timinglogs:
|
||||
import std/monotimes
|
||||
|
||||
export blocktype, cid
|
||||
|
||||
logScope:
|
||||
@ -51,6 +57,9 @@ method getBlock*(self: RepoStore, cid: Cid): Future[?!Block] {.async.} =
|
||||
trace "Error getting key from provider", err = err.msg
|
||||
return failure(err)
|
||||
|
||||
when codex_enable_repostore_timinglogs:
|
||||
let startTime = getMonoTime().ticks
|
||||
|
||||
without data =? await self.repoDs.get(key), err:
|
||||
if not (err of DatastoreKeyNotFound):
|
||||
trace "Error getting block from datastore", err = err.msg, key
|
||||
@ -58,7 +67,12 @@ method getBlock*(self: RepoStore, cid: Cid): Future[?!Block] {.async.} =
|
||||
|
||||
return failure(newException(BlockNotFoundError, err.msg))
|
||||
|
||||
trace "Got block for cid", cid
|
||||
when codex_enable_repostore_timinglogs:
|
||||
let durationUs = (getMonoTime().ticks - startTime) div 1000
|
||||
trace "Got block for cid", cid, durationUs
|
||||
else:
|
||||
trace "Got block for cid", cid
|
||||
|
||||
return Block.new(cid, data, verify = true)
|
||||
|
||||
method getBlockAndProof*(self: RepoStore, treeCid: Cid, index: Natural): Future[?!(Block, CodexProof)] {.async.} =
|
||||
@ -176,6 +190,9 @@ method putBlock*(
|
||||
|
||||
let expiry = self.clock.now() + (ttl |? self.blockTtl).seconds
|
||||
|
||||
when codex_enable_repostore_timinglogs:
|
||||
let startTime = getMonoTime().ticks
|
||||
|
||||
without res =? await self.storeBlock(blk, expiry), err:
|
||||
return failure(err)
|
||||
|
||||
@ -195,6 +212,10 @@ method putBlock*(
|
||||
else:
|
||||
trace "Block already exists"
|
||||
|
||||
when codex_enable_repostore_timinglogs:
|
||||
let durationUs = (getMonoTime().ticks - startTime) div 1000
|
||||
trace "putBlock", durationUs
|
||||
|
||||
return success()
|
||||
|
||||
method delBlock*(self: RepoStore, cid: Cid): Future[?!void] {.async.} =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user