Skip to content

Conversation

@satur9nine
Copy link
Contributor

@satur9nine satur9nine commented Nov 9, 2025

  • Builder startup work is cheaper: StartObject now seeds vtable state with [0] * numfields, lazy create sharedStrings dict to speed up objects with no strings

  • Offset/Pad/Prep all work off cached head/buffer lengths and zero-fill via slices

  • Prepend now handles alignment + byte writes in one pass

  • Vtable write is batched: WriteVtable gathers all field offsets plus metadata and streams them

Performance is 1.6x faster: old time: 63.0 us, new time 39.2 us

before_perf.txt
after_perf.txt

@google-cla
Copy link

google-cla bot commented Nov 9, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added the python label Nov 9, 2025
@satur9nine satur9nine force-pushed the python-perf branch 4 times, most recently from 8396420 to ec85faf Compare November 15, 2025 19:55
@satur9nine satur9nine changed the title Increase python performance [Python] Increase python builder performance Nov 15, 2025
@satur9nine satur9nine changed the title [Python] Increase python builder performance [Python] Improve python builder performance Nov 15, 2025
@satur9nine satur9nine force-pushed the python-perf branch 2 times, most recently from 89b94cf to c2467b0 Compare November 18, 2025 17:55
- Builder startup work is cheaper: StartObject now seeds vtable state
  with [0] * numfields, lazy create sharedStrings dict to speed up
  objects with no strings

- Offset/Pad/Prep all work off cached head/buffer lengths and zero-fill
  via slices

- Prepend now handles alignment + byte writes in one pass

- Vtable write is batched: WriteVtable gathers all field offsets plus
  metadata and streams them
@jtdavis777
Copy link
Collaborator

I'll take a crack at this one too but might help to get some additional eyes -- @fliiiix if you have some spare time I'd appreciate the help!

@fliiiix
Copy link
Contributor

fliiiix commented Nov 27, 2025

I had a look and closed it again 🙈 It would have been probably better to review if the changes would be split into separate commits

but i will give it an other look if i find time tomorrow

@satur9nine
Copy link
Contributor Author

satur9nine commented Nov 27, 2025

I had a look and closed it again 🙈 It would have been probably better to review if the changes would be split into separate commits

but i will give it an other look if i find time tomorrow

OK I have split this into 3 parts that build off each other, suggest review just the first and merge, then rebase and review the second, and so on, so that you see just one new commit worth of changes at a time:

#8807
#8808
#8809

I actually removed some of the optimizations that seemed to produce extremely minimal gain so the group of three is less code overall.

Feel free to close this if you prefer the phased approach.

@satur9nine
Copy link
Contributor Author

satur9nine commented Nov 28, 2025

Prefer the 3 commit approach

@satur9nine satur9nine closed this Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants