Skip to content
This repository has been archived by the owner on Sep 30, 2023. It is now read-only.

Optimize loading #275

Merged
merged 39 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7297675
add fetch entries test
shamb0t Nov 4, 2019
d7c04af
add refs property to Entry
shamb0t Nov 5, 2019
007a886
WIP
Nov 9, 2019
65290ba
fix: trim nexts to match length in EntryIO.fetchAll
shamb0t Nov 11, 2019
e2ad002
fix: remove duplicates in entries list
shamb0t Nov 11, 2019
4429bb9
fix tests
shamb0t Nov 12, 2019
5d31278
Improve entry fetching algorithm
Nov 18, 2019
bc088db
add 'refs' to IPLD_LINKS
shamb0t Nov 18, 2019
14e9bfb
Pass sort function to fromEntryHash
Nov 18, 2019
40ef717
Fix backwards compatibility issue with refs
Nov 18, 2019
824c96e
add v1 fixtures
shamb0t Nov 18, 2019
eec1577
Use orbit-db-io from master
Nov 18, 2019
0e00304
add static Entry.toEntry
shamb0t Nov 18, 2019
5add055
fix v0 fixtures
shamb0t Nov 18, 2019
8e9a1f1
fix test hashes
shamb0t Nov 18, 2019
998d793
fix tests
shamb0t Nov 18, 2019
0f312e9
wip browser tests failing
shamb0t Nov 19, 2019
6382f07
fix linting
shamb0t Nov 19, 2019
8e8bf19
add v1 entry tests
shamb0t Nov 19, 2019
213dc1e
Make v1 multihash explicit in test
Nov 19, 2019
2310762
WIP
Nov 19, 2019
4de038e
add tests for v0 and v1 entries
shamb0t Nov 19, 2019
b3b49e1
expose Entry.getWriteFormat
shamb0t Nov 19, 2019
f864346
fix linting
shamb0t Nov 19, 2019
0b7f8e1
Merge pull request #278 from orbitdb/feat/bc-2
haadcode Nov 20, 2019
e8b3f85
Fix browser benchmarks
Nov 20, 2019
b1eb206
Fix log example
Nov 20, 2019
9163e5b
Fix browser examples
Nov 20, 2019
103aaa3
Add timeout back into entry-io
Nov 20, 2019
e64569c
Fix linter
Nov 20, 2019
d4b519e
Update build and package-lock
Nov 20, 2019
ae8e5c0
Add description to timeout test fail
Nov 20, 2019
ec77537
Fix timeout tests
Nov 20, 2019
d26a4ac
Fix benchmarks
Nov 25, 2019
de05cac
fix benchmark ids
shamb0t Nov 25, 2019
3cfddd1
update orbit-db-identity-provider
shamb0t Nov 26, 2019
95154b4
add pin option
shamb0t Nov 27, 2019
cacf2df
Take max of pointerCount or headCount
Nov 29, 2019
2e95856
Merge pull request #287 from orbitdb/feat/optional-pin
haadcode Nov 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ node_modules/
coverage/
ipfs/
ipfs-log/
orbitdb/
dist/*.js.map
examples/browser/bundle.js
test/keystore/
test-keys/
test/browser/bundle.js
test/browser/bundle.js.map
ipfs-log-benchmarks/
examples/browser/bundle.js.map
examples/browser/ipfs.min.js
examples/browser/ipfslog.min.js
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ build: test
clean:
rm -rf ipfs/
rm -rf ipfs-log-benchmarks/
rm -rf orbitdb/
rm -rf node_modules/
rm -rf coverage/
rm -rf test/keystore/
Expand Down
9 changes: 2 additions & 7 deletions benchmarks/benchmark-append.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ const Log = require('../src/log')
const IdentityProvider = require('orbit-db-identity-provider')
const Keystore = require('orbit-db-keystore')

const leveldown = require('leveldown')
const storage = require('orbit-db-storage-adapter')(leveldown)

// State
let ipfs
let log
Expand All @@ -21,7 +18,7 @@ let queriesPerSecond = 0
let lastTenSeconds = 0

const queryLoop = async () => {
await log.append(totalQueries.toString())
await log.append(totalQueries.toString(), 1, false)
totalQueries++
lastTenSeconds++
queriesPerSecond++
Expand Down Expand Up @@ -56,9 +53,7 @@ let run = (() => {
// const memstore = new MemStore()
// ipfs.dag.put = memstore.put.bind(memstore)
// ipfs.dag.get = memstore.get.bind(memstore)
const signingKeysPath = './test/fixtures/keys'
const store = await storage.createStore(signingKeysPath)
const keystore = new Keystore(store)
const keystore = new Keystore('./ipfs-log-benchmarks/keys/')
const identity = await IdentityProvider.createIdentity({ id: 'userA', keystore })

log = new Log(ipfs, identity, { logId: 'A' })
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/benchmark-from-entry-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const IPFSRepo = require('ipfs-repo')
const DatastoreLevel = require('datastore-level')
const Log = require('../src/log')
const IdentityProvider = require('orbit-db-identity-provider')

const Keystore = require('orbit-db-keystore')
// State
let ipfs
let log
Expand All @@ -27,7 +27,7 @@ let run = (() => {
}

ipfs = new IPFS({
repo: new IPFSRepo('./ipfs-log-benchmarks/fromEntryHash/ipfs', repoConf),
repo: new IPFSRepo('./ipfs-log-benchmarks/ipfs', repoConf),
start: false,
EXPERIMENTAL: {
pubsub: false,
Expand All @@ -42,8 +42,8 @@ let run = (() => {

ipfs.on('ready', async () => {
// Create a log
const signingKeysPath = './test/fixtures/keys'
const identity = await IdentityProvider.createIdentity({ id: 'userA', signingKeysPath })
const keystore = new Keystore('./ipfs-log-benchmarks/keys/')
const identity = await IdentityProvider.createIdentity({ id: 'userA', keystore })

log = new Log(ipfs, identity, { logId: 'A' })

Expand Down
7 changes: 4 additions & 3 deletions benchmarks/benchmark-join.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const IPFSRepo = require('ipfs-repo')
const DatastoreLevel = require('datastore-level')
const Log = require('../src/log')
const IdentityProvider = require('orbit-db-identity-provider')
const Keystore = require('orbit-db-keystore')

// State
let ipfs
Expand Down Expand Up @@ -62,10 +63,10 @@ let run = (() => {
// const memstore = new MemStore()
// ipfs.dag.put = memstore.put.bind(memstore)
// ipfs.dag.get = memstore.get.bind(memstore)
const keystore = new Keystore('./ipfs-log-benchmarks/keys/')

const signingKeysPath = './test/fixtures/keys'
const identity = await IdentityProvider.createIdentity({ id: 'userA', signingKeysPath })
const identity2 = await IdentityProvider.createIdentity({ id: 'userB', signingKeysPath })
const identity = await IdentityProvider.createIdentity({ id: 'userA', keystore })
const identity2 = await IdentityProvider.createIdentity({ id: 'userB', keystore })

log1 = new Log(ipfs, identity, { logId: 'A' })
log2 = new Log(ipfs, identity2, { logId: 'A' })
Expand Down
96 changes: 96 additions & 0 deletions benchmarks/benchmark-join2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
'use strict'

const IPFS = require('ipfs')
const IPFSRepo = require('ipfs-repo')
const DatastoreLevel = require('datastore-level')
const Log = require('../src/log')
const IdentityProvider = require('orbit-db-identity-provider')
const Keystore = require('orbit-db-keystore')

// State
let ipfs
let log1, log2

// Metrics
let totalQueries = 0
const queryLoop = async () => {
try {
await Promise.all([
log1.append('a' + totalQueries),
log2.append('b' + totalQueries)
])

await log1.join(log2)
await log2.join(log1)
totalQueries++
setImmediate(queryLoop)
} catch (e) {
console.error(e)
process.exit(0)
}
}

let run = (() => {
console.log('Starting benchmark...')

const repoConf = {
storageBackends: {
blocks: DatastoreLevel
}
}

ipfs = new IPFS({
repo: new IPFSRepo('./ipfs-log-benchmarks/ipfs', repoConf),
start: false,
EXPERIMENTAL: {
pubsub: true
}
})

ipfs.on('error', (err) => {
console.error(err)
process.exit(1)
})

ipfs.on('ready', async () => {
// Use memory store to test without disk IO
// const memstore = new MemStore()
// ipfs.dag.put = memstore.put.bind(memstore)
// ipfs.dag.get = memstore.get.bind(memstore)
const keystore = new Keystore('./benchmarks/ipfs-log-benchmarks/keys')
const identity = await IdentityProvider.createIdentity({ id: 'userA', keystore })
const identity2 = await IdentityProvider.createIdentity({ id: 'userB', keystore })

log1 = new Log(ipfs, identity, { logId: 'A' })
log2 = new Log(ipfs, identity2, { logId: 'A' })

const amount = 10000
console.log('log length:', amount)

console.log('Writing log...')
const st3 = new Date().getTime()
for (let i = 0; i < amount; i++) {
await log1.append('a' + i, 64)
}
const et3 = new Date().getTime()
console.log('write took', (et3 - st3), 'ms')

console.log('Joining logs...')
const st = new Date().getTime()
await log2.join(log1)
const et = new Date().getTime()
console.log('join took', (et - st), 'ms')

console.log('Loading log...')
const st2 = new Date().getTime()
const l2 = await Log.fromEntryHash(ipfs, identity, log1.heads[0].hash, { logId: 'A' })
const et2 = new Date().getTime()
console.log('load took', (et2 - st2), 'ms')
console.log('Entry size:', Buffer.from(JSON.stringify(l2.heads)).length, 'bytes')
// console.log(log2.heads)
console.log('log length:', log2.values.length)
// console.log(log2.values.map(e => e.payload))
})
})()

module.exports = run
26 changes: 13 additions & 13 deletions benchmarks/browser/benchmark-append-signed.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ <h2>Results</h2>
<pre id="output"></pre>

<script type="text/javascript" src="../../dist/ipfslog.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../node_modules/orbit-db-keystore/dist/index-browser.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../node_modules/orbit-db-identity-provider/dist/index-browser.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../node_modules/ipfs/dist/index.min.js" charset="utf-8"></script>

Expand All @@ -32,20 +31,21 @@ <h2>Results</h2>
let queriesPerSecond = 0
let lastTenSeconds = 0

const queryLoop = () => {
return log.append(totalQueries.toString())
.then((res) => {
totalQueries ++
lastTenSeconds ++
queriesPerSecond ++
setImmediate(queryLoop)
})
.catch((e) => console.error(e))
const queryLoop = async () => {
try {
await log.append(totalQueries.toString())
totalQueries ++
lastTenSeconds ++
queriesPerSecond ++
setImmediate(queryLoop)
} catch (e) {
console.error(e)
}
}

let run = (() => {
ipfs = new Ipfs({
repo: './ipfs-log/examples/browser/benchmark-append/0.34.4',
repo: './ipfs-log/examples/browser/benchmark-append-signed',
start: false,
EXPERIMENTAL: {
pubsub: false,
Expand All @@ -72,9 +72,9 @@ <h2>Results</h2>
queriesPerSecond = 0
}, 1000)

const signingKeysPath = '../test/fixtures/keys'
const identity = await Identities.createIdentity({ id: 'userA', signingKeysPath })
const identity = await Identities.createIdentity({ id: 'userA' })
log = new Log(ipfs, identity, { logId: 'browser-benchmark-append-signed' })

queryLoop()
})

Expand Down
36 changes: 16 additions & 20 deletions benchmarks/browser/benchmark-join-signed.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ <h2>Results</h2>
<pre id="output"></pre>

<script type="text/javascript" src="../../dist/ipfslog.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../node_modules/orbit-db-keystore/dist/index-browser.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../node_modules/orbit-db-identity-provider/dist/index-browser.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../node_modules/ipfs/dist/index.min.js" charset="utf-8"></script>

Expand All @@ -42,26 +41,25 @@ <h2>Results</h2>
let lastTenSeconds = 0
let log1, log2

const { AccessController } = Log
const queryLoop = () => {
const add1 = log1.append("a" + totalQueries)
const add2 = log2.append("b" + totalQueries)

Promise.all([add1, add2])
.then((res) => {
log1.join(log2)
log2.join(log1)
totalQueries ++
lastTenSeconds ++
queriesPerSecond ++
setImmediate(queryLoop)
})
.catch((e) => console.error(e))
const queryLoop = async () => {
try {
const add1 = log1.append("a" + totalQueries)
const add2 = log2.append("b" + totalQueries)
await Promise.all([add1, add2])
log1.join(log2)
log2.join(log1)
totalQueries ++
lastTenSeconds ++
queriesPerSecond ++
setImmediate(queryLoop)
} catch(e) {
console.error(e)
}
}

let run = (() => {
ipfs = new Ipfs({
repo: './ipfs-log/examples/browser/benchmark-join/new/0.33.1',
repo: './ipfs-log/examples/browser/benchmark-join-signed',
start: false,
EXPERIMENTAL: {
pubsub: false,
Expand All @@ -88,9 +86,7 @@ <h2>Results</h2>
queriesPerSecond = 0
}, 1000)

const testKeyPath = '../test/fixtures/keys'
const keystore = Keystore.create(testKeyPath)
const identity = await Identities.createIdentity({ id: 'userA', keystore })
const identity = await Identities.createIdentity({ id: 'userA' })

log1 = new Log(ipfs, identity, { logId: 'browser-benchmark-join-signed' })
log2 = new Log(ipfs, identity, { logId: 'browser-benchmark-join-signed' })
Expand Down
14 changes: 7 additions & 7 deletions dist/ipfslog.min.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions examples/browser/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ <h1>ipfs-log example</h1>
<pre id="output"></pre>

<script type="text/javascript" src="../../dist/ipfslog.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../node_modules/orbit-db-keystore/dist/index-browser.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../node_modules/orbit-db-identity-provider/dist/index-browser.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../node_modules/ipfs/dist/index.min.js" charset="utf-8"></script>

<script type="text/javascript">
const dataPath = './ipfs-log/examples/browser/ipfs-0.34.4'
const dataPath = './ipfs-log/examples/browser/ipfs/browser.html'
const ipfs = new Ipfs({
repo: dataPath + '/index.js',
repo: dataPath,
start: false,
EXPERIMENTAL: {
pubsub: true
Expand Down
4 changes: 2 additions & 2 deletions examples/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const IPFS = require('ipfs')
const IdentityProvider = require('orbit-db-identity-provider')
const Log = require('../../src/log')

const dataPath = './ipfs-log/examples/browser/ipfs-0.34.4'
const dataPath = './ipfs-log/examples/browser/ipfs/index.html'
const ipfs = new IPFS({
repo: dataPath + '/index.js',
repo: dataPath,
start: false,
EXPERIMENTAL: {
pubsub: true
Expand Down
Loading