Comments (4)
Hey Vladislav!
Thanks for your feedback!
Can you share some code?
I want to try and figure if there's any specific slowdown cause in your use case
Currently the object is implement using simple linked list, and there's inherit overhead of working with arraybuffer that way, but it can be improved
from objectbuffer.
import * as objectbufferModule from "@bnaya/objectbuffer";
import { job, start, stop } from "microjob";
(async () => {
await start({ maxWorkers: 1 });
// cache require
await job(() => {
require("@bnaya/objectbuffer");
});
console.time("buffer");
const externalArgs: objectbufferModule.ExternalArgs = {
textEncoder: new TextEncoder(),
textDecoder: new TextDecoder(),
arrayAdditionalAllocation: 20,
minimumStringAllocation: 0
};
const myObjectBufferOnMainThread = objectbufferModule.createObjectBuffer(
externalArgs,
1024,
{
some: {
nested: [
{
thing: "im the value to follow"
}
]
}
},
{ useSharedArrayBuffer: true }
);
const shared = objectbufferModule.getUnderlyingArrayBuffer(
myObjectBufferOnMainThread
);
await job(
async () => {
const objectbufferModule = require("@bnaya/objectbuffer");
const myObjectBufferOnMainThread = objectbufferModule.loadObjectBuffer(
{
textEncoder: new TextEncoder(),
textDecoder: new TextDecoder(),
arrayAdditionalAllocation: 20,
minimumStringAllocation: 0
},
shared
);
myObjectBufferOnMainThread.some.nested.push(13);
},
{ shared }
);
console.log(myObjectBufferOnMainThread.some.nested[1]);
console.timeEnd("buffer");
console.time("simple");
let data = {
some: {
nested: [
{
thing: "im the value to follow"
}
]
}
};
const newData = await job(
async data => {
data.some.nested.push(13);
return data;
},
{ data }
);
console.log(newData.some.nested[1]);
console.timeEnd("simple");
// stop();
})();
Please, install microjob from here: darky/microjob#a00474ef0e833c3d09435f080b6ff9aae9b342f8
Shared memory support not merged at this moment
from objectbuffer.
For small objects, the speed of serialize + deserialize is expected to always be faster than using that library.
The overhead of writing all the logic in javascript, has it price.
But for example, if you want to sort big array on a worker,
that serialize + deserialize will be expensive from CPU and memory wise.
A side note: you are not using locks, you might get data races.
from objectbuffer.
Ok, thanks! I try to benchmark on larger data later :)
from objectbuffer.
Related Issues (20)
- [Optimizations] In hashmap creation don't check if key already exists in bucket
- Add more benchmarks to CI
- Make object faster maybe similar to https://v8.dev/blog/fast-properties HOT 6
- Global string dedup cache
- Why does Node.js not provide something like SharedObjectBuffers out of the box? HOT 4
- look for v8 deopts
- Data structures notes [WIP]
- Allocator changes working plan HOT 1
- Near-term work plan
- [Feat]Iterative/non-blocking memory reclaim
- [Feat]Remove the class wrapper on top of the functional allocator
- [Feat]Find and refactor-out closures
- Explore thread-safe lock-free data structures using atomics
- Track resizablearraybuffer proposal [Stage 3] HOT 2
- [BUG] Make not sense when i tried to get non-existent array index HOT 4
- Track structs - Fixed Layout Objects proposal [Stage 1]
- npm run browser-playground not working: SyntaxError: Cannot use import statement outside a module HOT 2
- Would it make sense to support WeakMaps? HOT 1
- RangeError: Start offset undefined is outside the bounds of the buffer HOT 3
- How to reliably estimate size without too much overhead? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objectbuffer.