WASM and SQLite Investigations Part 2

_putBlock(store, file, index, blockData) {
const key = this._blockKey(file.meta.name, index);
file.cache.delete(key);
file.cache.set(key, { data: blockData, dirty: true });
/* this._purgeCache(store, file); */
}
// Default block size for new databases.const BLOCK_SIZE = 32768; // was 8192
if (blockIndex <= lastBlockIndex && blockBytes < meta.blockSize) {
// The write is to only part of a block that may have been
// already written.
blockData = await this._getBlock(store, file, blockIndex);
}
if (!blockData) {
// We should reach here when:
// — writing a complete block
// — writing past the previous last block of the file
// — writing in an empty gap
blockData = new ArrayBuffer(meta.blockSize);
}
  • The emcc target was “unknown” I faked it as standard linux
  • Array sizes specified by a const int didn’t work so I changed the const to a macro
  • The ‘abort’ shim in the test didn’t work in this environment so I disabled that test
  • It’s likely that Safari is taking a very different approach on IndexedDB writes, we could look into this but I suspect they are less complete when they let the async promise resolve
  • I was able to get a significant speedup in the VFS with just a cursory look at it, if we thought harder about how to do the async and when exactly to sync we could do considerably better still
  • Safari is probably giving us the best-we-can-hope-for number and that number seems very reasonable, more careful use of await can probably get us closer to the Safari time on Chromium
  • We should probably have a look at Firefox and maybe follow-up with some perf folks on Edge/Chrome to see what’s going on here

--

--

--

I’m a software engineer at Facebook; I specialize in software performance engineering and programming tools generally. I survived Microsoft from 1988 to 2017.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Spark on Kubernetes

What’s a monitor in Java?

Better Together: Using Pair Programming to Build Inclusion

How to Write a Smart Contract on Ontology with Python — (Part 3)

How to launch an Apache Web Server from the CLI

The #OpenErlang Interviews Video Series

Building an iOS-style Shopping App with a minimalist design using Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rico Mariani

Rico Mariani

I’m a software engineer at Facebook; I specialize in software performance engineering and programming tools generally. I survived Microsoft from 1988 to 2017.

More from Medium

Avoiding using Serde in Rust WebAssembly When Performance Matters

Erlang/OTP profiling: eprof

My Battlesnake Server — The Basics

spinlock vs mutex performance