Skip to content
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

Reduce glyph key to 32 bits #2894

Merged
merged 1 commit into from Jul 18, 2018
Merged

Reduce glyph key to 32 bits #2894

merged 1 commit into from Jul 18, 2018

Conversation

@kvark
Copy link
Member

kvark commented Jul 13, 2018

Related to #2890.

As we do quite a few hashmap accesses (at least one per frame per glyph) by this key, reducing its size should help.

r? anyone


This change is Reviewable

@gw3583
Copy link
Collaborator

gw3583 commented Jul 15, 2018

Reftests with unexpected results:
	reftests/text/shadow-red.yaml == reftests/text/shadow-red-ref.yaml
	reftests/text/shadow-grey.yaml == reftests/text/shadow-grey-ref.yaml
	reftests/text/shadow-grey-transparent.yaml == reftests/text/shadow-grey-ref.yaml
	reftests/text/synthetic-bold-transparent.yaml == reftests/text/synthetic-bold-transparent-ref.yaml
	reftests/text/ahem.yaml == reftests/text/ahem-ref.yaml
	reftests/text/isolated-text.yaml == reftests/text/isolated-text.png
	reftests/text/colors.yaml == reftests/text/colors-alpha.png
	reftests/text/colors.yaml == reftests/text/colors-subpx.png
	reftests/text/colors.yaml == reftests/text/colors-subpx.png
	reftests/text/border-radius.yaml == reftests/text/border-radius-alpha.png
	reftests/text/border-radius.yaml == reftests/text/border-radius-subpx.png
	reftests/text/text-masking.yaml == reftests/text/text-masking-alpha.png
	reftests/text/text-masking.yaml == reftests/text/text-masking-subpx.png
	reftests/text/alpha-transform.yaml == reftests/text/alpha-transform.png
	reftests/text/subpixel-rotate.yaml == reftests/text/subpixel-rotate.png
	reftests/text/subpixel-scale.yaml == reftests/text/subpixel-scale.png
	reftests/text/subpixel-skew.yaml == reftests/text/subpixel-skew.png
	reftests/text/embedded-bitmaps.yaml == reftests/text/embedded-bitmaps.png
	reftests/text/clipped-transform.yaml == reftests/text/clipped-transform.png
	reftests/text/blurred-shadow-local-clip-rect.yaml == reftests/text/blurred-shadow-local-clip-rect-ref.png
	reftests/text/two-shadows.yaml == reftests/text/two-shadows.png
	reftests/text/shadow-clip.yaml == reftests/text/shadow-clip-ref.yaml
	reftests/text/shadow-partial-glyph.yaml == reftests/text/shadow-partial-glyph-ref.yaml
	reftests/text/shadow-transforms.yaml == reftests/text/shadow-transforms.png
	reftests/text/raster-space.yaml == reftests/text/raster-space.png

I'm not sure this is a valid change - I think the index value for a glyph can make use of the full 32 bit range on some fonts / platforms?

@kvark
Copy link
Member Author

kvark commented Jul 16, 2018

I double checked our macos and windows modules and they both appear to manage glyph indices as u16. As for Unix's FreeType, I wasn't able to find any concrete description of the glyph index format. I suppose it's opaque and we can't actually cut away 4 bits from it. Could you confirm, @lsalzman ?
If that's the case, I'll just make GlyphKey be platform-defined, with Unix taking a slightly slower route.

@lsalzman
Copy link
Contributor

lsalzman commented Jul 16, 2018

In practice, glyph ids in faces will probably never exceed a u16, though the types allow for it.

One idea in the worst case for GlyphKey would be to encode everything in a u32 bitfield. 28 bits for index, 2 bits for subpixel X, bits for subpixel Y, since the subpixel offset only requires 2 bits per field? Then you basically wouldn't have any issues fitting large fonts?

@kvark
Copy link
Member Author

kvark commented Jul 16, 2018

@lsalzman ok, good, thanks for the confirmation!

One idea in the worst case for GlyphKey would be to encode everything in a u32 bitfield. 28 bits for index, 2 bits for subpixel X, bits for subpixel Y, since the subpixel offset only requires 2 bits per field? Then you basically wouldn't have any issues fitting large fonts?

Funny thing is that this PR does exactly that. I just made a mistake somewhere, probably.

@kvark kvark force-pushed the kvark:glyph-key branch from 69d80f5 to f14bdab Jul 16, 2018
@kvark
Copy link
Member Author

kvark commented Jul 16, 2018

Alright, this should be fixed now. Got bitten by the operator precedence, ouch.

@kvark kvark mentioned this pull request Jul 16, 2018
0 of 3 tasks complete
@gw3583
Copy link
Collaborator

gw3583 commented Jul 16, 2018

@kvark If mac and windows platforms use a u16, then it's probably reasonable to assume the same on unix platforms. So r=me on this - my only question is whether we need a try run first?

@kvark
Copy link
Member Author

kvark commented Jul 17, 2018

I'll make one tomorrow @gw3583 . Thanks for taking a look!

@kvark
Copy link
Member Author

kvark commented Jul 18, 2018

There appear to be a bunch of intermittent timeouts, but I don't see anything related to the PR. Am I using the wrong try settings, or just an unlucky base revision? cc @staktrace

@staktrace
Copy link
Contributor

staktrace commented Jul 18, 2018

Looks like unlucky base revision. I'd do another try push on m-c tip just to make sure.

@kvark
Copy link
Member Author

kvark commented Jul 18, 2018

The new try push looks better.
@bors-servo r=gw3583

@bors-servo
Copy link
Contributor

bors-servo commented Jul 18, 2018

📌 Commit f14bdab has been approved by gw3583

@bors-servo
Copy link
Contributor

bors-servo commented Jul 18, 2018

Testing commit f14bdab with merge 95c59bb...

bors-servo added a commit that referenced this pull request Jul 18, 2018
Reduce glyph key to 32 bits

Related to #2890.

As we do quite a few hashmap accesses (at least one per frame per glyph) by this key, reducing its size should help.

r? anyone

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2894)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 18, 2018

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: gw3583
Pushing 95c59bb to master...

@bors-servo bors-servo merged commit f14bdab into servo:master Jul 18, 2018
3 checks passed
3 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@kvark kvark deleted the kvark:glyph-key branch Jul 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.