-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use a shared object with multiple length keys to store regl buffers #140
use a shared object with multiple length keys to store regl buffers #140
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @bmschmidt and the rest of your teammates on Graphite |
290e0fe
to
dd9bc11
Compare
aa964e6
to
2dac6bb
Compare
private _integer_buffer?: Buffer; | ||
|
||
constructor(renderer: ReglRenderer) { | ||
this.regl = renderer.regl; | ||
this.renderer = renderer; | ||
// Reuse the same buffer for all `ix_in_tile` keys, because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for creating a buffer for 'ix_in_tile' is repeated in both the constructor and the create_regl_buffer method. Consider refactoring to avoid repetition and adhere to the DRY principle.
* @returns A Float32-converted version of the data in the column | ||
* suitable to be dropped onto a webGL buffer. | ||
*/ | ||
convertToGlFormat(column: Vector<DS.SupportedArrowTypes>): Float32Array { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convertToGlFormat
method is complex and handles various data types. Consider adding comments to explain the logic, especially for timestamp conversion and dictionary handling, to improve code readability and maintainability.
dd9bc11
to
cd93751
Compare
2dac6bb
to
c7a8537
Compare
constructor(regl: Regl, tile: Tile, renderer: ReglRenderer) { | ||
this.tile = tile; | ||
this.regl = regl; | ||
private bufferMap: WeakMap<ArrayBufferView, DS.BufferLocation> = new Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using WeakMap
for bufferMap
is incorrect as WeakMap
should be used for objects, not ArrayBufferView
. Consider using a regular Map
instead.
cd93751
to
8b458b7
Compare
c7a8537
to
2315827
Compare
2315827
to
d175c73
Compare
@@ -123,7 +120,8 @@ export class Tile { | |||
|
|||
deleteColumn(colname: string) { | |||
if (this._batch) { | |||
this._buffer_manager?.release(colname); | |||
console.warn('Deleting column from tile doesnt free GPU memory'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deleteColumn
method does not free GPU memory, which could lead to memory leaks. Consider implementing GPU memory release when a column is deleted.
d175c73
to
fb591fb
Compare
These two PRs need to get rebased in some form right? I'm seeing "Trunk branch locked" in graphite |
Yeah |
It's weird though they used to be on |
fb591fb
to
9cdf75f
Compare
9cdf75f
to
5903dbd
Compare
@@ -45,6 +41,8 @@ import { Color } from './aesthetics/ColorAesthetic'; | |||
import { StatefulAesthetic } from './aesthetics/StatefulAesthetic'; | |||
import { Filter, Foreground } from './aesthetics/BooleanAesthetic'; | |||
import { ZoomTransform } from 'd3-zoom'; | |||
import { TupleMap } from './utilityFunctions'; | |||
import { buffer } from 'd3'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import 'buffer' from 'd3' is unused and can be removed to clean up the code.
Merged through other mans |
Previously deepscatter had something called a TileBufferManager. This doesn't make a huge amount of sense, and had a concrete cost; if two tiles used the same underlying Arrow memory for a column (say, 2**16 floating point zeros), then we'd use different memory on the GPU for them.
This PR revamps that storage so that it uses the new TupleMap class. There is a single shared buffer manager across the whole plot, which uses a key that includes the tile itself and then the string name of the field desired (which is now actually string[], for help in the next PR.)
This map associates each column with its underlying Arrow vector memory, and it is that memory that is used as a key to the GPU buffers. This is a little weird, but the two-step operation means taht we can re-use memory more efficiently.
At some later point I'll more fully build on this. One goal is that for four types of floating point data we can always use a single webGL buffer instead of re-allocating them ad-infinitum:
Important
Refactor buffer management by replacing
TileBufferManager
with a sharedBufferManager
for efficient GPU memory usage across tiles.TileBufferManager
with a sharedBufferManager
usingTupleMap
for efficient GPU memory management.BufferManager
uses a key with tile and field name for buffer management.BufferManager.get
andBufferManager.ready
for buffer retrieval and readiness checks.ReglRenderer
to use a singleBufferManager
instance._buffer_manager
references fromTile
class.tile
andcount
properties.ColorChange.svelte
.This description was created by for 5903dbd. It will automatically update as commits are pushed.