Repository navigation
Fix bufferpool puts (ref #4976) - #6125
Conversation
There was a logic error in Put() which made us put all large blocks into segment zero, where we subsequently did not look for them. I also added a lowest threshold, as we otherwise allocate a 128KiB buffer when we need 24 bytes for a header and such.
|
This is still broken, I'mma add some tests |
|
Why are we not using it for small slices? There shouldn't be any downsides. I guess for things like headers we should just have a "static" slice, not to churn trash. |
|
The difference is only in when we don't have a block available in any bucket. Previously we'd allocate a 128 KiB block and return that. Granted, this is a block we can maybe reuse and that's good. But we've also just allocated 128 KiB when we just needed 24 bytes or whatever which comes from a completely different allocator area in Go... So... 🤷 And yes, I guess we should. But this is about making the buffer pool actually do buffer pooly things and not just allocate bytes forever... |
|
|
Different allocator area? First time I've heard that there is more than a single area. |
|
Small blocks come from arenas containing lots of equally sized blocks, allocated in chunks (pages). Large blocks are rounded up to page size and handled individually. So the cost for allocating a (say) 24 byte block is often near zero as we already have a page full of such blocks and just need to pick one, while a large allocation is seldom free. |
|
Made it a bit less chill and more panicky so we'll see if it's misused. |
|
PTAL |
|
Baaah. squash message. We should have a hook that prevents quickfire merges with bad names. |
* master: docker: Add stdiscosrv and strelaysrv Dockerfiles (syncthing#6143) lib/protocol: Buffer allocation when compressing (fixes syncthing#6146) (syncthing#6147) golang-ci: Upgrade, skipping the white space complainer all: Cleanups enabled by Go 1.12 lib/tlsutil: Remove Go 1.12 TLS 1.3 beta opt-in lib/api: Make theme paths relative (syncthing#6142) gui, lib/api: Adds support for prefers-color-scheme (fixes syncthing#6115) lib/api: Reset mtime after theme change (fixes syncthing#5810) (syncthing#6140) lib/model: Remove some testing deadlocks (syncthing#6138) lib/model: Add test for previous commit lib/model: Add initial deviceStatRefs on model creation (fixes syncthing#6136) (syncthing#6137) lib/model: Add folders on start in model (syncthing#6135) cmd/stbench: rm -r cmd/stbench (syncthing#6131) lib/api: Slightly unflake TestCSRFRequired by allowing longer timeout Fix bufferpool puts (ref syncthing#4976) (syncthing#6125) all: Remove dead code, fix lost msgLen checks (syncthing#6129) lib/upnp: Fix outdated comment (syncthing#6110)
* dbastr3: (37 commits) docker: Add stdiscosrv and strelaysrv Dockerfiles (syncthing#6143) lib/protocol: Buffer allocation when compressing (fixes syncthing#6146) (syncthing#6147) golang-ci: Upgrade, skipping the white space complainer all: Cleanups enabled by Go 1.12 lib/tlsutil: Remove Go 1.12 TLS 1.3 beta opt-in lib/api: Make theme paths relative (syncthing#6142) gui, lib/api: Adds support for prefers-color-scheme (fixes syncthing#6115) lib/api: Reset mtime after theme change (fixes syncthing#5810) (syncthing#6140) lib/model: Remove some testing deadlocks (syncthing#6138) lib/model: Add test for previous commit lib/model: Add initial deviceStatRefs on model creation (fixes syncthing#6136) (syncthing#6137) lib/model: Add folders on start in model (syncthing#6135) wip wip wip wip cmd/stbench: rm -r cmd/stbench (syncthing#6131) lib/api: Slightly unflake TestCSRFRequired by allowing longer timeout Fix bufferpool puts (ref syncthing#4976) (syncthing#6125) wip ...
There was a logic error in Put() which made us put all large blocks into
segment zero, where we subsequently did not look for them.
I also added a lowest threshold, as we otherwise allocate a 128KiB
buffer when we need 24 bytes for a header and such.
After:
Before: